- About
- Key Features
- Tech Stack
- Requirements
- Setup Instructions
- License
OpenAdClassify is a straightforward classified ads app built with the latest versions of Next.js (14.2.6) and NestJS (10.4.4). It allows users to post and manage ads, chat in real-time, and offers secure access with strong authentication.
- CRUD Operations for Ads: Users can create, read, update, and delete ads.
- Real-Time Messaging: Integrated real-time messaging using Socket.IO for instant communication and message status updates.
- Ad History Page: Dedicated page to view, edit, and delete previous ads.
- Media Management: Upload and manage media associated with ads.
- Authentication and Authorization: JWT-based authentication with role-based access control, using HTTP-only cookies and token refresh mechanisms.
- Notifications: Real-time notifications for new messages.
- Responsive UI: Enhanced user experience with a minimalist footer, loading spinners, and various UX/UI improvements.
- Protected Routes: Route redirection for protected and restricted areas.
- Error Handling: Improved error handling and configurable token expiration.
- NestJS: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
- Prisma: A modern database toolkit to query and manage data in PostgreSQL.
- PostgreSQL: Database system used for storing application data.
- Redis: Used for managing JWT token refresh and revocation.
- Socket.IO: For real-time communication and messaging.
- JWT: For secure token-based authentication.
- ioredis: Redis client for Node.js.
- Bcrypt: For hashing passwords.
- Next.js: A React framework for server-side rendering and static site generation.
- React: A JavaScript library for building user interfaces.
- Redux Toolkit: For state management.
- Axios: For making HTTP requests.
- Bootstrap: CSS framework for responsive design.
- Tailwind CSS: Utility-first CSS framework.
- React Toastify: For adding notifications.
- Node.js:
- Frontend: 18.17.1 or higher.
- Backend: 20.6.0 or higher.
- PostgreSQL: For database management.
- Redis: For caching and token management. Can be easily installed via Docker Desktop by pulling the Redis image and starting it.
Clone the repository to your local machine:
git clone https://github.com/wassimfarah/OpenAdClassify.git
cd OpenAdClassify
Navigate to the backend
directory and install the dependencies:
cd backend
pnpm install # or use `npm install` or `yarn install`
Copy the example environment file to .env
and update it with your specific configuration:
cp .env.example .env
Create folders for storing media with the specified structure. You can create these directories manually or run the following commands.
Media Structure:
uploads
├── ads
│ ├── images
│ └── videos
└── profiles
└── avatars
For Linux and macOS (Unix-like systems):
mkdir -p uploads/{ads/{images,videos},profiles/avatars}
For Windows PowerShell:
New-Item -ItemType Directory -Path "uploads", "uploads/ads/images", "uploads/ads/videos", "uploads/profiles/avatars" -Force
Alternatively, create folders one at a time for Unix-like systems:
mkdir -p uploads
mkdir -p uploads/ads/images
mkdir -p uploads/ads/videos
mkdir -p uploads/profiles/avatars
Or for Windows Command Prompt (cmd.exe):
mkdir uploads
mkdir uploads\ads
mkdir uploads\ads\images
mkdir uploads\ads\videos
mkdir uploads\profiles
mkdir uploads\profiles\avatars
Create a new empty database in PostgreSQL and note down the database name, user, and password.
Update the .env
file with your specific PostgreSQL configuration (DB_NAME
, DATABASE_URL
, etc.).
Run the following command to generate the Prisma client:
npx prisma generate
Run the following command to apply the Prisma schema to your database:
npx prisma migrate dev
Seed the database with categories and subcategories by executing the seed.ts
script:
ts-node prisma/seed.ts
Start the backend server using your preferred package manager:
pnpm run dev # or use `npm run dev` or `yarn run dev`
You should see a message indicating the server is running on a specific port.
Using Docker (recommended):
-
Pull the Redis Image:
docker pull redis
-
Start a Redis Container:
docker run --name redis -p 6379:6379 -d redis
Without Docker (alternative):
-
Install Redis:
Follow the installation instructions for your Linux distribution from the official Redis documentation.
-
Start Redis:
redis-server
Navigate to the next_app
folder:
cd nextjs-app
Install the dependencies for the frontend:
pnpm install # or use `npm install` or `yarn install`
Copy the example environment file to .env.local
:
cp .env.example .env.local
Note: If you adjusted the port or origin in the backend .env
file, make sure to make corresponding adjustments in the env.local
file of the frontend. The ORIGIN
in the backend .env
must match the origin of the frontend.
Start the frontend server:
pnpm run dev # or use `npm run dev` or `yarn run dev`
This project is licensed under the MIT License
Thank you for checking out the Classified Ad Web Application! If you have any questions or need further assistance, feel free to contact me. Contributions are welcome, and I appreciate any feedback or suggestions. Enjoy building and exploring the application! 😊