# dardo95/ft_transcendence architecture

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

- Interactive diagram: https://gitdiagram.com/dardo95/ft_transcendence
- Repository: https://github.com/dardo95/ft_transcendence

## Overview

This is a browser-based multiplayer Bomberman game with account, social, lobby, matchmaking, real-time play, and match-history features. The main workflow is browser authentication, lobby matchmaking, server session creation and simulation, then socket-delivered snapshots rendered by the client. The diagram also includes chat, friends, profiles, and statistics as separate product capabilities. Edges are limited to relationships supported by excerpts, SOURCE INDEX references, or the README; unsampled feature wiring is not inferred.

Main entry points: [`frontend/src/App.tsx`](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/App.tsx) (App routing), [`backend/src/game/matchmaking/matchmaking.service.ts`](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/matchmaking/matchmaking.service.ts) (Matchmaking), [`backend/src/game/sessions/game-manager.service.ts`](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/sessions/game-manager.service.ts) (Game manager), [`backend/src/users/users.controller.ts`](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/users/users.controller.ts) (User endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_webapp["App routing<br/>[App.tsx]"]
  node_authstate["Auth state<br/>[useAuthStore.ts]"]
  node_authclient["Auth API service<br/>[authService.ts]"]
  node_api["HTTP client<br/>[api.ts]"]
  node_lobbypage["Lobby UI<br/>[LobbyPage.tsx]"]
  node_gamepage["Game UI<br/>[GamePage.tsx]"]
  node_clientengine["Client game engine<br/>[GameEngine.ts]"]
  node_gameconnection["Game connection<br/>[gameConnection.ts]"]
  node_gamescene["Pixi game scene<br/>[GameScene.ts]"]
  node_historyui["Profile and history<br/>[StatsPage.tsx]"]
end

subgraph group_identity["Identity and social"]
  node_authcontroller["Auth endpoints<br/>[auth.controller.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
  node_users["User endpoints"]
  node_userprofiles["User services<br/>[users.service.ts]"]
  node_friendships["Friendships"]
  node_stats["Match statistics<br/>[stats.service.ts]"]
end

subgraph group_play["Match lifecycle"]
  node_lobbyservice["Lobby service<br/>[lobby.service.ts]"]
  node_matchmaking["Matchmaking"]
  node_manager["Game manager"]
  node_sessionfactory["Session factory"]
  node_mapregistry["Map registry"]
  node_gamestate["Game state<br/>[game-state.ts]"]
  node_gameengine["Server simulation<br/>[game-engine.ts]"]
end

subgraph group_realtime["Realtime services"]
  node_chat["Global chat<br/>[chat.gateway.ts]"]
  node_gamegateway["Game gateway<br/>[game.gateway.ts]"]
  node_socketauth["Socket authentication"]
  node_socketregistry["Socket registry"]
end

subgraph group_persistence["Persistence"]
  node_database[("Relational database<br/>[prisma.service.ts]")]
end

node_player(("Player"))

node_player -->|"uses"| node_webapp
node_webapp -->|"checks session"| node_authstate
node_authstate -->|"requests auth"| node_authclient
node_authclient -->|"sends HTTP"| node_api
node_api -.->|"calls endpoints"| node_authcontroller
node_authcontroller -->|"delegates auth"| node_authservice
node_authservice -->|"reads and writes"| node_database
node_webapp -->|"routes to"| node_lobbypage
node_lobbypage -.->|"requests match"| node_matchmaking
node_matchmaking -->|"uses lobby"| node_lobbyservice
node_matchmaking -->|"creates sessions"| node_manager
node_manager -->|"builds sessions"| node_sessionfactory
node_sessionfactory -->|"loads maps"| node_mapregistry
node_sessionfactory -->|"initializes state"| node_gamestate
node_manager -->|"ticks sessions"| node_gameengine
node_webapp -->|"routes to"| node_gamepage
node_gamepage -.->|"starts rendering"| node_clientengine
node_clientengine -->|"handles protocol"| node_gameconnection
node_clientengine -->|"renders scene"| node_gamescene
node_gamegateway -->|"authenticates sockets"| node_socketauth
node_chat -->|"authenticates sockets"| node_socketauth
node_users -->|"delegates user work"| node_userprofiles
node_users -->|"delegates friend work"| node_friendships
node_users -->|"emits user events"| node_chat
node_userprofiles -->|"reads and writes"| node_database
node_stats -->|"queries history"| node_database
node_historyui -.->|"requests history"| node_api
node_manager -->|"uses map registry"| node_mapregistry
node_matchmaking -->|"authenticates players"| node_socketauth
node_userprofiles -->|"updates connections"| node_socketregistry

click node_webapp "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/App.tsx"
click node_authstate "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/auth/store/useAuthStore.ts"
click node_authclient "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/auth/service/authService.ts"
click node_api "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/api/api.ts"
click node_lobbypage "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/pages/LobbyPage.tsx"
click node_gamepage "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/pages/GamePage.tsx"
click node_clientengine "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/game/engine/GameEngine.ts"
click node_gameconnection "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/game/net/gameConnection.ts"
click node_gamescene "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/game/pixi/GameScene.ts"
click node_authcontroller "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/auth/auth.controller.ts"
click node_authservice "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/auth/auth.service.ts"
click node_users "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/users/users.controller.ts"
click node_userprofiles "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/users/users.service.ts"
click node_friendships "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/users/friendships.service.ts"
click node_chat "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/chat/chat.gateway.ts"
click node_lobbyservice "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/lobby/lobby.service.ts"
click node_matchmaking "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/matchmaking/matchmaking.service.ts"
click node_manager "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/sessions/game-manager.service.ts"
click node_sessionfactory "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/engine/game-session.factory.ts"
click node_mapregistry "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/maps/map-registry.service.ts"
click node_gamestate "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/engine/game-state.ts"
click node_gameengine "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/engine/game-engine.ts"
click node_gamegateway "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/game.gateway.ts"
click node_socketauth "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/auth/ws-jwt-auth.service.ts"
click node_socketregistry "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/realtime/socket-registry.service.ts"
click node_stats "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/stats/stats.service.ts"
click node_database "https://github.com/dardo95/ft_transcendence/blob/main/backend/src/database/prisma.service.ts"
click node_historyui "https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/pages/StatsPage.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,node_authstate,node_authclient,node_api,node_lobbypage,node_gamepage,node_clientengine,node_gameconnection,node_gamescene,node_historyui toneBlue
class node_authcontroller,node_authservice,node_users,node_userprofiles,node_friendships,node_stats toneAmber
class node_lobbyservice,node_matchmaking,node_manager,node_sessionfactory,node_mapregistry,node_gamestate,node_gameengine toneMint
class node_chat,node_gamegateway,node_socketauth,node_socketregistry toneRose
class node_database,node_player toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth state](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/auth/store/useAuthStore.ts): `frontend/src/features/auth/store/useAuthStore.ts`
- [Auth API service](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/auth/service/authService.ts): `frontend/src/features/auth/service/authService.ts`
- [HTTP client](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/api/api.ts): `frontend/src/api/api.ts`
- [Lobby UI](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/pages/LobbyPage.tsx): `frontend/src/pages/LobbyPage.tsx`
- [Game UI](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/pages/GamePage.tsx): `frontend/src/pages/GamePage.tsx`
- [Client game engine](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/game/engine/GameEngine.ts): `frontend/src/features/game/engine/GameEngine.ts`
- [Game connection](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/game/net/gameConnection.ts): `frontend/src/features/game/net/gameConnection.ts`
- [Pixi game scene](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/features/game/pixi/GameScene.ts): `frontend/src/features/game/pixi/GameScene.ts`
- [Profile and history](https://github.com/dardo95/ft_transcendence/blob/main/frontend/src/pages/StatsPage.tsx): `frontend/src/pages/StatsPage.tsx`

### Identity and social

- [Auth endpoints](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/auth/auth.controller.ts): `backend/src/auth/auth.controller.ts`
- [Auth service](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/auth/auth.service.ts): `backend/src/auth/auth.service.ts`
- [User endpoints](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/users/users.controller.ts): `backend/src/users/users.controller.ts`
- [User services](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/users/users.service.ts): `backend/src/users/users.service.ts`
- [Friendships](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/users/friendships.service.ts): `backend/src/users/friendships.service.ts`
- [Match statistics](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/stats/stats.service.ts): `backend/src/stats/stats.service.ts`

### Match lifecycle

- [Lobby service](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/lobby/lobby.service.ts): `backend/src/lobby/lobby.service.ts`
- [Matchmaking](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/matchmaking/matchmaking.service.ts): `backend/src/game/matchmaking/matchmaking.service.ts`
- [Game manager](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/sessions/game-manager.service.ts): `backend/src/game/sessions/game-manager.service.ts`
- [Session factory](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/engine/game-session.factory.ts): `backend/src/game/engine/game-session.factory.ts`
- [Map registry](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/maps/map-registry.service.ts): `backend/src/game/maps/map-registry.service.ts`
- [Game state](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/engine/game-state.ts): `backend/src/game/engine/game-state.ts`
- [Server simulation](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/engine/game-engine.ts): `backend/src/game/engine/game-engine.ts`

### Realtime services

- [Global chat](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/chat/chat.gateway.ts): `backend/src/chat/chat.gateway.ts`
- [Game gateway](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/game/game.gateway.ts): `backend/src/game/game.gateway.ts`
- [Socket authentication](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/auth/ws-jwt-auth.service.ts): `backend/src/auth/ws-jwt-auth.service.ts`
- [Socket registry](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/realtime/socket-registry.service.ts): `backend/src/realtime/socket-registry.service.ts`

### Persistence

- [Relational database](https://github.com/dardo95/ft_transcendence/blob/main/backend/src/database/prisma.service.ts): `backend/src/database/prisma.service.ts`

### Other components

- **Player**

## Connections

- Player → App routing: uses (evidence: `frontend/src/App.tsx`)
- App routing → Auth state: checks session (evidence: `frontend/src/App.tsx`)
- Auth state → Auth API service: requests auth (evidence: `frontend/src/features/auth/store/useAuthStore.ts`)
- Auth API service → HTTP client: sends HTTP (evidence: `frontend/src/features/auth/service/authService.ts`)
- HTTP client → Auth endpoints: calls endpoints
- Auth endpoints → Auth service: delegates auth (evidence: `backend/src/auth/auth.controller.ts`)
- Auth service → Relational database: reads and writes (evidence: `backend/src/auth/auth.service.ts`)
- App routing → Lobby UI: routes to (evidence: `frontend/src/App.tsx`)
- Lobby UI → Matchmaking: requests match
- Matchmaking → Lobby service: uses lobby (evidence: `backend/src/game/matchmaking/matchmaking.service.ts`)
- Matchmaking → Game manager: creates sessions (evidence: `backend/src/game/matchmaking/matchmaking.service.ts`)
- Game manager → Session factory: builds sessions (evidence: `backend/src/game/sessions/game-manager.service.ts`)
- Session factory → Map registry: loads maps (evidence: `backend/src/game/engine/game-session.factory.ts`)
- Session factory → Game state: initializes state (evidence: `backend/src/game/engine/game-session.factory.ts`)
- Game manager → Server simulation: ticks sessions (evidence: `backend/src/game/sessions/game-manager.service.ts`)
- App routing → Game UI: routes to (evidence: `frontend/src/App.tsx`)
- Game UI → Client game engine: starts rendering
- Client game engine → Game connection: handles protocol (evidence: `frontend/src/features/game/engine/GameEngine.ts`)
- Client game engine → Pixi game scene: renders scene (evidence: `frontend/src/features/game/engine/GameEngine.ts`)
- Game gateway → Socket authentication: authenticates sockets
- Global chat → Socket authentication: authenticates sockets (evidence: `backend/src/chat/chat.gateway.ts`)
- User endpoints → User services: delegates user work (evidence: `backend/src/users/users.controller.ts`)
- User endpoints → Friendships: delegates friend work (evidence: `backend/src/users/users.controller.ts`)
- User endpoints → Global chat: emits user events (evidence: `backend/src/users/users.controller.ts`)
- User services → Relational database: reads and writes (evidence: `backend/src/users/users.service.ts`)
- Match statistics → Relational database: queries history (evidence: `backend/src/stats/stats.service.ts`)
- Profile and history → HTTP client: requests history
- Game manager → Map registry: uses map registry (evidence: `backend/src/game/sessions/game-manager.service.ts`)
- Matchmaking → Socket authentication: authenticates players (evidence: `backend/src/game/matchmaking/matchmaking.service.ts`)
- User services → Socket registry: updates connections (evidence: `backend/src/users/users.service.ts`)
