# younesmoukhlij/ft_transcendence_42 architecture

> Architecture diagram of the GitHub repository younesmoukhlij/ft_transcendence_42, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/younesmoukhlij/ft_transcendence_42
- Repository: https://github.com/younesmoukhlij/ft_transcendence_42

## Overview

ft_transcendence is a real-time ping-pong web platform with authentication, social play, tournaments, and player progression. Users sign in, choose local, AI, or remote play, and can join tournaments; results and activity support profiles, leaderboards, and leagues. The backend exposes API routes and WebSocket handling around game sessions and social updates. The README documents broader product capabilities than the sampled code; connections for those areas are shown only where documented, and unsampled implementation details are not inferred.

Main entry points: [`backend/routes/routes.js`](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/routes/routes.js) (API routes), [`backend/server.js`](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/server.js) (Application server), [`backend/modules/websocketHandler.js`](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/websocketHandler.js) (WebSocket handler), [`frontend/src/app`](https://github.com/younesmoukhlij/ft_transcendence_42/tree/main/frontend/src/app) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["Web application"]
end

subgraph group_backend["Backend runtime"]
  node_api["API routes<br/>[routes.js]"]
  node_server["Application server<br/>[server.js]"]
  node_auth["Authentication<br/>[userAuth.module.js]"]
  node_user["User accounts<br/>[user.module.js]"]
  node_profiles["Profiles<br/>[profile.module.js]"]
  node_ws["WebSocket handler"]
end

subgraph group_play["Games and tournaments"]
  node_game_ui["Game modes"]
  node_local_tourney["Local tournament<br/>[page.tsx]"]
  node_local_manager["Bracket manager"]
  node_game_context["Game context<br/>[GameContext.tsx]"]
  node_game_service["Game service<br/>[game.module.js]"]
  node_game_manager["Game manager<br/>[gameManager.js]"]
  node_game_ws["Game messages"]
  node_bracket["Tournament results<br/>[bracket.js]"]
  node_blockchain["Blockchain records<br/>[blockchain.js]"]
end

subgraph group_social["Social features"]
  node_notifications["Friends and notifications"]
  node_chat["Chat and presence"]
  node_status["Status sharing<br/>[statusHandler.js]"]
end

subgraph group_progress["Player progression"]
  node_history["Match history"]
  node_leagues["Leagues<br/>[leagues.module.js]"]
  node_progress_service["Player progress<br/>[playerProgress.js]"]
  node_leaderboard["Leaderboard<br/>[page.tsx]"]
end

node_player(("Player"))

node_player -->|"uses"| node_webapp
node_webapp -->|"requests"| node_api
node_player -->|"chooses mode"| node_game_ui
node_game_ui -.->|"plays through"| node_game_service
node_local_tourney -->|"manages bracket"| node_local_manager
node_local_manager -->|"uses types"| node_game_context
node_server -->|"registers"| node_api
node_api -->|"routes auth"| node_auth
node_api -->|"routes account"| node_user
node_api -->|"routes profiles"| node_profiles
node_api -->|"routes games"| node_game_service
node_api -->|"routes results"| node_bracket
node_api -->|"routes social"| node_notifications
node_api -->|"routes history"| node_history
node_api -->|"routes leagues"| node_leagues
node_api -->|"routes progress"| node_progress_service
node_server -->|"initializes"| node_game_manager
node_server -->|"configures"| node_ws
node_ws -->|"dispatches game messages"| node_game_ws
node_ws -->|"updates status"| node_status
node_bracket -->|"uses contract config"| node_blockchain
node_player -->|"signs in"| node_auth
node_player -->|"enters tournament"| node_local_tourney
node_player -->|"chats"| node_chat
node_player -->|"views progress"| node_leaderboard

click node_webapp "https://github.com/younesmoukhlij/ft_transcendence_42/tree/main/frontend/src/app"
click node_game_ui "https://github.com/younesmoukhlij/ft_transcendence_42/tree/main/frontend/src/app/(protected)/game"
click node_local_tourney "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/app/(protected)/game/local-tournament/page.tsx"
click node_local_manager "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/components/LocalTournamentManager.ts"
click node_game_context "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/components/GameContext.tsx"
click node_api "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/routes/routes.js"
click node_server "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/server.js"
click node_auth "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/userAuth.module.js"
click node_user "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/user.module.js"
click node_profiles "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/profile.module.js"
click node_game_service "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/game.module.js"
click node_game_manager "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/gameManager.js"
click node_game_ws "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/gameWebSocketHandler.js"
click node_ws "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/websocketHandler.js"
click node_bracket "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/bracket.js"
click node_blockchain "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/config/blockchain.js"
click node_notifications "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/nofitication.moudle.js"
click node_chat "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/websocketHandler.js"
click node_status "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/statusHandler.js"
click node_history "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/matchHistory.module.js"
click node_leagues "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/leagues.module.js"
click node_progress_service "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/playerProgress.js"
click node_leaderboard "https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/app/(protected)/leaderboard/page.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp toneBlue
class node_api,node_server,node_auth,node_user,node_profiles,node_ws toneAmber
class node_game_ui,node_local_tourney,node_local_manager,node_game_context,node_game_service,node_game_manager,node_game_ws,node_bracket,node_blockchain toneMint
class node_notifications,node_chat,node_status toneRose
class node_history,node_leagues,node_progress_service,node_leaderboard,node_player toneIndigo
```

## Components

### Web client

- [Web application](https://github.com/younesmoukhlij/ft_transcendence_42/tree/main/frontend/src/app): `frontend/src/app`

### Backend runtime

- [API routes](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/routes/routes.js): `backend/routes/routes.js`
- [Application server](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/userAuth.module.js): `backend/modules/userAuth.module.js`
- [User accounts](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/user.module.js): `backend/modules/user.module.js`
- [Profiles](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/profile.module.js): `backend/modules/profile.module.js`
- [WebSocket handler](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/websocketHandler.js): `backend/modules/websocketHandler.js`

### Games and tournaments

- [Game modes](https://github.com/younesmoukhlij/ft_transcendence_42/tree/main/frontend/src/app/(protected)/game): `frontend/src/app/(protected)/game`
- [Local tournament](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/app/(protected)/game/local-tournament/page.tsx): `frontend/src/app/(protected)/game/local-tournament/page.tsx`
- [Bracket manager](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/components/LocalTournamentManager.ts): `frontend/src/components/LocalTournamentManager.ts`
- [Game context](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/components/GameContext.tsx): `frontend/src/components/GameContext.tsx`
- [Game service](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/game.module.js): `backend/modules/game.module.js`
- [Game manager](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/gameManager.js): `backend/modules/gameManager.js`
- [Game messages](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/gameWebSocketHandler.js): `backend/modules/gameWebSocketHandler.js`
- [Tournament results](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/bracket.js): `backend/modules/bracket.js`
- [Blockchain records](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/config/blockchain.js): `backend/config/blockchain.js`

### Social features

- [Friends and notifications](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/nofitication.moudle.js): `backend/modules/nofitication.moudle.js`
- [Chat and presence](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/websocketHandler.js): `backend/modules/websocketHandler.js`
- [Status sharing](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/statusHandler.js): `backend/modules/statusHandler.js`

### Player progression

- [Match history](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/matchHistory.module.js): `backend/modules/matchHistory.module.js`
- [Leagues](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/leagues.module.js): `backend/modules/leagues.module.js`
- [Player progress](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/backend/modules/playerProgress.js): `backend/modules/playerProgress.js`
- [Leaderboard](https://github.com/younesmoukhlij/ft_transcendence_42/blob/main/frontend/src/app/(protected)/leaderboard/page.tsx): `frontend/src/app/(protected)/leaderboard/page.tsx`

### Other components

- **Player**

## Connections

- Player → Web application: uses
- Web application → API routes: requests
- Player → Game modes: chooses mode
- Game modes → Game service: plays through
- Local tournament → Bracket manager: manages bracket (evidence: `frontend/src/components/LocalTournamentManager.ts`)
- Bracket manager → Game context: uses types (evidence: `frontend/src/components/LocalTournamentManager.ts`)
- Application server → API routes: registers (evidence: `backend/server.js`)
- API routes → Authentication: routes auth (evidence: `backend/routes/routes.js`)
- API routes → User accounts: routes account (evidence: `backend/routes/routes.js`)
- API routes → Profiles: routes profiles (evidence: `backend/routes/routes.js`)
- API routes → Game service: routes games (evidence: `backend/routes/routes.js`)
- API routes → Tournament results: routes results (evidence: `backend/routes/routes.js`)
- API routes → Friends and notifications: routes social (evidence: `backend/routes/routes.js`)
- API routes → Match history: routes history (evidence: `backend/routes/routes.js`)
- API routes → Leagues: routes leagues (evidence: `backend/routes/routes.js`)
- API routes → Player progress: routes progress (evidence: `backend/routes/routes.js`)
- Application server → Game manager: initializes (evidence: `backend/server.js`)
- Application server → WebSocket handler: configures (evidence: `backend/server.js`)
- WebSocket handler → Game messages: dispatches game messages (evidence: `backend/modules/websocketHandler.js`)
- WebSocket handler → Status sharing: updates status (evidence: `backend/modules/websocketHandler.js`)
- Tournament results → Blockchain records: uses contract config (evidence: `backend/modules/bracket.js`)
- Player → Authentication: signs in
- Player → Local tournament: enters tournament
- Player → Chat and presence: chats
- Player → Leaderboard: views progress
