How bekrobot99/42-ft_transcendence works
Project type and purpose
• This is a full-stack, real-time multiplayer ping-pong web application (2D & 3D modes).
• Frontend: TypeScript SPA (Canvas API + Babylon.js)
• Backend: Node.js & Fastify REST + WebSocket real-time server
• Data store: SQLite
• Containerized via Docker, reverse-proxied with nginx, SSL/TLS enabled
File structure
• Top-level “frontend/” and “backend/” folders indicate clear separation of presentation vs. application layers
• “backend/src/api/” contains REST endpoints (auth, profile, tournaments, etc.)
• “backend/src/websocket.ts” and related services implement real-time gameplay
• “frontend/src/views/” hosts visual pages (Home, Game2D, Game3D, etc.) and UI components under “ui/”
• Deployment artifacts: Dockerfiles for frontend, backend, Docker Compose files, nginx configs, SSL certificates
Key architecture points from README
• SPA served by nginx: static assets delivered over HTTPS
• Backend API & WebSocket endpoints handled by Fastify server
• JWT + Google OAuth + 2FA for secure authentication
• Tournament subsystem, user profiles, friend management all behind REST API
• Real-time game loops & state syncing via WebSocket channels
a. Client (Browser)
– Renders SPA, initiates HTTP(s) and WebSocket connections
b. nginx reverse proxy
– Terminates SSL, serves static assets, forwards API/WebSocket traffic
c. Frontend container
– Hosts index.html, compiled JS (Canvas & Babylon.js engines)
d. Backend container
– Fastify server exposes:
• REST API (authentication, user, tournament, profile, etc.)
• WebSocket endpoint for live game sessions
e. SQLite database
– Embedded file-based DB for persistent user, tournament, match records
f. External services
– Google OAuth endpoints for third-party login
Relationships & data flows
1. Browser → HTTPS → nginx → static assets OR proxy to Fastify REST
2. Browser WebSocket handshake → nginx → Fastify websocket.ts
3. Fastify → read/write SQLite via database config module
4. Fastify → external Google OAuth service for sign-in/up
– Request/response (HTTP REST)
– Bi-directional WebSocket streams
– Backend–DB interactions
– Backend–OAuth flows
Architectural patterns & principles
• Three-tier separation: Presentation (SPA), Application (Fastify), Data (SQLite)
• Containerized micro-deployment: individual Docker containers orchestrated by Docker Compose
• Secure boundary: nginx as reverse proxy + SSL + JWT gateways
• Real-time event-driven domain: WebSocket pub/sub for game state sync
Technologies & frameworks to annotate
• Frontend: TypeScript, Canvas API, Babylon.js, WebSocket client
• Backend: Node.js, Fastify, TypeScript, WebSocket server, bcrypt/TOTP for 2FA
• Database: SQLite via TypeORM or custom DB config
• DevOps: Docker, Docker Compose, nginx, railway/render configs