# beiginner777/im architecture

> Architecture diagram of the GitHub repository beiginner777/im, 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/beiginner777/im
- Repository: https://github.com/beiginner777/im

## Overview

This repository implements a multi-client chat system alongside a web-based flash-sale and order service. The principal chat workflow is login and service discovery, connection to a chat server, then message delivery with acknowledgement and persistence; friend discovery and file transfer are additional branches. The README documents the commerce endpoints, JWT authentication, and order states. Source excerpts are partial, so uncertain internal dispatch links are omitted; duplicate `server/` and `linux-server/` trees appear to represent parallel server implementations.

Main entry points: [`client/desktop/client1/core/mainwindow.cpp`](https://github.com/beiginner777/im/blob/main/client/desktop/client1/core/mainwindow.cpp) (Desktop client), [`server/SeckillServer/LogicSystem.cpp`](https://github.com/beiginner777/im/blob/main/server/SeckillServer/LogicSystem.cpp) (Commerce logic), [`server/AuthServer/LogicSystem.cpp`](https://github.com/beiginner777/im/blob/main/server/AuthServer/LogicSystem.cpp) (Auth logic), [`server/ChatServer1/LogicSystem.cpp`](https://github.com/beiginner777/im/blob/main/server/ChatServer1/LogicSystem.cpp) (Chat logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients"]
  node_react["React app<br/>[App.tsx]"]
  node_react_api["Web API client<br/>[index.ts]"]
  node_desktop["Desktop client<br/>[mainwindow.cpp]"]
  node_desktop_sqlite[("Local chat data<br/>[sqlitemanager.cpp]")]
end

subgraph group_identity["Identity and discovery"]
  node_auth["AuthServer<br/>[HttpConnection.cpp]"]
  node_auth_logic["Auth logic<br/>[LogicSystem.cpp]"]
  node_status["StatusServer<br/>[LogicSystem.cpp]"]
  node_status_grpc["Status gRPC client"]
end

subgraph group_messaging["Chat and resources"]
  node_chat["ChatServer<br/>[CSession.cpp]"]
  node_chat_logic["Chat logic<br/>[LogicSystem.cpp]"]
  node_batch_writer["Message writer"]
  node_resource["ResourceServer<br/>[LogicSystem.cpp]"]
  node_file_system["File handling<br/>[FileSystem.cpp]"]
end

subgraph group_commerce["Flash sale"]
  node_seckill["SeckillServer<br/>[HttpConnection.cpp]"]
  node_seckill_logic["Commerce logic<br/>[LogicSystem.cpp]"]
  node_payment_order["Orders and balance<br/>[LogicSystem.cpp]"]
end

subgraph group_infra["Shared state"]
  node_mysql[("MySQL")]
  node_redis[("Redis<br/>[RedisManager.cpp]")]
  node_auth_token["JWT utilities<br/>[JWT.cpp]"]
end

node_user(("User"))

node_user -->|"uses"| node_react
node_user -->|"uses"| node_desktop
node_react -->|"requests"| node_react_api
node_react_api -->|"auth requests"| node_auth
node_auth -->|"dispatches"| node_auth_logic
node_auth_logic -->|"reads and writes"| node_mysql
node_auth_logic -->|"signs tokens"| node_auth_token
node_auth_logic -->|"requests discovery"| node_status_grpc
node_status_grpc -->|"registers or queries"| node_status
node_desktop -->|"auth requests"| node_auth
node_desktop -->|"connects and chats"| node_chat
node_chat -->|"dispatches messages"| node_chat_logic
node_chat_logic -->|"queues persistence"| node_batch_writer
node_batch_writer -->|"batch writes"| node_mysql
node_chat_logic -->|"loads chat data"| node_mysql
node_chat_logic -->|"uses cache"| node_redis
node_desktop -->|"loads and saves local data"| node_desktop_sqlite
node_desktop -->|"uploads and downloads"| node_resource
node_resource -->|"handles files"| node_file_system
node_resource -->|"reads and writes metadata"| node_mysql
node_react_api -->|"commerce requests"| node_seckill
node_seckill -->|"dispatches"| node_seckill_logic
node_seckill_logic -->|"validates JWT"| node_auth_token
node_seckill_logic -->|"reads and writes orders"| node_mysql
node_seckill_logic -->|"uses Redis state"| node_redis
node_seckill_logic -->|"creates and updates"| node_payment_order

click node_react "https://github.com/beiginner777/im/blob/main/client/React/src/App.tsx"
click node_react_api "https://github.com/beiginner777/im/blob/main/client/React/src/api/index.ts"
click node_desktop "https://github.com/beiginner777/im/blob/main/client/desktop/client1/core/mainwindow.cpp"
click node_auth "https://github.com/beiginner777/im/blob/main/server/AuthServer/HttpConnection.cpp"
click node_auth_logic "https://github.com/beiginner777/im/blob/main/server/AuthServer/LogicSystem.cpp"
click node_status "https://github.com/beiginner777/im/blob/main/server/StatusServer/LogicSystem.cpp"
click node_chat "https://github.com/beiginner777/im/blob/main/server/ChatServer1/CSession.cpp"
click node_chat_logic "https://github.com/beiginner777/im/blob/main/server/ChatServer1/LogicSystem.cpp"
click node_batch_writer "https://github.com/beiginner777/im/blob/main/server/ChatServer1/BatchMessageWriter.cpp"
click node_resource "https://github.com/beiginner777/im/blob/main/server/ResourceServer/LogicSystem.cpp"
click node_file_system "https://github.com/beiginner777/im/blob/main/server/ResourceServer/FileSystem.cpp"
click node_seckill "https://github.com/beiginner777/im/blob/main/server/SeckillServer/HttpConnection.cpp"
click node_seckill_logic "https://github.com/beiginner777/im/blob/main/server/SeckillServer/LogicSystem.cpp"
click node_redis "https://github.com/beiginner777/im/blob/main/server/common/RedisManager.cpp"
click node_desktop_sqlite "https://github.com/beiginner777/im/blob/main/client/desktop/client1/data/sqlitemanager.cpp"
click node_status_grpc "https://github.com/beiginner777/im/blob/main/server/AuthServer/StatusGrpcClient.cpp"
click node_auth_token "https://github.com/beiginner777/im/blob/main/server/common/JWT.cpp"
click node_payment_order "https://github.com/beiginner777/im/blob/main/server/SeckillServer/LogicSystem.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_react,node_react_api,node_desktop,node_desktop_sqlite,node_user toneBlue
class node_auth,node_auth_logic,node_status,node_status_grpc toneAmber
class node_chat,node_chat_logic,node_batch_writer,node_resource,node_file_system toneMint
class node_seckill,node_seckill_logic,node_payment_order toneRose
class node_mysql,node_redis,node_auth_token toneIndigo
```

## Components

### Clients

- [React app](https://github.com/beiginner777/im/blob/main/client/React/src/App.tsx): `client/React/src/App.tsx`
- [Web API client](https://github.com/beiginner777/im/blob/main/client/React/src/api/index.ts): `client/React/src/api/index.ts`
- [Desktop client](https://github.com/beiginner777/im/blob/main/client/desktop/client1/core/mainwindow.cpp): `client/desktop/client1/core/mainwindow.cpp`
- [Local chat data](https://github.com/beiginner777/im/blob/main/client/desktop/client1/data/sqlitemanager.cpp): `client/desktop/client1/data/sqlitemanager.cpp`

### Identity and discovery

- [AuthServer](https://github.com/beiginner777/im/blob/main/server/AuthServer/HttpConnection.cpp): `server/AuthServer/HttpConnection.cpp`
- [Auth logic](https://github.com/beiginner777/im/blob/main/server/AuthServer/LogicSystem.cpp): `server/AuthServer/LogicSystem.cpp`
- [StatusServer](https://github.com/beiginner777/im/blob/main/server/StatusServer/LogicSystem.cpp): `server/StatusServer/LogicSystem.cpp`
- [Status gRPC client](https://github.com/beiginner777/im/blob/main/server/AuthServer/StatusGrpcClient.cpp): `server/AuthServer/StatusGrpcClient.cpp`

### Chat and resources

- [ChatServer](https://github.com/beiginner777/im/blob/main/server/ChatServer1/CSession.cpp): `server/ChatServer1/CSession.cpp`
- [Chat logic](https://github.com/beiginner777/im/blob/main/server/ChatServer1/LogicSystem.cpp): `server/ChatServer1/LogicSystem.cpp`
- [Message writer](https://github.com/beiginner777/im/blob/main/server/ChatServer1/BatchMessageWriter.cpp): `server/ChatServer1/BatchMessageWriter.cpp`
- [ResourceServer](https://github.com/beiginner777/im/blob/main/server/ResourceServer/LogicSystem.cpp): `server/ResourceServer/LogicSystem.cpp`
- [File handling](https://github.com/beiginner777/im/blob/main/server/ResourceServer/FileSystem.cpp): `server/ResourceServer/FileSystem.cpp`

### Flash sale

- [SeckillServer](https://github.com/beiginner777/im/blob/main/server/SeckillServer/HttpConnection.cpp): `server/SeckillServer/HttpConnection.cpp`
- [Commerce logic](https://github.com/beiginner777/im/blob/main/server/SeckillServer/LogicSystem.cpp): `server/SeckillServer/LogicSystem.cpp`
- [Orders and balance](https://github.com/beiginner777/im/blob/main/server/SeckillServer/LogicSystem.cpp): `server/SeckillServer/LogicSystem.cpp`

### Shared state

- **MySQL**
- [Redis](https://github.com/beiginner777/im/blob/main/server/common/RedisManager.cpp): `server/common/RedisManager.cpp`
- [JWT utilities](https://github.com/beiginner777/im/blob/main/server/common/JWT.cpp): `server/common/JWT.cpp`

### Other components

- **User**

## Connections

- User → React app: uses
- User → Desktop client: uses
- React app → Web API client: requests
- Web API client → AuthServer: auth requests
- AuthServer → Auth logic: dispatches
- Auth logic → MySQL: reads and writes
- Auth logic → JWT utilities: signs tokens
- Auth logic → Status gRPC client: requests discovery
- Status gRPC client → StatusServer: registers or queries
- Desktop client → AuthServer: auth requests
- Desktop client → ChatServer: connects and chats
- ChatServer → Chat logic: dispatches messages
- Chat logic → Message writer: queues persistence
- Message writer → MySQL: batch writes
- Chat logic → MySQL: loads chat data
- Chat logic → Redis: uses cache
- Desktop client → Local chat data: loads and saves local data
- Desktop client → ResourceServer: uploads and downloads
- ResourceServer → File handling: handles files
- ResourceServer → MySQL: reads and writes metadata
- Web API client → SeckillServer: commerce requests
- SeckillServer → Commerce logic: dispatches
- Commerce logic → JWT utilities: validates JWT
- Commerce logic → MySQL: reads and writes orders
- Commerce logic → Redis: uses Redis state
- Commerce logic → Orders and balance: creates and updates
