# liu-jianhao/chatroom architecture

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

- Interactive diagram: https://gitdiagram.com/liu-jianhao/chatroom
- Repository: https://github.com/liu-jianhao/chatroom

## Overview

This repository is a learning project that evolves a TCP chat room through successive client and server implementations. The workflow progresses from connecting and exchanging messages to a Qt GUI client, a Reactor-based server, and finally an account-oriented client paired with a MySQL-enabled server. The README documents these capabilities; the sampled source confirms the early socket client/server, Qt socket behavior, and server entry points. The Reactor internals, account flow, and database operations were not sampled, so their internal wiring is left unspecified.

Main entry points: [`dayOne/client.c`](https://github.com/liu-jianhao/chatroom/blob/master/dayOne/client.c) (Terminal client), [`dayOne/server.c`](https://github.com/liu-jianhao/chatroom/blob/master/dayOne/server.c) (Basic chat server), [`dayThree/TcpClient/tcpclient.cpp`](https://github.com/liu-jianhao/chatroom/blob/master/dayThree/TcpClient/tcpclient.cpp) (GUI chat client), [`dayFive/main.cpp`](https://github.com/liu-jianhao/chatroom/blob/master/dayFive/main.cpp) (Logged server entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_early["Socket Prototype"]
  node_cli["Terminal client<br/>[client.c]"]
  node_basicserver["Basic chat server<br/>[server.c]"]
end

subgraph group_qt["Qt Clients"]
  node_dialog["TCP demo client<br/>[dialog.cpp]"]
  node_gui["GUI chat client<br/>[tcpclient.cpp]"]
  node_guientry["GUI entry point<br/>[main.cpp]"]
end

subgraph group_reactor["Reactor Servers"]
  node_reactorentry4["Reactor entry point<br/>[main.cpp]"]
  node_reactor4["Reactor server<br/>[MyReactor.cpp]"]
  node_reactorentry5["Logged server entry<br/>[main.cpp]"]
  node_reactor5["Logged Reactor<br/>[MyReactor.cpp]"]
  node_logger["Server logging<br/>[main.cpp]"]
end

subgraph group_accounts["Account Chat"]
  node_signentry["Account client entry<br/>[main.cpp]"]
  node_signin["Sign-in interface<br/>[sign.cpp]"]
  node_chatroom["Chat interface<br/>[chatroom.cpp]"]
  node_tcpclient["Qt chat transport<br/>[tcpclient.cpp]"]
  node_accountserver["MySQL chat server"]
  node_accountreactor["Server Reactor<br/>[MyReactor.cpp]"]
end

node_person(("Chat participant"))
node_mysql[("MySQL database")]

node_person -->|"enters chat text"| node_cli
node_cli -->|"sends TCP messages"| node_basicserver
node_basicserver -->|"returns chat messages"| node_cli
node_person -->|"uses client"| node_dialog
node_person -->|"uses client"| node_gui
node_guientry -->|"creates window"| node_gui
node_gui -->|"connects and exchanges data"| node_basicserver
node_reactorentry4 -->|"initializes and runs"| node_reactor4
node_reactorentry5 -->|"initializes and runs"| node_reactor5
node_reactorentry5 -->|"logs lifecycle"| node_logger
node_signentry -->|"creates sign-in window"| node_signin
node_person -->|"uses account interface"| node_signin
node_person -->|"chats through GUI"| node_chatroom
node_tcpclient -->|"exchanges TCP data"| node_accountserver
node_accountserver -.->|"uses database"| node_mysql

click node_cli "https://github.com/liu-jianhao/chatroom/blob/master/dayOne/client.c"
click node_basicserver "https://github.com/liu-jianhao/chatroom/blob/master/dayOne/server.c"
click node_dialog "https://github.com/liu-jianhao/chatroom/blob/master/dayTwo/communication/dialog.cpp"
click node_gui "https://github.com/liu-jianhao/chatroom/blob/master/dayThree/TcpClient/tcpclient.cpp"
click node_guientry "https://github.com/liu-jianhao/chatroom/blob/master/dayThree/TcpClient/main.cpp"
click node_reactorentry4 "https://github.com/liu-jianhao/chatroom/blob/master/dayFour/main.cpp"
click node_reactor4 "https://github.com/liu-jianhao/chatroom/blob/master/dayFour/MyReactor.cpp"
click node_reactorentry5 "https://github.com/liu-jianhao/chatroom/blob/master/dayFive/main.cpp"
click node_reactor5 "https://github.com/liu-jianhao/chatroom/blob/master/dayFive/MyReactor.cpp"
click node_logger "https://github.com/liu-jianhao/chatroom/blob/master/dayFive/main.cpp"
click node_signentry "https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/main.cpp"
click node_signin "https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/sign.cpp"
click node_chatroom "https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/chatroom.cpp"
click node_tcpclient "https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/tcpclient.cpp"
click node_accountserver "https://github.com/liu-jianhao/chatroom/tree/master/daySix/Chat%2Bmysql"
click node_accountreactor "https://github.com/liu-jianhao/chatroom/blob/master/daySix/Chat%2Bmysql/MyReactor.cpp"

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_cli,node_basicserver toneBlue
class node_dialog,node_gui,node_guientry,node_mysql toneAmber
class node_reactorentry4,node_reactor4,node_reactorentry5,node_reactor5,node_logger toneMint
class node_signentry,node_signin,node_chatroom,node_tcpclient,node_accountserver,node_accountreactor toneRose
class node_person toneIndigo
```

## Components

### Socket Prototype

- [Terminal client](https://github.com/liu-jianhao/chatroom/blob/master/dayOne/client.c): `dayOne/client.c`
- [Basic chat server](https://github.com/liu-jianhao/chatroom/blob/master/dayOne/server.c): `dayOne/server.c`

### Qt Clients

- [TCP demo client](https://github.com/liu-jianhao/chatroom/blob/master/dayTwo/communication/dialog.cpp): `dayTwo/communication/dialog.cpp`
- [GUI chat client](https://github.com/liu-jianhao/chatroom/blob/master/dayThree/TcpClient/tcpclient.cpp): `dayThree/TcpClient/tcpclient.cpp`
- [GUI entry point](https://github.com/liu-jianhao/chatroom/blob/master/dayThree/TcpClient/main.cpp): `dayThree/TcpClient/main.cpp`

### Reactor Servers

- [Reactor entry point](https://github.com/liu-jianhao/chatroom/blob/master/dayFour/main.cpp): `dayFour/main.cpp`
- [Reactor server](https://github.com/liu-jianhao/chatroom/blob/master/dayFour/MyReactor.cpp): `dayFour/MyReactor.cpp`
- [Logged server entry](https://github.com/liu-jianhao/chatroom/blob/master/dayFive/main.cpp): `dayFive/main.cpp`
- [Logged Reactor](https://github.com/liu-jianhao/chatroom/blob/master/dayFive/MyReactor.cpp): `dayFive/MyReactor.cpp`
- [Server logging](https://github.com/liu-jianhao/chatroom/blob/master/dayFive/main.cpp): `dayFive/main.cpp`

### Account Chat

- [Account client entry](https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/main.cpp): `daySix/ChatRoom/main.cpp`
- [Sign-in interface](https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/sign.cpp): `daySix/ChatRoom/sign.cpp`
- [Chat interface](https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/chatroom.cpp): `daySix/ChatRoom/chatroom.cpp`
- [Qt chat transport](https://github.com/liu-jianhao/chatroom/blob/master/daySix/ChatRoom/tcpclient.cpp): `daySix/ChatRoom/tcpclient.cpp`
- [MySQL chat server](https://github.com/liu-jianhao/chatroom/tree/master/daySix/Chat%2Bmysql): `daySix/Chat+mysql`
- [Server Reactor](https://github.com/liu-jianhao/chatroom/blob/master/daySix/Chat%2Bmysql/MyReactor.cpp): `daySix/Chat+mysql/MyReactor.cpp`

### Other components

- **Chat participant**
- **MySQL database**

## Connections

- Chat participant → Terminal client: enters chat text
- Terminal client → Basic chat server: sends TCP messages
- Basic chat server → Terminal client: returns chat messages
- Chat participant → TCP demo client: uses client
- Chat participant → GUI chat client: uses client
- GUI entry point → GUI chat client: creates window
- GUI chat client → Basic chat server: connects and exchanges data
- Reactor entry point → Reactor server: initializes and runs
- Logged server entry → Logged Reactor: initializes and runs
- Logged server entry → Server logging: logs lifecycle
- Account client entry → Sign-in interface: creates sign-in window
- Chat participant → Sign-in interface: uses account interface
- Chat participant → Chat interface: chats through GUI
- Qt chat transport → MySQL chat server: exchanges TCP data
- MySQL chat server → MySQL database: uses database
