# saadpy111/chatapplication architecture

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

- Interactive diagram: https://gitdiagram.com/saadpy111/chatapplication
- Repository: https://github.com/saadpy111/chatapplication

## Overview

This is a one-to-one chat application: users register or sign in, find another user, open a conversation, then exchange messages and use search, reactions, presence, typing, and read/delivery receipts. The Angular client reaches authenticated HTTP endpoints and a SignalR hub; backend services apply domain rules and persist chat state through EF Core to SQL Server. The graph reflects the shown source and README; some client component wiring and unsampled controller or hub operations are documented but not verified at call level.

Main entry points: [`ChatApi/Data/ApplicationDbContext.cs`](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Data/ApplicationDbContext.cs) (SQL Server state), [`ChatApi/Hubs/ChatHub.cs`](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Hubs/ChatHub.cs) (SignalR hub), [`ChatApi/Services/Conversations/ConversationService.cs`](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Conversations/ConversationService.cs) (Conversation and messages), [`ChatClient/src/app/app.routes.ts`](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/app.routes.ts) (Route guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Angular client"]
  node_authui["Login and register<br/>[login.ts]"]
  node_authclient["Client auth<br/>[auth.service.ts]"]
  node_routes["Route guard<br/>[app.routes.ts]"]
  node_chatui["Chat interface<br/>[chat.component.ts]"]
  node_chatclient["Live chat client<br/>[chatService.ts]"]
  node_conversationapi["Conversation API client"]
  node_userapi["User search client"]
end

subgraph group_api["API endpoints"]
  node_authcontroller["Auth endpoints<br/>[AuthController.cs]"]
  node_userscontroller["User search endpoint<br/>[UsersController.cs]"]
  node_conversationscontroller["Conversation endpoints"]
  node_hub["SignalR hub<br/>[ChatHub.cs]"]
end

subgraph group_services["Domain services"]
  node_authservice["Authentication<br/>[AuthService.cs]"]
  node_userservice["User search"]
  node_conversationservice["Conversation and messages"]
  node_presence["Presence tracking<br/>[PresenceService.cs]"]
  node_reactions["Message reactions<br/>[ReactionService.cs]"]
end

subgraph group_state["Persistence"]
  node_sql[("SQL Server state")]
  node_entities["Chat and user entities<br/>[Message.cs]"]
end

node_user(("Chat user"))

node_user -->|"signs in"| node_authui
node_authui -.->|"requests auth"| node_authclient
node_authclient -.->|"calls API"| node_authcontroller
node_authcontroller -->|"delegates auth"| node_authservice
node_authservice -->|"manages identity"| node_sql
node_user -->|"opens chat"| node_routes
node_routes -->|"routes to"| node_chatui
node_routes -->|"routes to"| node_authui
node_chatui -.->|"uses live chat"| node_chatclient
node_chatui -.->|"loads conversations"| node_conversationapi
node_chatclient -->|"SignalR interactions"| node_hub
node_conversationapi -.->|"calls API"| node_conversationscontroller
node_userapi -.->|"calls API"| node_userscontroller
node_userscontroller -->|"delegates search"| node_userservice
node_conversationscontroller -->|"delegates operations"| node_conversationservice
node_conversationscontroller -->|"broadcasts edits"| node_hub
node_hub -->|"handles chat actions"| node_conversationservice
node_hub -->|"tracks connections"| node_presence
node_hub -->|"handles reactions"| node_reactions
node_conversationservice -->|"reads snapshots"| node_presence
node_conversationservice -->|"reads and writes"| node_sql
node_userservice -.->|"queries users"| node_sql
node_presence -->|"persists last seen"| node_sql
node_reactions -->|"reads and writes"| node_sql
node_sql -->|"maps entities"| node_entities

click node_authui "https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/auth/pages/login/login.ts"
click node_authclient "https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/core/services/auth.service.ts"
click node_routes "https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/app.routes.ts"
click node_chatui "https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/chat/pages/chat/chat.component.ts"
click node_chatclient "https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/chat/services/chatService.ts"
click node_conversationapi "https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/chat/services/conversations-api.service.ts"
click node_userapi "https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/users/data-access/users-api.service.ts"
click node_authcontroller "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Controllers/AuthController.cs"
click node_userscontroller "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Controllers/UsersController.cs"
click node_conversationscontroller "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Controllers/ConversationsController.cs"
click node_hub "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Hubs/ChatHub.cs"
click node_authservice "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Auth/AuthService.cs"
click node_userservice "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Users/UserSearchService.cs"
click node_conversationservice "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Conversations/ConversationService.cs"
click node_presence "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Presence/PresenceService.cs"
click node_reactions "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Reactions/ReactionService.cs"
click node_sql "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Data/ApplicationDbContext.cs"
click node_entities "https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Models/Message.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_authui,node_authclient,node_routes,node_chatui,node_chatclient,node_conversationapi,node_userapi,node_user toneBlue
class node_authcontroller,node_userscontroller,node_conversationscontroller,node_hub toneAmber
class node_authservice,node_userservice,node_conversationservice,node_presence,node_reactions toneMint
class node_sql,node_entities toneRose
```

## Components

### Angular client

- [Login and register](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/auth/pages/login/login.ts): `ChatClient/src/app/features/auth/pages/login/login.ts`
- [Client auth](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/core/services/auth.service.ts): `ChatClient/src/app/core/services/auth.service.ts`
- [Route guard](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/app.routes.ts): `ChatClient/src/app/app.routes.ts`
- [Chat interface](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/chat/pages/chat/chat.component.ts): `ChatClient/src/app/features/chat/pages/chat/chat.component.ts`
- [Live chat client](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/chat/services/chatService.ts): `ChatClient/src/app/features/chat/services/chatService.ts`
- [Conversation API client](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/chat/services/conversations-api.service.ts): `ChatClient/src/app/features/chat/services/conversations-api.service.ts`
- [User search client](https://github.com/saadpy111/chatapplication/blob/master/ChatClient/src/app/features/users/data-access/users-api.service.ts): `ChatClient/src/app/features/users/data-access/users-api.service.ts`

### API endpoints

- [Auth endpoints](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Controllers/AuthController.cs): `ChatApi/Controllers/AuthController.cs`
- [User search endpoint](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Controllers/UsersController.cs): `ChatApi/Controllers/UsersController.cs`
- [Conversation endpoints](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Controllers/ConversationsController.cs): `ChatApi/Controllers/ConversationsController.cs`
- [SignalR hub](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Hubs/ChatHub.cs): `ChatApi/Hubs/ChatHub.cs`

### Domain services

- [Authentication](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Auth/AuthService.cs): `ChatApi/Services/Auth/AuthService.cs`
- [User search](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Users/UserSearchService.cs): `ChatApi/Services/Users/UserSearchService.cs`
- [Conversation and messages](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Conversations/ConversationService.cs): `ChatApi/Services/Conversations/ConversationService.cs`
- [Presence tracking](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Presence/PresenceService.cs): `ChatApi/Services/Presence/PresenceService.cs`
- [Message reactions](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Services/Reactions/ReactionService.cs): `ChatApi/Services/Reactions/ReactionService.cs`

### Persistence

- [SQL Server state](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Data/ApplicationDbContext.cs): `ChatApi/Data/ApplicationDbContext.cs`
- [Chat and user entities](https://github.com/saadpy111/chatapplication/blob/master/ChatApi/Models/Message.cs): `ChatApi/Models/Message.cs`

### Other components

- **Chat user**

## Connections

- Chat user → Login and register: signs in
- Login and register → Client auth: requests auth
- Client auth → Auth endpoints: calls API
- Auth endpoints → Authentication: delegates auth (evidence: `ChatApi/Controllers/AuthController.cs`)
- Authentication → SQL Server state: manages identity (evidence: `ChatApi/Services/Auth/AuthService.cs`)
- Chat user → Route guard: opens chat
- Route guard → Chat interface: routes to (evidence: `ChatClient/src/app/app.routes.ts`)
- Route guard → Login and register: routes to (evidence: `ChatClient/src/app/app.routes.ts`)
- Chat interface → Live chat client: uses live chat
- Chat interface → Conversation API client: loads conversations
- Live chat client → SignalR hub: SignalR interactions
- Conversation API client → Conversation endpoints: calls API
- User search client → User search endpoint: calls API
- User search endpoint → User search: delegates search (evidence: `ChatApi/Controllers/UsersController.cs`)
- Conversation endpoints → Conversation and messages: delegates operations (evidence: `ChatApi/Controllers/ConversationsController.cs`)
- Conversation endpoints → SignalR hub: broadcasts edits (evidence: `ChatApi/Controllers/ConversationsController.cs`)
- SignalR hub → Conversation and messages: handles chat actions (evidence: `ChatApi/Hubs/ChatHub.cs`)
- SignalR hub → Presence tracking: tracks connections (evidence: `ChatApi/Hubs/ChatHub.cs`)
- SignalR hub → Message reactions: handles reactions (evidence: `ChatApi/Hubs/ChatHub.cs`)
- Conversation and messages → Presence tracking: reads snapshots (evidence: `ChatApi/Services/Conversations/ConversationService.cs`)
- Conversation and messages → SQL Server state: reads and writes (evidence: `ChatApi/Services/Conversations/ConversationService.cs`)
- User search → SQL Server state: queries users
- Presence tracking → SQL Server state: persists last seen (evidence: `ChatApi/Services/Presence/PresenceService.cs`)
- Message reactions → SQL Server state: reads and writes (evidence: `ChatApi/Services/Reactions/ReactionService.cs`)
- SQL Server state → Chat and user entities: maps entities (evidence: `ChatApi/Data/ApplicationDbContext.cs`)
