Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

629 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ ft_transcendence

Live: starcendence.dev

๐ŸŽฏ Project Overview

ft_transcendence is a full-stack, real-time multiplayer gaming platform developed as part of the 42 curriculum. The project focuses on low-latency gameplay, microservices architecture, and modern web technologies.

The platform includes:

  • A 3D Pong game built with Babylon.js
  • A Star Wars Pod Racingโ€“inspired racing game
  • Real-time multiplayer using WebSockets
  • Live chat, tournaments, AI opponents, and user profiles
  • Secure authentication with OAuth and 2FA
  • A containerized microservices backend

The system is designed to be scalable, modular, and fault-tolerant, mirroring real-world production architectures.


๐ŸŽฎ Features (Modules)

Major Modules (11 modules)

  • โšก Fastify Backend - High-performance server framework
  • ๐Ÿ—๏ธ Backend as Microservices - Distributed architecture
  • ๐Ÿ‘ค Standard User Management - Auth + profiles + friends
  • ๐Ÿ”‘ Google Sign-in - OAuth integration
  • ๐ŸŒ Remote Players - WebSocket multiplayer
  • ๐ŸŽ๏ธ Star Wars Racer + Matchmaking - Second game with pairing
  • ๐Ÿ’ฌ Live Chat - Real-time messaging
  • ๐Ÿค– AI Opponent - Intelligent computer players
  • ๐Ÿ” 2FA + JWT - Advanced security
  • ๐ŸŽ† Advanced 3D Babylon.js - 3D graphics engine

Minor Modules (7 modules)

  • ๐ŸŽจ Tailwind CSS - Styling framework
  • ๐Ÿ’พ SQLite Database - Data persistence
  • โš™๏ธ Game Customization - Power-ups and variations
  • ๐Ÿ“Š Stats Dashboards - User analytics
  • ๐Ÿ“ฑ All Devices Support - Responsive design
  • ๐ŸŒ Browser Compatibility - Firefox + Chrome
  • ๐Ÿ“ˆ Prometheus/Grafana - System monitoring

๐Ÿ—๏ธ System Architecture

Frontend (TypeScript + Tailwind + Babylon.js)
    โ†“
API Gateway (Nginx)
    โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Microservices                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   Auth  โ”‚  Game   โ”‚  Chat   โ”‚  User   โ”‚WebSocketโ”‚
โ”‚  :3001  โ”‚ :3002   โ”‚ :3003   โ”‚ :3004   โ”‚ :3005  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ†“               โ†“               โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          Infrastructure Services                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚     Redis       โ”‚          SQLite               โ”‚
โ”‚ (Cache+PubSub)  โ”‚        (Persistent)           โ”‚
โ”‚     :6379       โ”‚           File                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ Project Structure

frontend/ UI and games
services/ Backend microservices
shared/ Shared types and utils
infrastructure/ Redis, database, monitoring

๐Ÿš€ Technology Stack

Frontend Technologies

  • TypeScript: Type-safe development
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first styling framework
  • Babylon.js: 3D graphics engine for games

Backend Technologies

  • Fastify: High-performance Node.js web framework
  • SQLite: Lightweight, reliable database
  • Redis: In-memory cache and message broker
  • JWT: Secure authentication tokens

DevOps & Quality

  • Docker: Containerized development and deployment
  • Nginx: Reverse proxy and SSL termination
  • Prometheus + Grafana: Monitoring and observability

๐Ÿ“Š Microservices Communication

Service Ports & Responsibilities

nginx:80/443        โ†’ API Gateway + SSL termination
frontend:3000       โ†’ Vite dev server / Static files
auth-service:3001   โ†’ JWT, 2FA, Google OAuth, Sessions
game-service:3002   โ†’ Game engines, AI, Physics, Tournaments  
chat-service:3003   โ†’ Real-time messaging, Chat rooms
user-service:3004   โ†’ Profiles, Friends, Stats, Avatars
websocket-service:3005 โ†’ Real-time events, Broadcasting
redis:6379          โ†’ Cache + PubSub messaging
sqlite:file         โ†’ Persistent data storage
prometheus:9090     โ†’ Metrics collection
grafana:3010        โ†’ Monitoring dashboards

API Gateway Routes (Nginx)

/auth/*     โ†’ auth-service:3001
/games/*    โ†’ game-service:3002
/chat/*     โ†’ chat-service:3003
/users/*    โ†’ user-service:3004
/ws         โ†’ websocket-service:3005
/metrics    โ†’ prometheus:9090
/grafana/*  โ†’ grafana:3010

Event-Driven Communication (Redis PubSub)

Redis Pub/Sub is used only between Game Service and WebSocket Service.

Lobby Events:
- lobby:create
- lobby:invite
- lobby:join
- lobby:leave
- lobby:kick
- lobby:ready
- lobby:start
- lobby:chat
- lobby:player:update
- lobby:quick-play

Game Events:
- game:move
- game:action
- game:pause
- game:resume
- game:end
- game:input
- game:ready
- game:start
- game:leave
- game:state
- game:event

โšก Performance & Security Architecture

Latency Optimization Strategy

HIGH LATENCY (Login/Setup - 80-200ms):
Frontend โ†’ game-service โ†’ auth-service (validate token)
                       โ†’ user-service (get profile)  
                       โ†’ chat-service (join channel)

LOW LATENCY (Gameplay - 6-20ms):
Frontend โ†’ websocket โ†’ game-service (cached validation)
                    โ†’ broadcast (local state)

๐ŸŽฎ Games & Features

3D Pong (Babylon.js)

  • Server-authoritative physics (paddle movement, ball collision)
  • Real-time multiplayer with lag compensation
  • AI opponents with adaptive difficulty
  • Tournament system with bracket management
  • Ultra-low latency validation (< 1ms per input)

Star Wars Racer

  • Complex physics simulation (vehicle dynamics)
  • Track boundary enforcement
  • Advanced collision detection

Real-time Architecture

  • WebSocket connections for 60fps gameplay
  • Redis PubSub for event broadcasting
  • Cached player data for instant validation
  • Cross-service communication optimized for gaming

Advanced Features

  • Auth: JWT + 2FA + Google OAuth + Session management
  • Live Chat: Real-time messaging, Game invitations, User presence
  • Monitoring: Prometheus metrics + Grafana dashboards + Performance tracking

๐Ÿ› ๏ธ Microservices Benefits in Gaming

โœ… Independent Scaling:
   - Game service: CPU-intensive (3D physics)
   - Chat service: I/O-intensive (messaging)
   - Auth service: Security-focused (encryption)

โœ… Fault Isolation:
   - If chat crashes โ†’ games continue
   - If auth is slow โ†’ games use cached tokens
   - Database separation prevents cascade failures

โœ… Development Efficiency:
   - Teams work independently on services
   - Deploy services without downtime
   - Technology flexibility per service

โœ… Gaming-Specific Optimizations:
   - Game service: Optimized for low-latency
   - Chat service: Optimized for high-throughput
   - User service: Optimized for complex queries

๐Ÿง‘โ€๐Ÿ’ป Team

hluiz
hluiz-ma
jpedro-c
jpedro-c
rafaelfe
rafaelfe
jmeirele
jmeirele

About

Real-time 3D gaming platform featuring Pong and Star Wars Pod Racing with live multiplayer, tournaments, AI opponents, and integrated chat system. Built with TypeScript, Babylon.js, and microservices architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages