# duc-hust-et1/lan_media architecture

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

- Interactive diagram: https://gitdiagram.com/duc-hust-et1/lan_media
- Repository: https://github.com/duc-hust-et1/lan_media

## Overview

LAN-Media is a LAN-priority multimedia messaging app: users register or log in, then chat in direct or group conversations, transfer files, and make voice/video calls. The graph separates frontend interaction, backend API and realtime handling, domain services, persistence, and LAN discovery. README capabilities are included where source excerpts are incomplete; dashed links mark documented or plausible integration points whose runtime wiring was not shown.

Main entry points: [`backend/src/main.ts`](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/main.ts) (HTTP entrypoint), [`frontend/src/App.tsx`](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/App.tsx) (App routing), [`backend/src/controllers/FileController.ts`](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/controllers/FileController.ts) (File controller), [`backend/src/repositories`](https://github.com/duc-hust-et1/lan_media/tree/main/backend/src/repositories) (Data repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_auth_ui["Auth UI<br/>[useAuth.ts]"]
  node_auth_api["Auth client<br/>[AuthApi.ts]"]
  node_chat_ui["Chat workspace<br/>[ChatPage.tsx]"]
  node_chat_api["Chat client<br/>[ChatApi.ts]"]
  node_file_ui["File UI<br/>[FileMessage.tsx]"]
  node_call_ui["Call interface<br/>[CallDialog.tsx]"]
  node_call_hook["WebRTC calls<br/>[useCall.ts]"]
  node_realtime_client["Realtime client<br/>[RealtimeClient.ts]"]
  node_network_ui["Network settings"]
end

subgraph group_api["Backend API"]
  node_backend["HTTP entrypoint<br/>[main.ts]"]
  node_auth_routes["Auth routes<br/>[AuthRoutes.ts]"]
  node_chat_routes["Chat routes<br/>[ChatRoutes.ts]"]
  node_file_routes["File routes<br/>[FileRoutes.ts]"]
  node_auth_controller["Auth controller<br/>[AuthController.ts]"]
  node_chat_controller["Chat controller<br/>[ChatController.ts]"]
  node_file_controller["File controller<br/>[FileController.ts]"]
end

subgraph group_realtime["Realtime and calls"]
  node_call_handler["Call signaling<br/>[CallHandler.ts]"]
  node_ws_server["WebSocket server<br/>[WebSocketServer.ts]"]
  node_connections["Connections"]
end

subgraph group_domain["Domain services"]
  node_auth_service["Authentication<br/>[AuthService.ts]"]
  node_chat_service["Conversations<br/>[ChatService.ts]"]
  node_file_service["File transfer<br/>[FileService.ts]"]
  node_call_service["Call lifecycle<br/>[CallService.ts]"]
end

subgraph group_storage["Persistence and files"]
  node_repositories["Data repositories"]
  node_database["Database access<br/>[Database.ts]"]
  node_mysql[("MySQL")]
  node_local_files[("Server file storage")]
end

subgraph group_lan["LAN discovery"]
  node_network_service["Network discovery"]
  node_network_status["Network status"]
  node_lan_discovery["LAN discovery<br/>[LanDiscovery.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"uses"| node_auth_ui
node_auth_ui -->|"calls"| node_auth_api
node_app -->|"renders"| node_chat_ui
node_chat_ui -->|"calls"| node_chat_api
node_chat_ui -->|"renders"| node_file_ui
node_app -->|"uses"| node_call_hook
node_app -->|"renders"| node_call_ui
node_call_ui -->|"uses"| node_call_hook
node_call_hook -->|"signals through"| node_realtime_client
node_app -->|"connects via"| node_realtime_client
node_user -->|"manages network"| node_network_ui
node_auth_api -.->|"HTTP requests"| node_backend
node_chat_api -.->|"HTTP requests"| node_backend
node_realtime_client -.->|"WebSocket events"| node_ws_server
node_backend -->|"registers"| node_auth_routes
node_backend -->|"registers"| node_chat_routes
node_backend -->|"registers"| node_file_routes
node_auth_routes -->|"routes to"| node_auth_controller
node_chat_routes -->|"routes to"| node_chat_controller
node_file_routes -->|"routes to"| node_file_controller
node_auth_controller -->|"calls"| node_auth_service
node_chat_controller -->|"calls"| node_chat_service
node_chat_controller -->|"dispatches messages"| node_connections
node_file_controller -->|"calls"| node_file_service
node_file_controller -->|"gets conversation"| node_chat_service
node_file_controller -->|"dispatches file message"| node_connections
node_auth_service -->|"uses"| node_repositories
node_chat_service -->|"uses"| node_repositories
node_file_service -->|"uses"| node_repositories
node_repositories -->|"queries"| node_database
node_database -->|"executes SQL"| node_mysql
node_file_controller -->|"streams downloads"| node_local_files
node_backend -->|"starts"| node_ws_server
node_ws_server -.->|"dispatches calls"| node_call_handler
node_call_handler -->|"calls"| node_call_service
node_call_handler -->|"sends events"| node_connections
node_backend -->|"starts"| node_network_service
node_network_service -.->|"uses"| node_lan_discovery
node_network_ui -.->|"configures discovery"| node_network_service

click node_app "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/App.tsx"
click node_auth_ui "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/hooks/useAuth.ts"
click node_auth_api "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/api/AuthApi.ts"
click node_chat_ui "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/pages/ChatPage/ChatPage.tsx"
click node_chat_api "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/api/ChatApi.ts"
click node_file_ui "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/components/chat/FileMessage.tsx"
click node_call_ui "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/components/call/CallDialog.tsx"
click node_call_hook "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/hooks/useCall.ts"
click node_realtime_client "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/api/RealtimeClient.ts"
click node_network_ui "https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/components/NetworkManagement.tsx"
click node_backend "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/main.ts"
click node_auth_routes "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/routes/AuthRoutes.ts"
click node_chat_routes "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/routes/ChatRoutes.ts"
click node_file_routes "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/routes/FileRoutes.ts"
click node_auth_controller "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/controllers/AuthController.ts"
click node_chat_controller "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/controllers/ChatController.ts"
click node_file_controller "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/controllers/FileController.ts"
click node_auth_service "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/AuthService.ts"
click node_chat_service "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/ChatService.ts"
click node_file_service "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/FileService.ts"
click node_call_handler "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/websocket/handlers/CallHandler.ts"
click node_ws_server "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/websocket/WebSocketServer.ts"
click node_connections "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/websocket/ConnectionManager.ts"
click node_call_service "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/CallService.ts"
click node_repositories "https://github.com/duc-hust-et1/lan_media/tree/main/backend/src/repositories"
click node_database "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/core/database/Database.ts"
click node_network_service "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/NetworkDiscoveryService.ts"
click node_network_status "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/NetworkStatusService.ts"
click node_lan_discovery "https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/core/network/LanDiscovery.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_app,node_auth_ui,node_auth_api,node_chat_ui,node_chat_api,node_file_ui,node_call_ui,node_call_hook,node_realtime_client,node_network_ui,node_user toneBlue
class node_backend,node_auth_routes,node_chat_routes,node_file_routes,node_auth_controller,node_chat_controller,node_file_controller toneAmber
class node_call_handler,node_ws_server,node_connections toneMint
class node_auth_service,node_chat_service,node_file_service,node_call_service toneRose
class node_repositories,node_database,node_mysql,node_local_files toneIndigo
class node_network_service,node_network_status,node_lan_discovery toneTeal
```

## Components

### Frontend experience

- [App routing](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth UI](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/hooks/useAuth.ts): `frontend/src/hooks/useAuth.ts`
- [Auth client](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/api/AuthApi.ts): `frontend/src/api/AuthApi.ts`
- [Chat workspace](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/pages/ChatPage/ChatPage.tsx): `frontend/src/pages/ChatPage/ChatPage.tsx`
- [Chat client](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/api/ChatApi.ts): `frontend/src/api/ChatApi.ts`
- [File UI](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/components/chat/FileMessage.tsx): `frontend/src/components/chat/FileMessage.tsx`
- [Call interface](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/components/call/CallDialog.tsx): `frontend/src/components/call/CallDialog.tsx`
- [WebRTC calls](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/hooks/useCall.ts): `frontend/src/hooks/useCall.ts`
- [Realtime client](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/api/RealtimeClient.ts): `frontend/src/api/RealtimeClient.ts`
- [Network settings](https://github.com/duc-hust-et1/lan_media/blob/main/frontend/src/components/NetworkManagement.tsx): `frontend/src/components/NetworkManagement.tsx`

### Backend API

- [HTTP entrypoint](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/main.ts): `backend/src/main.ts`
- [Auth routes](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/routes/AuthRoutes.ts): `backend/src/routes/AuthRoutes.ts`
- [Chat routes](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/routes/ChatRoutes.ts): `backend/src/routes/ChatRoutes.ts`
- [File routes](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/routes/FileRoutes.ts): `backend/src/routes/FileRoutes.ts`
- [Auth controller](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/controllers/AuthController.ts): `backend/src/controllers/AuthController.ts`
- [Chat controller](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/controllers/ChatController.ts): `backend/src/controllers/ChatController.ts`
- [File controller](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/controllers/FileController.ts): `backend/src/controllers/FileController.ts`

### Realtime and calls

- [Call signaling](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/websocket/handlers/CallHandler.ts): `backend/src/websocket/handlers/CallHandler.ts`
- [WebSocket server](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/websocket/WebSocketServer.ts): `backend/src/websocket/WebSocketServer.ts`
- [Connections](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/websocket/ConnectionManager.ts): `backend/src/websocket/ConnectionManager.ts`

### Domain services

- [Authentication](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/AuthService.ts): `backend/src/services/AuthService.ts`
- [Conversations](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/ChatService.ts): `backend/src/services/ChatService.ts`
- [File transfer](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/FileService.ts): `backend/src/services/FileService.ts`
- [Call lifecycle](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/CallService.ts): `backend/src/services/CallService.ts`

### Persistence and files

- [Data repositories](https://github.com/duc-hust-et1/lan_media/tree/main/backend/src/repositories): `backend/src/repositories`
- [Database access](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/core/database/Database.ts): `backend/src/core/database/Database.ts`
- **MySQL**
- **Server file storage**

### LAN discovery

- [Network discovery](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/NetworkDiscoveryService.ts): `backend/src/services/NetworkDiscoveryService.ts`
- [Network status](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/services/NetworkStatusService.ts): `backend/src/services/NetworkStatusService.ts`
- [LAN discovery](https://github.com/duc-hust-et1/lan_media/blob/main/backend/src/core/network/LanDiscovery.ts): `backend/src/core/network/LanDiscovery.ts`

### Other components

- **User**

## Connections

- User → App routing: uses (evidence: `README.md`)
- App routing → Auth UI: uses (evidence: `frontend/src/App.tsx`)
- Auth UI → Auth client: calls (evidence: `frontend/src/hooks/useAuth.ts`)
- App routing → Chat workspace: renders (evidence: `frontend/src/App.tsx`)
- Chat workspace → Chat client: calls (evidence: `frontend/src/pages/ChatPage/ChatPage.tsx`)
- Chat workspace → File UI: renders (evidence: `frontend/src/pages/ChatPage/ChatPage.tsx`)
- App routing → WebRTC calls: uses (evidence: `frontend/src/App.tsx`)
- App routing → Call interface: renders (evidence: `frontend/src/App.tsx`)
- Call interface → WebRTC calls: uses (evidence: `frontend/src/components/call/CallDialog.tsx`)
- WebRTC calls → Realtime client: signals through (evidence: `frontend/src/hooks/useCall.ts`)
- App routing → Realtime client: connects via (evidence: `frontend/src/App.tsx`)
- User → Network settings: manages network (evidence: `README.md`)
- Auth client → HTTP entrypoint: HTTP requests
- Chat client → HTTP entrypoint: HTTP requests
- Realtime client → WebSocket server: WebSocket events
- HTTP entrypoint → Auth routes: registers (evidence: `backend/src/main.ts`)
- HTTP entrypoint → Chat routes: registers (evidence: `backend/src/main.ts`)
- HTTP entrypoint → File routes: registers (evidence: `backend/src/main.ts`)
- Auth routes → Auth controller: routes to (evidence: `backend/src/routes/AuthRoutes.ts`)
- Chat routes → Chat controller: routes to (evidence: `backend/src/routes/ChatRoutes.ts`)
- File routes → File controller: routes to (evidence: `backend/src/routes/FileRoutes.ts`)
- Auth controller → Authentication: calls (evidence: `backend/src/controllers/AuthController.ts`)
- Chat controller → Conversations: calls (evidence: `backend/src/controllers/ChatController.ts`)
- Chat controller → Connections: dispatches messages (evidence: `backend/src/controllers/ChatController.ts`)
- File controller → File transfer: calls (evidence: `backend/src/controllers/FileController.ts`)
- File controller → Conversations: gets conversation (evidence: `backend/src/controllers/FileController.ts`)
- File controller → Connections: dispatches file message (evidence: `backend/src/controllers/FileController.ts`)
- Authentication → Data repositories: uses (evidence: `backend/src/services/AuthService.ts`)
- Conversations → Data repositories: uses (evidence: `backend/src/controllers/ChatController.ts`)
- File transfer → Data repositories: uses (evidence: `backend/src/services/FileService.ts`)
- Data repositories → Database access: queries (evidence: `backend/src/repositories/SessionRepository.ts`)
- Database access → MySQL: executes SQL (evidence: `backend/src/core/database/Database.ts`)
- File controller → Server file storage: streams downloads (evidence: `backend/src/controllers/FileController.ts`)
- HTTP entrypoint → WebSocket server: starts (evidence: `backend/src/main.ts`)
- WebSocket server → Call signaling: dispatches calls
- Call signaling → Call lifecycle: calls (evidence: `backend/src/websocket/handlers/CallHandler.ts`)
- Call signaling → Connections: sends events (evidence: `backend/src/websocket/handlers/CallHandler.ts`)
- HTTP entrypoint → Network discovery: starts (evidence: `backend/src/main.ts`)
- Network discovery → LAN discovery: uses
- Network settings → Network discovery: configures discovery
