# bedelo/ft_transcendence architecture

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

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

## Overview

ft_transcendence is a multiplayer Tic-Tac-Toe web application: users authenticate, find or create a room, play live 1v1 or 1v1v1 matches, and review profile progression and statistics. The React client also supports chat and social interaction, while the Fastify backend handles authenticated API and WebSocket traffic and persists application state through Prisma. The README documents further admin, GDPR, multilingual, and accessibility capabilities. Some route and UI implementations were not sampled, so links for those features reflect documented capabilities and registered modules, not inspected call chains.

Main entry points: [`apps/backend/src/main.ts`](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/main.ts) (Fastify server), [`apps/backend/src/db/prisma.ts`](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/db/prisma.ts) (Prisma data access), [`apps/frontend/src/router.tsx`](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/router.tsx) (Routes and pages), [`apps/frontend/src/hooks/useGameRoom.ts`](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/hooks/useGameRoom.ts) (Game room connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_spa["React application<br/>[main.tsx]"]
  node_router["Routes and pages<br/>[router.tsx]"]
  node_game_ui["Game lobby and match UI<br/>[GameLobbyPage.tsx]"]
  node_game_hook["Game room connection<br/>[useGameRoom.ts]"]
  node_chat_hook["Chat connection<br/>[useChat.ts]"]
  node_api["HTTP API client<br/>[api.ts]"]
end

subgraph group_identity["Identity and profiles"]
  node_auth_ui["Authentication UI<br/>[index.ts]"]
  node_auth_routes["Authentication routes<br/>[auth.ts]"]
  node_profile_routes["Profile and avatar routes<br/>[profile.ts]"]
  node_friends_routes["Friends routes<br/>[friends.ts]"]
end

subgraph group_realtime["Live play and chat"]
  node_chat_routes["Chat WebSocket and history<br/>[chat.ts]"]
  node_game_routes["Game room routes<br/>[game.ts]"]
  node_game_manager["Room manager<br/>[GameManager.ts]"]
  node_game_room["Room and match state<br/>[GameRoom.ts]"]
  node_game_engine["Game rules<br/>[GameEngine.ts]"]
end

subgraph group_insights["Progress and administration"]
  node_stats_routes["Statistics routes<br/>[stats.ts]"]
  node_achievements["Achievement service<br/>[achievements.ts]"]
  node_admin_routes["Admin routes<br/>[index.ts]"]
  node_gdpr_routes["GDPR routes<br/>[gdpr.ts]"]
end

subgraph group_data["Contracts and persistence"]
  node_server["Fastify server<br/>[main.ts]"]
  node_contracts["Shared schemas and types<br/>[index.ts]"]
  node_prisma["Prisma data access<br/>[prisma.ts]"]
  node_database[("Relational database")]
end

node_player(("Player"))

node_player -->|"uses"| node_spa
node_spa -->|"renders"| node_router
node_router -->|"routes to"| node_game_ui
node_router -->|"routes to"| node_auth_ui
node_game_ui -->|"connects with"| node_game_hook
node_game_hook -->|"WebSocket messages"| node_game_routes
node_chat_hook -->|"history and messages"| node_chat_routes
node_auth_ui -->|"submits requests"| node_api
node_api -->|"HTTP requests"| node_server
node_server -->|"registers"| node_auth_routes
node_server -->|"registers"| node_profile_routes
node_server -->|"registers"| node_friends_routes
node_server -->|"registers"| node_chat_routes
node_server -->|"registers"| node_game_routes
node_server -->|"registers"| node_stats_routes
node_server -->|"registers"| node_admin_routes
node_server -->|"registers"| node_gdpr_routes
node_game_routes -->|"manages rooms"| node_game_manager
node_game_manager -->|"creates and joins"| node_game_room
node_game_room -->|"applies rules"| node_game_engine
node_game_manager -->|"persists games"| node_prisma
node_prisma -->|"reads and writes"| node_database
node_auth_routes -->|"session and user data"| node_prisma
node_profile_routes -->|"profile data"| node_prisma
node_friends_routes -->|"social data"| node_prisma
node_chat_routes -->|"message history"| node_prisma
node_stats_routes -->|"statistics data"| node_prisma
node_admin_routes -->|"management data"| node_prisma
node_gdpr_routes -->|"export and deletion data"| node_prisma
node_server -->|"validates API contracts"| node_contracts
node_game_hook -->|"uses game types"| node_contracts
node_achievements -->|"progress data"| node_prisma

click node_spa "https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/main.tsx"
click node_router "https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/router.tsx"
click node_game_ui "https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/pages/GameLobbyPage.tsx"
click node_game_hook "https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/hooks/useGameRoom.ts"
click node_chat_hook "https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/hooks/useChat.ts"
click node_api "https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/lib/api.ts"
click node_auth_ui "https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/components/auth/index.ts"
click node_auth_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/auth.ts"
click node_profile_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/profile.ts"
click node_friends_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/friends.ts"
click node_chat_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/chat.ts"
click node_game_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/game.ts"
click node_game_manager "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/game/GameManager.ts"
click node_game_room "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/game/GameRoom.ts"
click node_game_engine "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/game/GameEngine.ts"
click node_stats_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/stats.ts"
click node_achievements "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/achievements.ts"
click node_admin_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/admin/index.ts"
click node_gdpr_routes "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/gdpr.ts"
click node_server "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/main.ts"
click node_contracts "https://github.com/bedelo/ft_transcendence/blob/main/packages/shared-types/src/index.ts"
click node_prisma "https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/db/prisma.ts"

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_spa,node_router,node_game_ui,node_game_hook,node_chat_hook,node_api toneBlue
class node_auth_ui,node_auth_routes,node_profile_routes,node_friends_routes toneAmber
class node_chat_routes,node_game_routes,node_game_manager,node_game_room,node_game_engine toneMint
class node_stats_routes,node_achievements,node_admin_routes,node_gdpr_routes toneRose
class node_server,node_contracts,node_prisma,node_database,node_player toneIndigo
```

## Components

### Web client

- [React application](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/main.tsx): `apps/frontend/src/main.tsx`
- [Routes and pages](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/router.tsx): `apps/frontend/src/router.tsx`
- [Game lobby and match UI](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/pages/GameLobbyPage.tsx): `apps/frontend/src/pages/GameLobbyPage.tsx`
- [Game room connection](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/hooks/useGameRoom.ts): `apps/frontend/src/hooks/useGameRoom.ts`
- [Chat connection](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/hooks/useChat.ts): `apps/frontend/src/hooks/useChat.ts`
- [HTTP API client](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/lib/api.ts): `apps/frontend/src/lib/api.ts`

### Identity and profiles

- [Authentication UI](https://github.com/bedelo/ft_transcendence/blob/main/apps/frontend/src/components/auth/index.ts): `apps/frontend/src/components/auth/index.ts`
- [Authentication routes](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/auth.ts): `apps/backend/src/routes/auth.ts`
- [Profile and avatar routes](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/profile.ts): `apps/backend/src/routes/profile.ts`
- [Friends routes](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/friends.ts): `apps/backend/src/routes/friends.ts`

### Live play and chat

- [Chat WebSocket and history](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/chat.ts): `apps/backend/src/routes/chat.ts`
- [Game room routes](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/game.ts): `apps/backend/src/routes/game.ts`
- [Room manager](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/game/GameManager.ts): `apps/backend/src/services/game/GameManager.ts`
- [Room and match state](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/game/GameRoom.ts): `apps/backend/src/services/game/GameRoom.ts`
- [Game rules](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/game/GameEngine.ts): `apps/backend/src/services/game/GameEngine.ts`

### Progress and administration

- [Statistics routes](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/stats.ts): `apps/backend/src/routes/stats.ts`
- [Achievement service](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/services/achievements.ts): `apps/backend/src/services/achievements.ts`
- [Admin routes](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/admin/index.ts): `apps/backend/src/routes/admin/index.ts`
- [GDPR routes](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/routes/gdpr.ts): `apps/backend/src/routes/gdpr.ts`

### Contracts and persistence

- [Fastify server](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/main.ts): `apps/backend/src/main.ts`
- [Shared schemas and types](https://github.com/bedelo/ft_transcendence/blob/main/packages/shared-types/src/index.ts): `packages/shared-types/src/index.ts`
- [Prisma data access](https://github.com/bedelo/ft_transcendence/blob/main/apps/backend/src/db/prisma.ts): `apps/backend/src/db/prisma.ts`
- **Relational database**

### Other components

- **Player**

## Connections

- Player → React application: uses
- React application → Routes and pages: renders
- Routes and pages → Game lobby and match UI: routes to
- Routes and pages → Authentication UI: routes to
- Game lobby and match UI → Game room connection: connects with
- Game room connection → Game room routes: WebSocket messages
- Chat connection → Chat WebSocket and history: history and messages
- Authentication UI → HTTP API client: submits requests
- HTTP API client → Fastify server: HTTP requests
- Fastify server → Authentication routes: registers
- Fastify server → Profile and avatar routes: registers
- Fastify server → Friends routes: registers
- Fastify server → Chat WebSocket and history: registers
- Fastify server → Game room routes: registers
- Fastify server → Statistics routes: registers
- Fastify server → Admin routes: registers
- Fastify server → GDPR routes: registers
- Game room routes → Room manager: manages rooms
- Room manager → Room and match state: creates and joins
- Room and match state → Game rules: applies rules
- Room manager → Prisma data access: persists games
- Prisma data access → Relational database: reads and writes
- Authentication routes → Prisma data access: session and user data
- Profile and avatar routes → Prisma data access: profile data
- Friends routes → Prisma data access: social data
- Chat WebSocket and history → Prisma data access: message history
- Statistics routes → Prisma data access: statistics data
- Admin routes → Prisma data access: management data
- GDPR routes → Prisma data access: export and deletion data
- Fastify server → Shared schemas and types: validates API contracts
- Game room connection → Shared schemas and types: uses game types
- Achievement service → Prisma data access: progress data
