# ilyesbelahsen/projet-chat architecture

> Architecture diagram of the GitHub repository ilyesbelahsen/projet-chat, 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/ilyesbelahsen/projet-chat
- Repository: https://github.com/ilyesbelahsen/projet-chat

## Overview

Cloud Chat is a real-time messaging product: users sign in, enter the general room or manage private rooms and members, then exchange messages over WebSocket. The React client calls separate NestJS identity and chat services; AWS can use a WebSocket Lambda with DynamoDB connection tracking, while local development has a WebSocket service. The README documents the service/database architecture and capabilities; sampled source confirms key auth, room, message, and WebSocket operations. Several frontend and infrastructure links are documented rather than verified in sampled implementation.

Main entry points: [`auth-service/src/auth/auth.service.ts`](https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/auth/auth.service.ts) (Auth workflows), [`frontend/src/App.tsx`](https://github.com/ilyesbelahsen/projet-chat/blob/main/frontend/src/App.tsx) (React application), [`frontend/src/services`](https://github.com/ilyesbelahsen/projet-chat/tree/main/frontend/src/services) (Chat API clients), [`chat-service/src/rooms/rooms.controller.ts`](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/rooms/rooms.controller.ts) (Room endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User application"]
  node_frontend["React application<br/>[App.tsx]"]
  node_auth_context["Auth context<br/>[AuthProvider.tsx]"]
  node_frontend_auth["Auth API client<br/>[authService.ts]"]
  node_room_pages["Room pages"]
  node_chat_api["Chat API clients"]
end

subgraph group_identity["Identity service"]
  node_auth_controller["Auth endpoints<br/>[auth.controller.ts]"]
  node_auth_logic["Auth workflows<br/>[auth.service.ts]"]
  node_users_api["User endpoints"]
  node_users_logic["User management<br/>[users.service.ts]"]
  node_email["Reset email<br/>[email.service.ts]"]
end

subgraph group_chat["Chat service"]
  node_rooms_api["Room endpoints"]
  node_rooms_logic["Room management<br/>[rooms.service.ts]"]
  node_messages_api["Message endpoints"]
  node_messages_logic["Message management"]
  node_auth_client["Remote auth client"]
end

subgraph group_realtime["Realtime delivery"]
  node_ws_internal["Internal WS handler"]
  node_local_ws["Local WS server<br/>[index.ts]"]
  node_lambda["AWS WS Lambda<br/>[handler.ts]"]
end

subgraph group_state["Application state"]
  node_connections[("Connection registry<br/>[dynamo.ts]")]
  node_auth_db[("Auth MySQL<br/>[database.module.ts]")]
  node_chat_db[("Chat MySQL<br/>[database.module.ts]")]
end

node_user(("User"))
node_ses["AWS SES"]

node_user -->|"uses"| node_frontend
node_frontend -->|"provides"| node_auth_context
node_frontend -->|"routes to"| node_room_pages
node_auth_context -->|"calls"| node_frontend_auth
node_frontend_auth -->|"sends auth requests"| node_auth_controller
node_room_pages -.->|"uses"| node_chat_api
node_chat_api -.->|"calls"| node_rooms_api
node_chat_api -.->|"calls"| node_messages_api
node_auth_controller -->|"delegates to"| node_auth_logic
node_auth_logic -->|"looks up users"| node_users_logic
node_users_api -->|"delegates to"| node_users_logic
node_auth_logic -->|"sends reset email"| node_email
node_auth_logic -.->|"stores tokens"| node_auth_db
node_users_logic -.->|"stores users"| node_auth_db
node_rooms_api -->|"delegates to"| node_rooms_logic
node_rooms_api -->|"looks up invitee"| node_auth_client
node_messages_api -->|"delegates to"| node_messages_logic
node_rooms_logic -.->|"stores rooms and members"| node_chat_db
node_messages_logic -.->|"stores messages"| node_chat_db
node_auth_client -->|"introspects token"| node_auth_controller
node_ws_internal -->|"validates connection"| node_auth_client
node_ws_internal -->|"checks membership and saves"| node_chat_db
node_user -.->|"connects locally"| node_local_ws
node_user -.->|"connects on AWS"| node_lambda
node_lambda -->|"tracks connections"| node_connections
node_lambda -.->|"posts messages"| node_ws_internal
node_email -.->|"sends email"| node_ses

click node_frontend "https://github.com/ilyesbelahsen/projet-chat/blob/main/frontend/src/App.tsx"
click node_auth_context "https://github.com/ilyesbelahsen/projet-chat/blob/main/frontend/src/context/AuthProvider.tsx"
click node_frontend_auth "https://github.com/ilyesbelahsen/projet-chat/blob/main/frontend/src/services/authService.ts"
click node_room_pages "https://github.com/ilyesbelahsen/projet-chat/tree/main/frontend/src/pages"
click node_chat_api "https://github.com/ilyesbelahsen/projet-chat/tree/main/frontend/src/services"
click node_auth_controller "https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/auth/auth.controller.ts"
click node_auth_logic "https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/auth/auth.service.ts"
click node_users_api "https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/users/users.controller.ts"
click node_users_logic "https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/users/users.service.ts"
click node_email "https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/email/email.service.ts"
click node_rooms_api "https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/rooms/rooms.controller.ts"
click node_rooms_logic "https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/rooms/rooms.service.ts"
click node_messages_api "https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/messages/messages.controller.ts"
click node_messages_logic "https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/messages/messages.service.ts"
click node_auth_client "https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/auth-client/auth-client.service.ts"
click node_ws_internal "https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/ws-internal/ws-internal.controller.ts"
click node_local_ws "https://github.com/ilyesbelahsen/projet-chat/blob/main/ws-local-service/src/index.ts"
click node_lambda "https://github.com/ilyesbelahsen/projet-chat/blob/main/tf-chat-ecs/lambda/src/handler.ts"
click node_connections "https://github.com/ilyesbelahsen/projet-chat/blob/main/tf-chat-ecs/lambda/src/dynamo.ts"
click node_auth_db "https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/database/database.module.ts"
click node_chat_db "https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/database/database.module.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_frontend,node_auth_context,node_frontend_auth,node_room_pages,node_chat_api,node_user toneBlue
class node_auth_controller,node_auth_logic,node_users_api,node_users_logic,node_email toneAmber
class node_rooms_api,node_rooms_logic,node_messages_api,node_messages_logic,node_auth_client toneMint
class node_ws_internal,node_local_ws,node_lambda toneRose
class node_connections,node_auth_db,node_chat_db,node_ses toneIndigo
```

## Components

### User application

- [React application](https://github.com/ilyesbelahsen/projet-chat/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth context](https://github.com/ilyesbelahsen/projet-chat/blob/main/frontend/src/context/AuthProvider.tsx): `frontend/src/context/AuthProvider.tsx`
- [Auth API client](https://github.com/ilyesbelahsen/projet-chat/blob/main/frontend/src/services/authService.ts): `frontend/src/services/authService.ts`
- [Room pages](https://github.com/ilyesbelahsen/projet-chat/tree/main/frontend/src/pages): `frontend/src/pages`
- [Chat API clients](https://github.com/ilyesbelahsen/projet-chat/tree/main/frontend/src/services): `frontend/src/services`

### Identity service

- [Auth endpoints](https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/auth/auth.controller.ts): `auth-service/src/auth/auth.controller.ts`
- [Auth workflows](https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/auth/auth.service.ts): `auth-service/src/auth/auth.service.ts`
- [User endpoints](https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/users/users.controller.ts): `auth-service/src/users/users.controller.ts`
- [User management](https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/users/users.service.ts): `auth-service/src/users/users.service.ts`
- [Reset email](https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/email/email.service.ts): `auth-service/src/email/email.service.ts`

### Chat service

- [Room endpoints](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/rooms/rooms.controller.ts): `chat-service/src/rooms/rooms.controller.ts`
- [Room management](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/rooms/rooms.service.ts): `chat-service/src/rooms/rooms.service.ts`
- [Message endpoints](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/messages/messages.controller.ts): `chat-service/src/messages/messages.controller.ts`
- [Message management](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/messages/messages.service.ts): `chat-service/src/messages/messages.service.ts`
- [Remote auth client](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/auth-client/auth-client.service.ts): `chat-service/src/auth-client/auth-client.service.ts`

### Realtime delivery

- [Internal WS handler](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/ws-internal/ws-internal.controller.ts): `chat-service/src/ws-internal/ws-internal.controller.ts`
- [Local WS server](https://github.com/ilyesbelahsen/projet-chat/blob/main/ws-local-service/src/index.ts): `ws-local-service/src/index.ts`
- [AWS WS Lambda](https://github.com/ilyesbelahsen/projet-chat/blob/main/tf-chat-ecs/lambda/src/handler.ts): `tf-chat-ecs/lambda/src/handler.ts`

### Application state

- [Connection registry](https://github.com/ilyesbelahsen/projet-chat/blob/main/tf-chat-ecs/lambda/src/dynamo.ts): `tf-chat-ecs/lambda/src/dynamo.ts`
- [Auth MySQL](https://github.com/ilyesbelahsen/projet-chat/blob/main/auth-service/src/database/database.module.ts): `auth-service/src/database/database.module.ts`
- [Chat MySQL](https://github.com/ilyesbelahsen/projet-chat/blob/main/chat-service/src/database/database.module.ts): `chat-service/src/database/database.module.ts`

### Other components

- **User**
- **AWS SES**

## Connections

- User → React application: uses (evidence: `README.md`)
- React application → Auth context: provides (evidence: `frontend/src/App.tsx`)
- React application → Room pages: routes to (evidence: `frontend/src/App.tsx`)
- Auth context → Auth API client: calls (evidence: `frontend/src/context/AuthProvider.tsx`)
- Auth API client → Auth endpoints: sends auth requests (evidence: `frontend/src/services/authService.ts`)
- Room pages → Chat API clients: uses
- Chat API clients → Room endpoints: calls (evidence: `README.md`)
- Chat API clients → Message endpoints: calls (evidence: `README.md`)
- Auth endpoints → Auth workflows: delegates to (evidence: `auth-service/src/auth/auth.controller.ts`)
- Auth workflows → User management: looks up users (evidence: `auth-service/src/auth/auth.service.ts`)
- User endpoints → User management: delegates to (evidence: `auth-service/src/users/users.controller.ts`)
- Auth workflows → Reset email: sends reset email (evidence: `auth-service/src/auth/auth.service.ts`)
- Auth workflows → Auth MySQL: stores tokens (evidence: `README.md`)
- User management → Auth MySQL: stores users (evidence: `README.md`)
- Room endpoints → Room management: delegates to (evidence: `chat-service/src/rooms/rooms.controller.ts`)
- Room endpoints → Remote auth client: looks up invitee (evidence: `chat-service/src/rooms/rooms.controller.ts`)
- Message endpoints → Message management: delegates to (evidence: `chat-service/src/messages/messages.controller.ts`)
- Room management → Chat MySQL: stores rooms and members (evidence: `README.md`)
- Message management → Chat MySQL: stores messages (evidence: `README.md`)
- Remote auth client → Auth endpoints: introspects token (evidence: `chat-service/src/auth-client/auth-client.service.ts`)
- Internal WS handler → Remote auth client: validates connection (evidence: `chat-service/src/ws-internal/ws-internal.controller.ts`)
- Internal WS handler → Chat MySQL: checks membership and saves (evidence: `chat-service/src/ws-internal/ws-internal.controller.ts`)
- User → Local WS server: connects locally (evidence: `README.md`)
- User → AWS WS Lambda: connects on AWS (evidence: `README.md`)
- AWS WS Lambda → Connection registry: tracks connections
- AWS WS Lambda → Internal WS handler: posts messages (evidence: `README.md`)
- Reset email → AWS SES: sends email (evidence: `README.md`)
