Skip to content

Adel2k/ft_transendence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

121 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“– ft_transcendence

A web-based real-time multiplayer Pong game, built as part of the 42 School Common Core curriculum. This project challenged us to explore unfamiliar technologies, develop real-time web applications, and integrate various gameplay, user management, and security features โ€” all containerized via Docker.


๐Ÿ“Š Badges

Dockerized TypeScript Node.js JWT 2FA Prometheus SQLite Vault ModSecurity


๐ŸŽฅ Demo

Gameplay Demo


๐Ÿ“Œ Table of Contents


๐ŸŽฎ About the Project

ft_transcendence is a real-time, multiplayer Pong tournament platform with:

  • A clean, responsive, single-page interface
  • Real-time gameplay with matchmaking and tournaments
  • Secure authentication and user management
  • Integrated live chat and player profiles
  • Dockerized deployment for portability and ease of use

The project required mastering web technologies under constraints, focusing on problem-solving and adaptability rather than relying on familiar stacks.


๐Ÿš€ Features

  • Real-time 1v1 Pong gameplay
  • Tournament system with alias-based matchmaking
  • User registration/login, profile customization, and stats tracking
  • Match history
  • Game customization options
  • Remote multiplayer support
  • Responsive SPA built with TypeScript and Tailwind CSS
  • Fully containerized with Docker
  • Secure, validated user inputs and HTTPS connections

๐Ÿ› ๏ธ Technologies Used

  • Backend: Node.js (Fastify)
  • Frontend: TypeScript, Tailwind CSS, Babylon.js (for future 3D)
  • Database: SQLite
  • Authentication: JWT, 2FA (where applicable)
  • Containerization: Docker
  • Security: Hashicorp, ModSecurity

โš™๏ธ Setup & Installation

  1. Clone the repository

    git clone https://github.com/Adel2k/ft_transendence.git
    cd ft_transendence
  2. Configure environment variables

    Copy .env.example to .env and update accordingly.

  3. Build and run containers

    make
  4. Access the application at http://localhost


๐Ÿ“‚ Project Structure

ft_transcendence/
โ”œโ”€โ”€ backend/              # Fastify server, APIs, DB models
    โ””โ”€โ”€ database/         # SQLite DB and migrations
โ”œโ”€โ”€ frontend/             # TypeScript + Tailwind SPA
โ”œโ”€โ”€ docker-compose.yml    # Service orchestration
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ Dockerfile            # App container
โ”œโ”€โ”€ vault                 # Secret Manager hashicorp
โ”œโ”€โ”€ .env                  # Environment variables
โ””โ”€โ”€ README.md

๐ŸŽฏ Modules Implemented

โœ… Mandatory part

  • Real-time Pong game
  • Tournament matchmaking
  • SPA architecture
  • Dockerized deployment

โœ… Major Modules

  • Fastify-based Backend
  • User Management (signup/login/profile/avatar/friends)
  • Remote Multiplayer
  • 2FA + JWT Security

โœ… Minor Modules

  • Tailwind CSS for frontend
  • SQLite database
  • Game customization options
  • Stats dashboards
  • Accessibility improvements
  • Multi-browser support
  • Device responsiveness

๐Ÿ” Security Measures

Security was a top priority in the development of ft_transcendence. The following mechanisms were implemented to safeguard user data, communication, and system integrity:

  • Password hashing using bcrypt

  • Input validation and sanitization to protect against:

    • SQL Injection (SQLi)
    • Cross-Site Scripting (XSS)
  • HTTPS enforced across all communications (wss for WebSocket connections)

  • Google Sign-In OAuth 2.0 integration for secure, streamlined authentication:

    • Users can log in with their Google account credentials via OAuth
    • Access tokens and user profile data handled securely following OAuth best practices
    • Safe token exchange and session handling

Google sign in

  • JWT-based authentication with optional Two-Factor Authentication (2FA) for enhanced user security

2fa

  • Environment variables and secrets are securely stored using HashiCorp Vault:

    • API keys, database credentials, and other sensitive data are encrypted and isolated from the codebase
    • Centralized secret management minimizes exposure and simplifies access control

Google sign in

  • Web Application Firewall (WAF) powered by ModSecurity:

    • Hardened configuration to detect and block malicious traffic, such as:

      • Common web attacks (XSS, SQLi, CSRF)
      • Rate limiting for abuse prevention
      • Custom security rules for sensitive routes and APIs
  • Secure token handling and session management with automatic token expiration and invalidation

  • Docker container isolation and network restrictions to minimize attack surface


๐Ÿ“Š WebSocket User Status Management Diagram

Hereโ€™s an ASCII-style diagram you can include:

                        +--------------------+
                        |    Web Application   |
                        |  (Frontend SPA)      |
                        +----------+-----------+
                                   |
                                   |  WebSocket (wss)
                                   |
                        +----------v-----------+
                        |    Socket Server     |
                        | (Fastify + Socket.io)|
                        +----------+-----------+
                                   |
           +-----------------------+----------------------+
           |                       |                      |
  +--------v-------+       +-------v--------+      +-------v-------+
  |  User A (Online)|       |  User B (Offline)|    |  User C (Online)|
  +----------------+       +-----------------+    +----------------+
          |                          |                     |
          +-----[online status]------+                     |
          |                                                |
          +------------------------------[friend list updates]

    (When a socket connects, user is marked 'Online' in DB or in-memory)
    (When disconnects, server updates to 'Offline' and broadcasts updates)

๐Ÿ“Œ Diagram Summary:

  • Web app SPA connects via secure WebSocket (wss://)

  • Server tracks active sockets and marks users online/offline

  • On connect/disconnect:

    • Status is updated in DB (or memory)
    • Friends get live status updates via socket events Great call โ€” letโ€™s succinctly describe that too! Hereโ€™s a clean, one-liner you can slot into your Features and Notable Features sections:
  • Match history tracking โ€” each user can view a personal log of their past games, opponents, scores, and match dates.

Google sign in

  • Random unique avatars auto-assigned to new users at signup

Google sign in

  • Front-end displays real-time online/offline badges on friends list

๐Ÿ‘ฅ Contributors


๐Ÿ“ƒ License

This project is part of the 42 School curriculum and follows its internal project regulations.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors