This project has been created as part of the 42 curriculum by hel-asli, mes-salh, mkimdil, zderfouf, ichaabi.
Leets is a full-stack social and blogging platform built for the 42 Transcendence project. It allows users to register, log in (including OAuth and 2FA), manage their profile, add friends, publish and search posts, and chat in real time. The application is built as a microservices-based web app with a single-command deployment using Docker.
Deliver a production-ready, multi-user web application that demonstrates frontend and backend frameworks, real-time features, user management, DevOps practices, and data handling—meeting the mandatory Transcendence requirements and at least 14 module points.
- Frontend: Next.js (React) SPA with Tailwind CSS, server-side and client-side routing, and real-time updates via WebSockets where needed.
- Backend: Multiple Node.js (Express) microservices: user (auth, profile, friends, notifications), posts (CRUD, search, bookmarks), and chat (real-time messaging). All services use MongoDB.
- DevOps: Docker Compose for orchestration, Prometheus for metrics, Grafana for dashboards. Optional SSL for the user service (HTTPS).
- User registration and login (email/password, OAuth with Google, GitHub, 42).
- Two-factor authentication (TOTP + backup codes).
- User profiles (avatar, bio, social links) and friend system (add/remove, status).
- Posts microservice: create, edit, delete posts; full-text search; bookmarks; likes.
- Real-time chat between users (Socket.io).
- Notification system (friend requests, likes, comments).
- Data export/import and bulk operations.
- Monitoring with Prometheus and Grafana.
- Privacy Policy and Terms of Service pages.
- Docker and Docker Compose (so the project runs with a single command).
- OpenSSL (for generating self-signed SSL certificates for the user service).
- Make (optional but recommended for
make setup,make run, etc.). - A MongoDB instance reachable from the host and from containers (e.g. local MongoDB or MongoDB Atlas). The Compose file does not start MongoDB; configure each service’s
MONGODB_URIin.envaccordingly. - Node.js (only if you run services locally without Docker): v20+ for frontend and backend.
-
Clone the repository and go to the project root (where
docker-compose.ymlandMakefileare). -
Create
.envfiles from the examples (if missing,make setupwill copy them and exit so you can edit):services/user-service/.envfromservices/user-service/.env.exampleservices/posts-service/.envfromservices/posts-service/.env.exampleservices/chat-service/.envfromservices/chat-service/.env.example
-
Edit each
.env:- user-service: Set
MONGODB_URI(e.g.mongodb://mongodb:27017/user_servicefor a container namedmongodb, or your Atlas URI). SetJWT_SECRET,SESSION_SECRET, and optionallyEMAIL_*, OAuth credentials (GOOGLE_*,GITHUB_*,INTRA_*),API_KEY, and Cloudinary for avatars. - posts-service: Set
MONGODB_URI, sameJWT_SECRETas user-service,USER_SERVICE_URL,API_KEY, and optionally Cloudinary. - chat-service: Set any required variables (e.g. MongoDB if used).
- user-service: Set
-
SSL (for user-service HTTPS)
Runmake sslto generate self-signed certificates inservices/user-service/ssl/. Required for OAuth callbacks in production-like setup.
From the project root (same directory as docker-compose.yml):
# First time: check env, generate SSL, build images, and start
make setup
# or: make check-env && make ssl && make build && make runIf .env files were already created and you only need to start:
make run
# or: docker compose up -d- Frontend: http://localhost:3000
- User API: https://localhost:3001
- Posts API: http://localhost:3004
- Chat API: http://localhost:3002
- Grafana: http://localhost:3005 (default admin/admin)
- Prometheus: http://localhost:9090
To stop:
make down
# or: docker compose downSee make help (or run make) for other targets (e.g. make logs, make logs-user, make frontend-rebuild).
- Next.js Documentation
- Express.js Guide
- MongoDB Manual
- Mongoose ODM
- Socket.io Documentation
- Docker Compose
- Prometheus, Grafana
AI was used for: brainstorming project structure and module choices, drafting documentation and README sections, debugging and explaining error messages, and reviewing code style. All implementation decisions and code were reviewed and understood by the team; no AI-generated code was integrated without review and testing.
| Login | Assigned role(s) | Responsibilities |
|---|---|---|
| hel-asli | PM, Developer | Project coordination, task distribution, meetings. Figma design, basic microservices structure, landing page, login/sign-up, privacy policy (frontend). Containers and DBs setup/management. Collaboration across features. |
| mes-salh | Developer | Posts microservice (backend and API). Search (frontend and backend). Import/export and bulk data. Collaboration with other teammates. |
| mkimdil | Tech Lead, Developer | Technical architecture and DB schema. User authentication, 2FA. DevOps (Docker, monitoring). Notification system (backend). Monitoring (Prometheus/Grafana). |
| zderfouf | Developer | Chat microservice fullstack (real-time messaging, API, frontend integration). |
| ichaabi | PO, Developer | Product vision and priorities. Profile and friend system fullstack (backend APIs, frontend pages and UX). |
- Work organization: Tasks were split by feature area (auth, posts, chat, profile/friends, DevOps, frontend base). Each member owned one or more areas and contributed to shared parts (e.g. frontend layout, env setup).
- Tools: GitHub (or equivalent) for code and issues; a shared board (e.g. Trello or GitHub Projects) for task distribution and status.
- Communication: Regular syncs (e.g. weekly) and a dedicated channel (Discord/Slack) for daily coordination and blockers.
| Layer | Technologies | Notes |
|---|---|---|
| Frontend | Next.js 16, React 19, TypeScript, Tailwind CSS, Framer Motion, Zustand, Socket.io-client, Axios | Framework and UI; real-time via Socket.io. |
| Backend | Node.js, Express 5 (user-service, posts-service), TypeScript (chat-service), Mongoose, Socket.io, Passport (local + Google, GitHub, 42), Speakeasy (2FA), JWT | Microservices with REST and WebSockets. |
| Database | MongoDB | Chosen for flexible schema, good fit for user profiles, posts, notifications, and chat messages; used across user, posts, and chat services (each with own DB or collections). |
| DevOps | Docker, Docker Compose, Prometheus, Grafana | Single-command run; metrics and dashboards for monitoring. |
| Other | Cloudinary (avatars, post images), Nodemailer (emails), bcrypt, Helmet, rate limiting | Security and external services. |
Major technical choices:
- Microservices: Clear separation (user, posts, chat) for scalability and independent deployment; services communicate via REST and shared JWT/API keys.
- Next.js: SSR/SSG where useful, API routes for proxying, and a single frontend app for all features.
- MongoDB: Document model fits nested structures (e.g. friends, preferences, notifications) and fast iteration during development.
The application uses MongoDB with one database per service (or logical separation). Main collections and relationships:
- User:
email,password(hashed),username,firstName,lastName,avatar,coverImage,bio,location,pronouns,socialLinks,friends(array of{ userId, status, addedAt, initiatedBy }),isOnline,lastSeen,isEmailVerified,role,oauthProvider,googleId/githubId/intraId,isTwoFactorEnabled,twoFactorSecret,twoFactorBackupCodes,preferences,followedTags, timestamps. Indexes onemail,username,friends.userId,isOnline,lastSeen. - Notification:
userId,type(e.g. friend_request, like, new_comment),read,message,data(e.g. fromUserId, postId). Indexes onuserIdandcreatedAt.
- Post:
title,slug,content,excerpt,coverImage,tags,authorId, embeddedauthorsnapshot,status(draft/published),likes,likesBy,commentsCount, timestamps. Indexes onslug,authorId,status,tags, and text index ontitle/contentfor search. - Bookmark:
userId,postId. Unique compound index on(userId, postId).
- Message:
fromId,toId(ObjectIds referencing users),text,image,isEdited, timestamps.
Relationships: User owns notifications; User is author of posts; Post is referenced by Bookmark; Message links two users. Cross-service links (e.g. authorId in Post) are resolved via user-service API when needed.
| Feature | Description | Team member(s) |
|---|---|---|
| Landing page | Public homepage and navigation | hel-asli |
| Login / Sign up | Email/password and OAuth (Google, GitHub, 42) | hel-asli, mkimdil |
| Privacy policy & Terms of Service | Accessible pages with real content | hel-asli |
| User authentication | JWT, sessions, password hashing, lockout | mkimdil |
| Two-factor authentication (2FA) | TOTP and backup codes | mkimdil |
| User profile | View/edit profile, avatar, bio, social links | ichaabi |
| Friend system | Add/remove friends, list, status (pending/accepted/blocked) | ichaabi |
| Notifications | Friend requests, likes, comments; read state | mkimdil |
| Posts CRUD | Create, edit, delete posts; draft/published | mes-salh |
| Post search | Full-text and filters, sorting, pagination | mes-salh |
| Bookmarks & likes | Save posts, like posts | mes-salh |
| Chat | Real-time messaging between users | zderfouf |
| Data export/import & bulk | Export/import and bulk operations | mes-salh |
| Containers & DBs | Docker Compose, service and DB setup | hel-asli, mkimdil |
| Monitoring | Prometheus + Grafana | mkimdil |
| Microservices structure | Split into user, posts, chat services | hel-asli, mkimdil |
| Module (category) | Type | Points | Justification | Implementation | Team member(s) |
|---|---|---|---|---|---|
| Use framework frontend + backend (Web) | Major | 2 | Next.js (frontend) and Express (backend) used across the app. | Next.js for UI and API routes; Express in user, posts, chat services. | All |
| Real-time features WebSockets (Web) | Major | 2 | Chat and live updates require real-time communication. | Socket.io in chat-service and frontend; optional events in user-service. | zderfouf, mkimdil |
| User interaction: chat, profile, friends (Web) | Major | 2 | Core social features: messaging, profiles, friend list. | Chat microservice; profile and friends in user-service and frontend. | zderfouf, ichaabi |
| Standard user management (User Management) | Major | 2 | Sign up, login, profile update, avatar, friends, online status. | User model, auth routes, profile and friend APIs, frontend pages. | mkimdil, ichaabi, hel-asli |
| OAuth 2.0 (User Management) | Minor | 1 | Login with Google, GitHub, 42. | Passport strategies, callbacks, session/JWT. | mkimdil, hel-asli |
| 2FA (User Management) | Minor | 1 | Extra security for sensitive accounts. | Speakeasy TOTP, QR flow, backup codes in User model. | mkimdil |
| Monitoring Prometheus + Grafana (DevOps) | Major | 2 | Observe service health and performance. | Prometheus scrape config, Grafana datasource and dashboards. | mkimdil |
| Backend as microservices (DevOps) | Major | 2 | Scalability and clear boundaries. | user-service, posts-service, chat-service; REST and shared auth. | hel-asli, mkimdil |
| Advanced search (Web) | Minor | 1 | Find posts by text and filters. | MongoDB text index, query params, pagination. | mes-salh |
| Data export/import (Data and Analytics) | Minor | 1 | User and bulk data handling. | Export/import endpoints and validation; bulk operations. | mes-salh |
| Complete notification system (Web) | Minor | 1 | Notifications for key actions. | Notification model, creation on events, read state, API. | mkimdil |
| Use an ORM for the database (Web) | Minor | 1 | Consistent data access and schema validation across services. | Mongoose (ODM) in user-service, posts-service, and chat-service for all MongoDB access. | All |
| Server-Side Rendering – SSR (Web) | Minor | 1 | Improved performance and SEO for public content. | Next.js SSR (e.g. getServerSideProps or App Router server components) for landing, post view, and public profile pages. | hel-asli / frontend |
Point total: 2+2+2+2+1+1+2+2+1+1+1+1+1 = 19 points (≥14 required).
- hel-asli: Figma design; basic project structure (microservices, repos, Docker). Landing page, login page, sign-up page, privacy policy (frontend). Container and database setup and management. Ongoing collaboration with others on frontend and integration.
- mes-salh: Posts microservice (API, CRUD, author resolution). Search (frontend and backend) with filters and pagination. Import/export and bulk data handling. Collaboration on shared frontend and API contracts.
- mkimdil: Database schema design (User, Notification, and coordination with posts/chat). User authentication (local + OAuth, JWT, sessions). Full 2FA flow (TOTP, backup codes). DevOps: Docker Compose, monitoring (Prometheus, Grafana). Notification system (backend). Addressed security and deployment challenges.
- zderfouf: Chat microservice fullstack: backend (Express/TypeScript, Socket.io, message persistence), frontend (UI, real-time send/receive). Integration with user context and friend list.
- ichaabi: Profile and friend system fullstack: user profile API and frontend (view/edit, avatar, bio, social links), friend APIs (add/remove, list, status), and frontend for friend requests and list.
