How abdeladim-fadlane/42cursus-ft_transcendence works
Main Components
• Client (Browser): Represents the end-user’s interface where the game, chat, and authentication flows occur.
• Web Server (Frontend Layer):
– Located in the “WebServer” folder.
– Consists of static assets (HTML, CSS, JavaScript) and an Nginx configuration (nginx.conf) for routing.
– Acts as the entry point for users, providing the game’s landing pages and handling asset delivery.
• Authentication Service:
– Found under the “auth” directory.
– A Django project responsible for user authentication, registration, and authorization.
– Uses RESTful APIs and connects to a SQL database (PostgreSQL as noted in the README).
• Chat Service:
– Located in the “chat” folder (subdirectories “chatApp” and “chatlive”).
– Handles real-time chat functionality through Django Channels (WebSocket consumers) for in-game communication.
• Game Service:
– Found in the “game” folder.
– This service manages the core game logic, real-time multiplayer interactions (likely involving WebSockets), and game state.
• Tracking / Analytics Service:
– Found in the “track” folder.
– Monitors game events or user activity, further enhancing the interactive elements of the game.
• Additional Infrastructure:
– Docker Compose (docker-compose.yml) to orchestrate services.
– Individual Dockerfiles under “WebServer”, “auth”, and scripts in “chat”, “game”, and “track” to containerize each service.
– CI/CD configuration using GitHub workflows to build Docker images.
Out the Relationships and Interactions
• Client interacts with the Web Server (Nginx) which serves the static assets.
• The Web Server acts as a reverse proxy:
– Routes API calls to the Authentication Service for managing user data.
– Establishes WebSocket connections to the Chat and Game services for real-time communication.
• The Authentication Service uses SQL (PostgreSQL) for persisting user and game-related data.
• The Chat Service and Game Service communicate real-time data flows (players chatting and game state updates) typically via asynchronous channels enabled by Django Channels.
• The Tracking Service observes and records events happening in other services for game analytics and may interact with the database as required.
Architectural Patterns and Design Principles
• Microservices Architecture: Each core function (authentication, chat, game logic, tracking) is separated into its own service.
• Containerization: Use of Docker and docker-compose to deploy isolated services.
• Asynchronous Communication: Use of WebSockets and Django Channels in chat and game services to manage real-time data.
• RESTful Design: APIs for handling authentication and potentially other data exchanges between services.
• Load Balancing & Scalability: Nginx is leveraged not only for serving static assets but also for directing traffic to microservices, ensuring smooth scalability.
• Security: Incorporation of robust authentication methods (OAuth 2.0 with 42 API integration) and secure API gateways.
Technologies, Frameworks, and External Links
• Django & Django Channels for backend logic and real-time functionality.
• PostgreSQL as the database management system.
• Nginx for routing and serving static content.
• Docker and docker-compose for containerization and orchestration.
• Additional dependencies such as Django Rest Framework are implied by the authentication and API components.
• Referenced links in the README provide further context on each technology’s role.
Final Detailed Architecture Breakdown
• Top Layer: Clients (Browsers) interacting via HTTPS.
• Middle Layer: Nginx-based Web Server handling static content and acting as a reverse proxy.
• Data Layer: PostgreSQL database supporting persistent storage.