A full-featured Reddit Clone RESTful API, built with Node.js, Express.js, and PostgreSQL. It follows a 3-Tier Architecture (Presentation, Business Logic, Data Access), supports authentication, posts, comments, votes, and notifications.
Check out the full API documentation here:
👉 Postman Docs
- Backend: Node.js, Express.js
- Database: PostgreSQL
- Authentication: JWT (JSON Web Token), bcryptjs
- Email Service: Nodemailer
- Notifications: Socket.IO
- Security: Helmet, Rate Limiting
- Environment Config: dotenv
- Logging: Morgan
- Development Tools: Nodemon
- File Upload: Multer
reddit-clone-api/
├── config/
| └── index.js
├── scripts/
| └── db-ddl.sql
├── src/
│ ├── controllers/
| ├── handlers/
│ ├── middlewares/
│ ├── models/
| ├── repositories/
│ ├── routes/
| ├── services/
│ ├── utils/
| ├── app.js
│ └── server.js
├── .gitignore
├── count_lines.sh
├── project_requirements.md
├── LICENSE
└── README.md
- Register new users
- Email verification
- Login with JWT
- Password reset via email
- Get current user info
- Create/update/delete posts
- Pagination support
- Search by content
- Image support: upload up to 10 images per post
- Add/update/delete comments & replies
- Paginated fetch
- Nested replies support
- Upvote/downvote posts and comments
- Get user-specific votes
- Remove vote
- Real-time via Socket.IO
- Mark notifications as read
- Fetch all unread notifications
git clone https://github.com/MohamedM216/reddit-clone-api.git
cd reddit-clone-api
npm install
Create a .env file in the root directory:
PORT=3000
DATABASE_URL=postgres://youruser:yourpassword@localhost:5432/reddit
JWT_SECRET=your_jwt_secret
[email protected]
EMAIL_PASS=your_email_password
BASE_URL=http://localhost:3000
Development
npm run dev
Production
npm start
- Rate Limiting (express-rate-limit)
- Input Sanitization
- JWT-based Auth
- Password Hashing with bcryptjs
- Helmet for setting HTTP headers
- Unit tests
- Sorting posts (New, Top, Controversial)
- Users update their profiles
- Notify users when other users mention them (@username)
- Notify when there are system updates
- Most active users, trending posts.
This project is licensed under the MIT License.