# muhaha365/demo_nt106_doan architecture

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

- Interactive diagram: https://gitdiagram.com/muhaha365/demo_nt106_doan
- Repository: https://github.com/muhaha365/demo_nt106_doan

## Overview

UIT Chat is a WinForms desktop chat application backed by a central TCP/TLS server. A user connects with the server address and certificate fingerprint, registers or logs in, then uses the chat interface for messaging and related social features; the server persists shared state and attachments. The README documents authentication, presence, friends, groups, history, search, file sharing, and access control. Detailed UI request handlers and some server internals were not sampled, so those relationships are shown only where source or documentation supports them.

Main entry points: [`Chat.Server/ChatServer.cs`](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs) (Request server), [`Chat.Core/ChatClient.cs`](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Core/ChatClient.cs) (TCP/TLS client), [`WinFormsApp1/Form1.cs`](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Form1.cs) (Window selection), [`WinFormsApp1/LoginForm.cs`](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/LoginForm.cs) (Connect and login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop client"]
  node_app["Application entry<br/>[Program.cs]"]
  node_launcher["Window selection<br/>[Form1.cs]"]
  node_login["Connect and login<br/>[LoginForm.cs]"]
  node_chatui["Chat workspace<br/>[ChatForm.cs]"]
  node_dialogs["Chat dialogs<br/>[Dialogs.cs]"]
  node_bubble["Message display<br/>[MessageBubble.cs]"]
  node_theme["UI styling<br/>[Theme.cs]"]
  node_serverui["Server manager<br/>[ServerForm.cs]"]
end

subgraph group_wire["Shared protocol"]
  node_client["TCP/TLS client<br/>[ChatClient.cs]"]
  node_codec["Frame codec<br/>[FrameCodec.cs]"]
  node_contracts["Packet contracts<br/>[Contracts.cs]"]
end

subgraph group_backend["Server runtime"]
  node_host["Console host<br/>[Program.cs]"]
  node_server["Request server<br/>[ChatServer.cs]"]
  node_auth["Identity and access<br/>[ChatServer.cs]"]
  node_community["Friends and groups<br/>[ChatServer.cs]"]
  node_chatdata["Messages and files<br/>[ChatServer.cs]"]
  node_presence["Presence and events<br/>[ChatServer.cs]"]
  node_storage[("JSON and attachments<br/>[Storage.cs]")]
end

node_user(("Chat user"))

node_user -->|"opens"| node_app
node_app -->|"starts"| node_launcher
node_launcher -->|"opens"| node_login
node_launcher -->|"opens"| node_serverui
node_login -->|"connects through"| node_client
node_login -->|"opens after login"| node_chatui
node_chatui -->|"requests and receives"| node_client
node_chatui -->|"renders messages"| node_bubble
node_dialogs -->|"uses"| node_client
node_client -->|"frames packets"| node_codec
node_client -.->|"sends over TLS"| node_server
node_serverui -->|"starts and stops"| node_server
node_host -->|"starts"| node_server
node_server -->|"reads and commits"| node_storage
node_server -->|"handles authentication"| node_auth
node_server -->|"handles social features"| node_community
node_server -->|"handles chat and files"| node_chatdata
node_server -->|"handles presence"| node_presence

click node_app "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Program.cs"
click node_launcher "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Form1.cs"
click node_login "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/LoginForm.cs"
click node_chatui "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/ChatForm.cs"
click node_dialogs "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Dialogs.cs"
click node_bubble "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/MessageBubble.cs"
click node_theme "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Theme.cs"
click node_client "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Core/ChatClient.cs"
click node_codec "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Core/FrameCodec.cs"
click node_contracts "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Core/Contracts.cs"
click node_serverui "https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/ServerForm.cs"
click node_host "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Host/Program.cs"
click node_server "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs"
click node_auth "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs"
click node_community "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs"
click node_chatdata "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs"
click node_presence "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs"
click node_storage "https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/Storage.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_launcher,node_login,node_chatui,node_dialogs,node_bubble,node_theme,node_serverui,node_user toneBlue
class node_client,node_codec,node_contracts toneAmber
class node_host,node_server,node_auth,node_community,node_chatdata,node_presence,node_storage toneMint
```

## Components

### Desktop client

- [Application entry](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Program.cs): `WinFormsApp1/Program.cs`
- [Window selection](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Form1.cs): `WinFormsApp1/Form1.cs`
- [Connect and login](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/LoginForm.cs): `WinFormsApp1/LoginForm.cs`
- [Chat workspace](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/ChatForm.cs): `WinFormsApp1/ChatForm.cs`
- [Chat dialogs](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Dialogs.cs): `WinFormsApp1/Dialogs.cs`
- [Message display](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/MessageBubble.cs): `WinFormsApp1/MessageBubble.cs`
- [UI styling](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/Theme.cs): `WinFormsApp1/Theme.cs`
- [Server manager](https://github.com/muhaha365/demo_nt106_doan/blob/main/WinFormsApp1/ServerForm.cs): `WinFormsApp1/ServerForm.cs`

### Shared protocol

- [TCP/TLS client](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Core/ChatClient.cs): `Chat.Core/ChatClient.cs`
- [Frame codec](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Core/FrameCodec.cs): `Chat.Core/FrameCodec.cs`
- [Packet contracts](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Core/Contracts.cs): `Chat.Core/Contracts.cs`

### Server runtime

- [Console host](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Host/Program.cs): `Chat.Host/Program.cs`
- [Request server](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs): `Chat.Server/ChatServer.cs`
- [Identity and access](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs): `Chat.Server/ChatServer.cs`
- [Friends and groups](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs): `Chat.Server/ChatServer.cs`
- [Messages and files](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs): `Chat.Server/ChatServer.cs`
- [Presence and events](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/ChatServer.cs): `Chat.Server/ChatServer.cs`
- [JSON and attachments](https://github.com/muhaha365/demo_nt106_doan/blob/main/Chat.Server/Storage.cs): `Chat.Server/Storage.cs`

### Other components

- **Chat user**

## Connections

- Chat user → Application entry: opens (evidence: `README.md`)
- Application entry → Window selection: starts (evidence: `WinFormsApp1/Program.cs`)
- Window selection → Connect and login: opens (evidence: `WinFormsApp1/Form1.cs`)
- Window selection → Server manager: opens (evidence: `WinFormsApp1/Form1.cs`)
- Connect and login → TCP/TLS client: connects through (evidence: `WinFormsApp1/LoginForm.cs`)
- Connect and login → Chat workspace: opens after login (evidence: `WinFormsApp1/LoginForm.cs`)
- Chat workspace → TCP/TLS client: requests and receives (evidence: `WinFormsApp1/ChatForm.cs`)
- Chat workspace → Message display: renders messages (evidence: `WinFormsApp1/ChatForm.cs`)
- Chat dialogs → TCP/TLS client: uses (evidence: `WinFormsApp1/Dialogs.cs`)
- TCP/TLS client → Frame codec: frames packets (evidence: `Chat.Core/ChatClient.cs`)
- TCP/TLS client → Request server: sends over TLS (evidence: `README.md`)
- Server manager → Request server: starts and stops (evidence: `WinFormsApp1/ServerForm.cs`)
- Console host → Request server: starts (evidence: `Chat.Host/Program.cs`)
- Request server → JSON and attachments: reads and commits (evidence: `Chat.Server/ChatServer.cs`)
- Request server → Identity and access: handles authentication (evidence: `README.md`)
- Request server → Friends and groups: handles social features (evidence: `README.md`)
- Request server → Messages and files: handles chat and files (evidence: `README.md`)
- Request server → Presence and events: handles presence (evidence: `README.md`)
