# minhkhoa05/realtimechat architecture

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

- Interactive diagram: https://gitdiagram.com/minhkhoa05/realtimechat
- Repository: https://github.com/minhkhoa05/realtimechat

## Overview

RealtimeChat is a real-time messaging and social communication platform: clients use authenticated HTTP workflows for accounts, conversations, messages and social features, while SignalR carries live events; WebRTC supports calls. The backend follows Clean Architecture, with feature use cases over application abstractions and infrastructure implementations. The README documents media, stickers, recommendations and live-trip sharing as additional product capabilities. Some feature implementations and frontend wiring were not sampled, so those branches are shown at subsystem level and only documented or indexed relationships are connected.

Main entry points: [`backend/RealtimeChat.Api/Controllers`](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Api/Controllers) (HTTP controllers), [`backend/RealtimeChat.Application/Features/Messages`](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Messages) (Messaging workflows), [`backend/RealtimeChat.Api/Hubs/ChatHub.cs`](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Api/Hubs/ChatHub.cs) (SignalR hub), [`backend/RealtimeChat.Domain/Entities`](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Domain/Entities) (Domain entities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_frontend["React client"]
  node_chatui["Chat interface"]
  node_api_client["API client<br/>[api-client.ts]"]
end

subgraph group_api["API and realtime"]
  node_http["HTTP controllers<br/>[Controllers]"]
  node_signalr["SignalR hub<br/>[ChatHub.cs]"]
  node_program["API startup<br/>[Program.cs]"]
end

subgraph group_features["Application workflows"]
  node_auth["Auth workflows<br/>[Auth]"]
  node_conversations["Conversation workflows<br/>[Conversations]"]
  node_messages["Messaging workflows<br/>[Messages]"]
  node_social["Friends and groups<br/>[Relationships]"]
  node_recommendations["Friend recommendations<br/>[Recommendations]"]
  node_media_stickers["Media and stickers<br/>[Features]"]
  node_calls["Call workflows<br/>[Calls]"]
  node_trips["Live trip sharing<br/>[ShareTrip]"]
  node_posts["Posts and comments<br/>[Posts]"]
  node_presence["Presence service<br/>[PresenceService.cs]"]
  node_abstractions["Application ports<br/>[Interfaces]"]
end

subgraph group_domain["Domain model"]
  node_domain_model["Domain entities<br/>[Entities]"]
end

subgraph group_infra["Infrastructure"]
  node_database[("EF persistence<br/>[AppDbContext.cs]")]
  node_storage["File storage"]
  node_routing["Routing service<br/>[RoutingService.cs]"]
  node_cache["Cache service"]
end

node_user(("User"))
node_clients(("Connected clients"))
node_webrtc(("WebRTC peers"))

node_user -->|"uses"| node_frontend
node_frontend -->|"renders"| node_chatui
node_chatui -.->|"requests data"| node_api_client
node_frontend -.->|"calls HTTP"| node_http
node_http -.->|"dispatches"| node_auth
node_http -->|"dispatches"| node_conversations
node_http -->|"dispatches"| node_social
node_http -->|"dispatches"| node_media_stickers
node_http -->|"dispatches"| node_trips
node_http -.->|"dispatches"| node_messages
node_http -.->|"dispatches"| node_calls
node_http -.->|"dispatches"| node_posts
node_program -->|"maps routes"| node_http
node_program -->|"maps hub"| node_signalr
node_messages -->|"notifies clients"| node_abstractions
node_messages -->|"persists messages"| node_database
node_signalr -->|"broadcasts events"| node_clients
node_signalr -.->|"handles presence"| node_presence
node_webrtc -->|"signals calls"| node_signalr
node_presence -->|"uses ports"| node_abstractions
node_recommendations -->|"caches pool"| node_cache
node_trips -->|"calculates ETA"| node_routing
node_media_stickers -.->|"stores media"| node_storage
node_abstractions -->|"provides persistence"| node_database
node_conversations -->|"applies rules"| node_domain_model
node_messages -->|"creates messages"| node_domain_model
node_trips -->|"manages sessions"| node_domain_model
node_calls -->|"tracks call history"| node_domain_model

click node_frontend "https://github.com/minhkhoa05/realtimechat/tree/main/frontend/src"
click node_chatui "https://github.com/minhkhoa05/realtimechat/tree/main/frontend/src/features/messages"
click node_api_client "https://github.com/minhkhoa05/realtimechat/blob/main/frontend/src/lib/api-client.ts"
click node_http "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Api/Controllers"
click node_signalr "https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Api/Hubs/ChatHub.cs"
click node_program "https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Api/Program.cs"
click node_auth "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Auth"
click node_conversations "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Conversations"
click node_messages "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Messages"
click node_social "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Relationships"
click node_recommendations "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Recommendations"
click node_media_stickers "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features"
click node_calls "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Calls"
click node_trips "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/ShareTrip"
click node_posts "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Posts"
click node_presence "https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Application/Features/Presence/PresenceService.cs"
click node_abstractions "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Interfaces"
click node_domain_model "https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Domain/Entities"
click node_database "https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Persistence/AppDbContext.cs"
click node_storage "https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Storage/LocalFileStorage.cs"
click node_routing "https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Routings/RoutingService.cs"
click node_cache "https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Caching/InMemoryCacheService.cs"

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_chatui,node_api_client,node_user,node_clients toneBlue
class node_http,node_signalr,node_program toneAmber
class node_auth,node_conversations,node_messages,node_social,node_recommendations,node_media_stickers,node_calls,node_trips,node_posts,node_presence,node_abstractions toneMint
class node_domain_model toneRose
class node_database,node_storage,node_routing,node_cache,node_webrtc toneIndigo
```

## Components

### Client experience

- [React client](https://github.com/minhkhoa05/realtimechat/tree/main/frontend/src): `frontend/src`
- [Chat interface](https://github.com/minhkhoa05/realtimechat/tree/main/frontend/src/features/messages): `frontend/src/features/messages`
- [API client](https://github.com/minhkhoa05/realtimechat/blob/main/frontend/src/lib/api-client.ts): `frontend/src/lib/api-client.ts`

### API and realtime

- [HTTP controllers](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Api/Controllers): `backend/RealtimeChat.Api/Controllers`
- [SignalR hub](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Api/Hubs/ChatHub.cs): `backend/RealtimeChat.Api/Hubs/ChatHub.cs`
- [API startup](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Api/Program.cs): `backend/RealtimeChat.Api/Program.cs`

### Application workflows

- [Auth workflows](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Auth): `backend/RealtimeChat.Application/Features/Auth`
- [Conversation workflows](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Conversations): `backend/RealtimeChat.Application/Features/Conversations`
- [Messaging workflows](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Messages): `backend/RealtimeChat.Application/Features/Messages`
- [Friends and groups](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Relationships): `backend/RealtimeChat.Application/Features/Relationships`
- [Friend recommendations](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Recommendations): `backend/RealtimeChat.Application/Features/Recommendations`
- [Media and stickers](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features): `backend/RealtimeChat.Application/Features`
- [Call workflows](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Calls): `backend/RealtimeChat.Application/Features/Calls`
- [Live trip sharing](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/ShareTrip): `backend/RealtimeChat.Application/Features/ShareTrip`
- [Posts and comments](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Features/Posts): `backend/RealtimeChat.Application/Features/Posts`
- [Presence service](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Application/Features/Presence/PresenceService.cs): `backend/RealtimeChat.Application/Features/Presence/PresenceService.cs`
- [Application ports](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Application/Interfaces): `backend/RealtimeChat.Application/Interfaces`

### Domain model

- [Domain entities](https://github.com/minhkhoa05/realtimechat/tree/main/backend/RealtimeChat.Domain/Entities): `backend/RealtimeChat.Domain/Entities`

### Infrastructure

- [EF persistence](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Persistence/AppDbContext.cs): `backend/RealtimeChat.Infrastructure/Persistence/AppDbContext.cs`
- [File storage](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Storage/LocalFileStorage.cs): `backend/RealtimeChat.Infrastructure/Storage/LocalFileStorage.cs`
- [Routing service](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Routings/RoutingService.cs): `backend/RealtimeChat.Infrastructure/Routings/RoutingService.cs`
- [Cache service](https://github.com/minhkhoa05/realtimechat/blob/main/backend/RealtimeChat.Infrastructure/Caching/InMemoryCacheService.cs): `backend/RealtimeChat.Infrastructure/Caching/InMemoryCacheService.cs`

### Other components

- **User**
- **Connected clients**
- **WebRTC peers**

## Connections

- User → React client: uses
- React client → Chat interface: renders (evidence: `frontend/src/app/App.tsx`)
- Chat interface → API client: requests data
- React client → HTTP controllers: calls HTTP
- HTTP controllers → Auth workflows: dispatches
- HTTP controllers → Conversation workflows: dispatches (evidence: `backend/RealtimeChat.Api/Controllers/ConversationController.cs`)
- HTTP controllers → Friends and groups: dispatches (evidence: `backend/RealtimeChat.Api/Controllers/RelationshipController.cs`)
- HTTP controllers → Media and stickers: dispatches (evidence: `backend/RealtimeChat.Api/Controllers/StickerCollectionsController.cs`)
- HTTP controllers → Live trip sharing: dispatches (evidence: `backend/RealtimeChat.Api/Controllers/ShareTripController.cs`)
- HTTP controllers → Messaging workflows: dispatches (evidence: `backend/RealtimeChat.Api/Controllers/MessageController.cs`)
- HTTP controllers → Call workflows: dispatches
- HTTP controllers → Posts and comments: dispatches
- API startup → HTTP controllers: maps routes (evidence: `backend/RealtimeChat.Api/Program.cs`)
- API startup → SignalR hub: maps hub (evidence: `backend/RealtimeChat.Api/Program.cs`)
- Messaging workflows → Application ports: notifies clients (evidence: `backend/RealtimeChat.Application/Features/Messages/Services/MessageService.cs`)
- Messaging workflows → EF persistence: persists messages
- SignalR hub → Connected clients: broadcasts events
- SignalR hub → Presence service: handles presence
- WebRTC peers → SignalR hub: signals calls
- Presence service → Application ports: uses ports (evidence: `backend/RealtimeChat.Application/Features/Presence/PresenceService.cs`)
- Friend recommendations → Cache service: caches pool (evidence: `backend/RealtimeChat.Application/Features/Recommendations/CandidatePool/PoolManager.cs`)
- Live trip sharing → Routing service: calculates ETA (evidence: `backend/RealtimeChat.Application/Features/ShareTrip/Services/ShareTripService.cs`)
- Media and stickers → File storage: stores media
- Application ports → EF persistence: provides persistence (evidence: `backend/RealtimeChat.Infrastructure/Persistence/AppDbContext.cs`)
- Conversation workflows → Domain entities: applies rules (evidence: `backend/RealtimeChat.Application/Features/Conversations/Services/ConversationService.cs`)
- Messaging workflows → Domain entities: creates messages (evidence: `backend/RealtimeChat.Domain/Entities/Message.cs`)
- Live trip sharing → Domain entities: manages sessions (evidence: `backend/RealtimeChat.Domain/Entities/ShareTripSession.cs`)
- Call workflows → Domain entities: tracks call history (evidence: `backend/RealtimeChat.Application/Features/Calls/Services/CallHistoryService.cs`)
