# stanislavtrue/mymessenger architecture

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

- Interactive diagram: https://gitdiagram.com/stanislavtrue/mymessenger
- Repository: https://github.com/stanislavtrue/mymessenger

## Overview

This is a real-time chat product with a React messenger and ASP.NET Core API. Users authenticate, browse chats, load and send messages, and manage read state, replies, reactions, pins, and deletions; SignalR supports live chat and Redis tracks presence. The graph preserves those documented-by-source subsystems, but frontend-to-API and hub event details are not shown, so those links are dashed and unverified. Persistence is represented as PostgreSQL-backed data access; source evidence shows EF Core configuration but not the deployment environment.

Main entry points: [`backend/Chat.Persistence/ChatDbContext.cs`](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/ChatDbContext.cs) (Chat database), [`backend/Chat.Application/Services/ChatRoomsService.cs`](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/ChatRoomsService.cs) (Room service), [`backend/Chat.Application/Services/MessagesService.cs`](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/MessagesService.cs) (Message service), [`backend/Chat.Application/Services/UsersService.cs`](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/UsersService.cs) (User service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_app["Messenger app<br/>[App.jsx]"]
  node_messenger["Messenger state"]
  node_views["Chat and sidebar UI"]
  node_authui["Login UI<br/>[LoginPage.jsx]"]
end

subgraph group_api["API and realtime"]
  node_authapi["Auth endpoints<br/>[AuthController.cs]"]
  node_controllers["Chat endpoints"]
  node_roomcontroller["Room endpoints"]
  node_hub["Realtime hub<br/>[ChatHub.cs]"]
end

subgraph group_application["Application services"]
  node_users["User service<br/>[UsersService.cs]"]
  node_rooms["Room service"]
  node_messages["Message service<br/>[MessagesService.cs]"]
end

subgraph group_data["Persistence and infrastructure"]
  node_userrepo["User repository<br/>[UsersRepository.cs]"]
  node_roomrepo["Room and member data"]
  node_memberrepo["Membership data"]
  node_messagerepo["Message data"]
  node_pinnedrepo["Pinned messages"]
  node_reactionsrepo["Reaction data"]
  node_tokensrepo["Refresh tokens"]
  node_db[("Chat database<br/>[ChatDbContext.cs]")]
  node_status["Presence tracker"]
  node_jwt["JWT provider<br/>[JwtProvider.cs]"]
end

node_user(("Chat user"))
node_redis[("Redis")]
node_actor(("Browser client"))

node_user -->|"uses"| node_app
node_app -->|"provides state"| node_messenger
node_app -->|"renders"| node_views
node_authui -.->|"accepts credentials"| node_actor
node_messenger -->|"feeds state"| node_views
node_messenger -.->|"calls API"| node_actor
node_actor -.->|"HTTP requests"| node_authapi
node_actor -.->|"HTTP requests"| node_controllers
node_actor -.->|"HTTP requests"| node_roomcontroller
node_actor -.->|"realtime connection"| node_hub
node_authapi -->|"calls"| node_users
node_controllers -->|"calls"| node_messages
node_controllers -->|"calls"| node_rooms
node_roomcontroller -->|"calls"| node_rooms
node_users -->|"reads and writes"| node_userrepo
node_users -->|"reads and writes"| node_tokensrepo
node_users -->|"generates tokens"| node_jwt
node_rooms -.->|"reads and writes"| node_roomrepo
node_rooms -->|"reads and writes"| node_memberrepo
node_rooms -->|"reads messages"| node_messagerepo
node_rooms -->|"reads pins"| node_pinnedrepo
node_messages -->|"reads and writes"| node_messagerepo
node_messages -->|"checks access"| node_memberrepo
node_messages -->|"reads and writes"| node_reactionsrepo
node_messages -->|"manages pins"| node_pinnedrepo
node_userrepo -.->|"queries"| node_db
node_roomrepo -.->|"queries"| node_db
node_memberrepo -->|"queries"| node_db
node_messagerepo -->|"queries"| node_db
node_pinnedrepo -->|"queries"| node_db
node_reactionsrepo -.->|"queries"| node_db
node_tokensrepo -.->|"queries"| node_db
node_hub -.->|"tracks presence"| node_status
node_status -.->|"stores presence"| node_redis

click node_app "https://github.com/stanislavtrue/mymessenger/blob/main/frontend/chat/src/App.jsx"
click node_messenger "https://github.com/stanislavtrue/mymessenger/blob/main/frontend/chat/src/features/messenger/context/MessengerContext.jsx"
click node_views "https://github.com/stanislavtrue/mymessenger/tree/main/frontend/chat/src/features/messenger/components"
click node_authui "https://github.com/stanislavtrue/mymessenger/blob/main/frontend/chat/src/features/auth/LoginPage.jsx"
click node_authapi "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Controllers/AuthController.cs"
click node_controllers "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Controllers/MessagesController.cs"
click node_roomcontroller "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Controllers/ChatRoomsController.cs"
click node_hub "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Hubs/ChatHub.cs"
click node_users "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/UsersService.cs"
click node_rooms "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/ChatRoomsService.cs"
click node_messages "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/MessagesService.cs"
click node_userrepo "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/UsersRepository.cs"
click node_roomrepo "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/ChatRoomsRepository.cs"
click node_memberrepo "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/ChatMembersRepository.cs"
click node_messagerepo "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/MessagesRepository.cs"
click node_pinnedrepo "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/PinnedMessagesRepository.cs"
click node_reactionsrepo "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/MessageReactionsRepository.cs"
click node_tokensrepo "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/RefreshTokensRepository.cs"
click node_db "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/ChatDbContext.cs"
click node_status "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Infrastructure/Services/RedisUserStatusTracker.cs"
click node_jwt "https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Infrastructure/Authentication/JwtProvider.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_app,node_messenger,node_views,node_authui,node_user,node_actor toneBlue
class node_authapi,node_controllers,node_roomcontroller,node_hub,node_redis toneAmber
class node_users,node_rooms,node_messages toneMint
class node_userrepo,node_roomrepo,node_memberrepo,node_messagerepo,node_pinnedrepo,node_reactionsrepo,node_tokensrepo,node_db,node_status,node_jwt toneRose
```

## Components

### Chat client

- [Messenger app](https://github.com/stanislavtrue/mymessenger/blob/main/frontend/chat/src/App.jsx): `frontend/chat/src/App.jsx`
- [Messenger state](https://github.com/stanislavtrue/mymessenger/blob/main/frontend/chat/src/features/messenger/context/MessengerContext.jsx): `frontend/chat/src/features/messenger/context/MessengerContext.jsx`
- [Chat and sidebar UI](https://github.com/stanislavtrue/mymessenger/tree/main/frontend/chat/src/features/messenger/components): `frontend/chat/src/features/messenger/components`
- [Login UI](https://github.com/stanislavtrue/mymessenger/blob/main/frontend/chat/src/features/auth/LoginPage.jsx): `frontend/chat/src/features/auth/LoginPage.jsx`

### API and realtime

- [Auth endpoints](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Controllers/AuthController.cs): `backend/Chat.API/Controllers/AuthController.cs`
- [Chat endpoints](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Controllers/MessagesController.cs): `backend/Chat.API/Controllers/MessagesController.cs`
- [Room endpoints](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Controllers/ChatRoomsController.cs): `backend/Chat.API/Controllers/ChatRoomsController.cs`
- [Realtime hub](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.API/Hubs/ChatHub.cs): `backend/Chat.API/Hubs/ChatHub.cs`

### Application services

- [User service](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/UsersService.cs): `backend/Chat.Application/Services/UsersService.cs`
- [Room service](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/ChatRoomsService.cs): `backend/Chat.Application/Services/ChatRoomsService.cs`
- [Message service](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Application/Services/MessagesService.cs): `backend/Chat.Application/Services/MessagesService.cs`

### Persistence and infrastructure

- [User repository](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/UsersRepository.cs): `backend/Chat.Persistence/Repositories/UsersRepository.cs`
- [Room and member data](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/ChatRoomsRepository.cs): `backend/Chat.Persistence/Repositories/ChatRoomsRepository.cs`
- [Membership data](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/ChatMembersRepository.cs): `backend/Chat.Persistence/Repositories/ChatMembersRepository.cs`
- [Message data](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/MessagesRepository.cs): `backend/Chat.Persistence/Repositories/MessagesRepository.cs`
- [Pinned messages](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/PinnedMessagesRepository.cs): `backend/Chat.Persistence/Repositories/PinnedMessagesRepository.cs`
- [Reaction data](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/MessageReactionsRepository.cs): `backend/Chat.Persistence/Repositories/MessageReactionsRepository.cs`
- [Refresh tokens](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/Repositories/RefreshTokensRepository.cs): `backend/Chat.Persistence/Repositories/RefreshTokensRepository.cs`
- [Chat database](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Persistence/ChatDbContext.cs): `backend/Chat.Persistence/ChatDbContext.cs`
- [Presence tracker](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Infrastructure/Services/RedisUserStatusTracker.cs): `backend/Chat.Infrastructure/Services/RedisUserStatusTracker.cs`
- [JWT provider](https://github.com/stanislavtrue/mymessenger/blob/main/backend/Chat.Infrastructure/Authentication/JwtProvider.cs): `backend/Chat.Infrastructure/Authentication/JwtProvider.cs`

### Other components

- **Chat user**
- **Redis**
- **Browser client**

## Connections

- Chat user → Messenger app: uses (evidence: `frontend/chat/src/App.jsx`)
- Messenger app → Messenger state: provides state (evidence: `frontend/chat/src/App.jsx`)
- Messenger app → Chat and sidebar UI: renders (evidence: `frontend/chat/src/App.jsx`)
- Login UI → Browser client: accepts credentials
- Messenger state → Chat and sidebar UI: feeds state
- Messenger state → Browser client: calls API
- Browser client → Auth endpoints: HTTP requests
- Browser client → Chat endpoints: HTTP requests
- Browser client → Room endpoints: HTTP requests
- Browser client → Realtime hub: realtime connection
- Auth endpoints → User service: calls (evidence: `backend/Chat.API/Controllers/AuthController.cs`)
- Chat endpoints → Message service: calls (evidence: `backend/Chat.API/Controllers/MessagesController.cs`)
- Chat endpoints → Room service: calls (evidence: `backend/Chat.API/Controllers/MessagesController.cs`)
- Room endpoints → Room service: calls (evidence: `backend/Chat.API/Controllers/ChatRoomsController.cs`)
- User service → User repository: reads and writes (evidence: `backend/Chat.Application/Services/UsersService.cs`)
- User service → Refresh tokens: reads and writes (evidence: `backend/Chat.Application/Services/UsersService.cs`)
- User service → JWT provider: generates tokens (evidence: `backend/Chat.Application/Services/UsersService.cs`)
- Room service → Room and member data: reads and writes
- Room service → Membership data: reads and writes (evidence: `backend/Chat.Application/Services/ChatRoomsService.cs`)
- Room service → Message data: reads messages (evidence: `backend/Chat.Application/Services/ChatRoomsService.cs`)
- Room service → Pinned messages: reads pins (evidence: `backend/Chat.Application/Services/ChatRoomsService.cs`)
- Message service → Message data: reads and writes (evidence: `backend/Chat.Application/Services/MessagesService.cs`)
- Message service → Membership data: checks access (evidence: `backend/Chat.Application/Services/MessagesService.cs`)
- Message service → Reaction data: reads and writes (evidence: `backend/Chat.Application/Services/MessagesService.cs`)
- Message service → Pinned messages: manages pins (evidence: `backend/Chat.Application/Services/MessagesService.cs`)
- User repository → Chat database: queries
- Room and member data → Chat database: queries
- Membership data → Chat database: queries (evidence: `backend/Chat.Persistence/Repositories/ChatMembersRepository.cs`)
- Message data → Chat database: queries (evidence: `backend/Chat.Persistence/Repositories/MessagesRepository.cs`)
- Pinned messages → Chat database: queries (evidence: `backend/Chat.Persistence/Repositories/PinnedMessagesRepository.cs`)
- Reaction data → Chat database: queries
- Refresh tokens → Chat database: queries
- Realtime hub → Presence tracker: tracks presence
- Presence tracker → Redis: stores presence
