How xdarksyderx/ft_transcendence works
Project Type and Purpose
• This project (“ft_transcendence”) is built as a multi-microservice application.
• Its structure indicates support for multiple games (chess and pong) along with user authentication (“auth”), social features (“social”), and notifications.
• There’s a dedicated frontend component, and a gateway (likely based on Nginx) to route external requests.
• The overall purpose is to provide a full-featured online platform integrating interactive games with social and notification functionalities.
File Structure to Determine Architectural Components
• Main services are organized in individual directories:
– auth: Handles authentication and user management (login, logout, registration, OAuth callbacks, etc.).
– chess: Contains game logic for chess (multiple game modes and pieces logic).
– pong: Implements gameplay functionality for the pong game.
– social: Manages social interactions, including chat, friends, and related API endpoints.
– notifications: Provides asynchronous notifications and messaging features (with Celery tasks, RabbitMQ integration, and event handling).
• Separate frontend directory: Contains the web client’s assets like HTML, CSS, and JavaScript. It has its own Docker support (and reference to a lightweight web server via “lighttpd.conf”).
• Gateway directory: Contains configuration for a reverse proxy setup (using an Nginx configuration), which is key for routing incoming requests to the appropriate backend services.
• Each service contains its own configuration, Dockerfile, entrypoint scripts, and dev container setups ensuring isolation and independent deployment.
Key Components and Their Relationships
• Frontend:
– Acts as the client-facing part of the system.
– Communicates with the backend through API calls routed by the gateway.
• API Gateway:
– Serves as the reverse proxy, directing incoming HTTP/HTTPS requests to the correct microservice (auth, chess, pong, social, notifications).
– Manages security and may perform load balancing.
• Auth Service:
– Manages user authentication, OAuth logins, token management, and possibly session handling.
– Other services likely depend on it for verifying user identities and permissions.
• Game Services (Chess & Pong):
– Implement game logic, manage sessions/matches, and include various game modes.
– Use messaging (RabbitMQ) to notify other components or trigger tasks.
• Social Service:
– Provides features for chat, managing friends, and social interactions among users.
– Uses WebSockets or similar real-time communication mechanisms.
• Notifications Service:
– Centralizes the delivery of system notifications.
– Uses asynchronous tasks (Celery) and event-driven communication, as indicated by tasks and messaging utilities.
• Shared Infrastructure:
– RabbitMQ clients appear in several services (auth, chess, notifications, pong, social) suggesting a message-bus for asynchronous events.
– Each service has its own configuration (ASGI, WSGI, Celery apps) which may hint at a common framework (like Django or similar) used across the services.
Architectural Patterns and Design Principles
• Microservices Architecture:
– Each service is independently deployed, containerized (via Docker and devcontainer setups), and likely communicates over well-defined APIs.
– Use of a gateway emphasizes separation of concerns and decouples the frontend from backend service implementations.
• API-driven and Event-driven Communication:
– The presence of REST API endpoints, async messaging (RabbitMQ) and worker tasks (Celery) implies that services communicate both synchronously (via HTTP) and asynchronously.
• Containerization for Isolation:
– Dockerfiles in every major directory and a compose.yaml file indicate orchestration of multiple containers.