# youngyangyang04/cppaiservice architecture

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

- Interactive diagram: https://gitdiagram.com/youngyangyang04/cppaiservice
- Repository: https://github.com/youngyangyang04/cppaiservice

## Overview

This is a C++ AI application service platform built on a custom HTTP server. The main workflow is client request → ChatServer routing → domain handler → conversational or multimodal AI capability → response; conversation and account operations also use MySQL, while message persistence can be queued. The README documents RAG, MCP-style tools, multiple model providers, speech, image recognition, and multi-session isolation. Some of these implementations were not sampled, so their internal connections are omitted or shown as unverified.

Main entry points: [`AIApps/ChatServer/src/handlers`](https://github.com/youngyangyang04/cppaiservice/tree/main/AIApps/ChatServer/src/handlers) (Request handlers), [`AIApps/ChatServer/include/AIUtil/AIHelper.h`](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/include/AIUtil/AIHelper.h) (Conversation context), [`AIApps/ChatServer/src/ChatServer.cpp`](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/ChatServer.cpp) (ChatServer), [`HttpServer/src/http/HttpServer.cpp`](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/http/HttpServer.cpp) (HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service["Application service"]
  node_chatserver["ChatServer<br/>[ChatServer.cpp]"]
  node_handlers["Request handlers"]
  node_auth["Account access"]
  node_chat["Chat sessions"]
  node_history["Chat history"]
  node_uploads["AI uploads"]
  node_speechhandler["Speech requests"]
end

subgraph group_http["HTTP framework"]
  node_httpserver["HTTP server<br/>[HttpServer.cpp]"]
  node_router["Request router<br/>[Router.cpp]"]
  node_request["HTTP request<br/>[HttpRequest.h]"]
  node_response["HTTP response<br/>[HttpResponse.h]"]
  node_sessions["HTTP sessions<br/>[SessionManager.cpp]"]
  node_sessionstore[("Memory session store<br/>[SessionStorage.cpp]")]
end

subgraph group_ai["AI capabilities"]
  node_aihelper["Conversation context<br/>[AIHelper.h]"]
  node_strategy["Model strategies<br/>[AIStrategy.cpp]"]
  node_tools["Tool registry<br/>[AIToolRegistry.cpp]"]
  node_rag["RAG pipeline"]
  node_image["Image recognition"]
  node_speech["Speech processing"]
end

subgraph group_state["State and persistence"]
  node_mysql["MySQL access<br/>[MysqlUtil.h]"]
  node_dbpool["DB connection pool"]
  node_mqmanager["Message queue manager<br/>[MQManager.cpp]"]
end

subgraph group_integrations["External integrations"]
  node_database[("MySQL database")]
  node_rabbitmq["RabbitMQ"]
  node_modelapis["Model provider APIs"]
  node_speechapis["Speech APIs"]
  node_visionruntime["Vision runtime"]
end

node_client(("API client"))

node_client -->|"sends request"| node_httpserver
node_httpserver -.->|"routes request"| node_router
node_router -.->|"dispatches"| node_handlers
node_chatserver -->|"dispatches to"| node_handlers
node_handlers -.->|"handles access"| node_auth
node_handlers -.->|"handles chat"| node_chat
node_handlers -.->|"handles history"| node_history
node_handlers -.->|"handles uploads"| node_uploads
node_handlers -.->|"handles speech"| node_speechhandler
node_chatserver -->|"manages contexts"| node_aihelper
node_chat -.->|"uses context"| node_aihelper
node_aihelper -->|"uses strategy"| node_strategy
node_strategy -->|"calls provider"| node_modelapis
node_aihelper -->|"supports tool flow"| node_tools
node_aihelper -->|"supports retrieval"| node_rag
node_uploads -.->|"uses recognition"| node_image
node_image -->|"runs inference"| node_visionruntime
node_speechhandler -.->|"uses processor"| node_speech
node_speech -->|"calls speech API"| node_speechapis
node_chatserver -->|"reads and writes"| node_mysql
node_auth -->|"queries accounts"| node_mysql
node_mysql -->|"gets connection"| node_dbpool
node_dbpool -.->|"queries"| node_database
node_chatserver -->|"queues persistence"| node_mqmanager
node_mqmanager -->|"publishes messages"| node_rabbitmq
node_sessions -->|"stores sessions"| node_sessionstore
node_httpserver -.->|"manages sessions"| node_sessions

click node_chatserver "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/ChatServer.cpp"
click node_handlers "https://github.com/youngyangyang04/cppaiservice/tree/main/AIApps/ChatServer/src/handlers"
click node_auth "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatLoginHandler.cpp"
click node_chat "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatCreateAndSendHandler.cpp"
click node_history "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatHistoryHandler.cpp"
click node_uploads "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/AIUploadSendHandler.cpp"
click node_speechhandler "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatSpeechHandler.cpp"
click node_httpserver "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/http/HttpServer.cpp"
click node_router "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/router/Router.cpp"
click node_request "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/include/http/HttpRequest.h"
click node_response "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/include/http/HttpResponse.h"
click node_sessions "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/session/SessionManager.cpp"
click node_sessionstore "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/session/SessionStorage.cpp"
click node_aihelper "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/include/AIUtil/AIHelper.h"
click node_strategy "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/AIStrategy.cpp"
click node_tools "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/AIToolRegistry.cpp"
click node_rag "https://github.com/youngyangyang04/cppaiservice/tree/main/AIApps/ChatServer/src/AIUtil"
click node_image "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/ImageRecognizer.cpp"
click node_speech "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/AISpeechProcessor.cpp"
click node_mysql "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/include/utils/MysqlUtil.h"
click node_dbpool "https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/utils/db/DbConnectionPool.cpp"
click node_mqmanager "https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/MQManager.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_chatserver,node_handlers,node_auth,node_chat,node_history,node_uploads,node_speechhandler,node_client toneBlue
class node_httpserver,node_router,node_request,node_response,node_sessions,node_sessionstore toneAmber
class node_aihelper,node_strategy,node_tools,node_rag,node_image,node_speech toneMint
class node_mysql,node_dbpool,node_mqmanager toneRose
class node_database,node_rabbitmq,node_modelapis,node_speechapis,node_visionruntime toneIndigo
```

## Components

### Application service

- [ChatServer](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/ChatServer.cpp): `AIApps/ChatServer/src/ChatServer.cpp`
- [Request handlers](https://github.com/youngyangyang04/cppaiservice/tree/main/AIApps/ChatServer/src/handlers): `AIApps/ChatServer/src/handlers`
- [Account access](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatLoginHandler.cpp): `AIApps/ChatServer/src/handlers/ChatLoginHandler.cpp`
- [Chat sessions](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatCreateAndSendHandler.cpp): `AIApps/ChatServer/src/handlers/ChatCreateAndSendHandler.cpp`
- [Chat history](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatHistoryHandler.cpp): `AIApps/ChatServer/src/handlers/ChatHistoryHandler.cpp`
- [AI uploads](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/AIUploadSendHandler.cpp): `AIApps/ChatServer/src/handlers/AIUploadSendHandler.cpp`
- [Speech requests](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/handlers/ChatSpeechHandler.cpp): `AIApps/ChatServer/src/handlers/ChatSpeechHandler.cpp`

### HTTP framework

- [HTTP server](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/http/HttpServer.cpp): `HttpServer/src/http/HttpServer.cpp`
- [Request router](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/router/Router.cpp): `HttpServer/src/router/Router.cpp`
- [HTTP request](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/include/http/HttpRequest.h): `HttpServer/include/http/HttpRequest.h`
- [HTTP response](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/include/http/HttpResponse.h): `HttpServer/include/http/HttpResponse.h`
- [HTTP sessions](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/session/SessionManager.cpp): `HttpServer/src/session/SessionManager.cpp`
- [Memory session store](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/session/SessionStorage.cpp): `HttpServer/src/session/SessionStorage.cpp`

### AI capabilities

- [Conversation context](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/include/AIUtil/AIHelper.h): `AIApps/ChatServer/include/AIUtil/AIHelper.h`
- [Model strategies](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/AIStrategy.cpp): `AIApps/ChatServer/src/AIUtil/AIStrategy.cpp`
- [Tool registry](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/AIToolRegistry.cpp): `AIApps/ChatServer/src/AIUtil/AIToolRegistry.cpp`
- [RAG pipeline](https://github.com/youngyangyang04/cppaiservice/tree/main/AIApps/ChatServer/src/AIUtil): `AIApps/ChatServer/src/AIUtil`
- [Image recognition](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/ImageRecognizer.cpp): `AIApps/ChatServer/src/AIUtil/ImageRecognizer.cpp`
- [Speech processing](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/AISpeechProcessor.cpp): `AIApps/ChatServer/src/AIUtil/AISpeechProcessor.cpp`

### State and persistence

- [MySQL access](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/include/utils/MysqlUtil.h): `HttpServer/include/utils/MysqlUtil.h`
- [DB connection pool](https://github.com/youngyangyang04/cppaiservice/blob/main/HttpServer/src/utils/db/DbConnectionPool.cpp): `HttpServer/src/utils/db/DbConnectionPool.cpp`
- [Message queue manager](https://github.com/youngyangyang04/cppaiservice/blob/main/AIApps/ChatServer/src/AIUtil/MQManager.cpp): `AIApps/ChatServer/src/AIUtil/MQManager.cpp`

### External integrations

- **MySQL database**
- **RabbitMQ**
- **Model provider APIs**
- **Speech APIs**
- **Vision runtime**

### Other components

- **API client**

## Connections

- API client → HTTP server: sends request (evidence: `README.md`)
- HTTP server → Request router: routes request
- Request router → Request handlers: dispatches
- ChatServer → Request handlers: dispatches to (evidence: `README.md`)
- Request handlers → Account access: handles access
- Request handlers → Chat sessions: handles chat
- Request handlers → Chat history: handles history
- Request handlers → AI uploads: handles uploads
- Request handlers → Speech requests: handles speech
- ChatServer → Conversation context: manages contexts
- Chat sessions → Conversation context: uses context
- Conversation context → Model strategies: uses strategy (evidence: `README.md`)
- Model strategies → Model provider APIs: calls provider (evidence: `README.md`)
- Conversation context → Tool registry: supports tool flow (evidence: `README.md`)
- Conversation context → RAG pipeline: supports retrieval (evidence: `README.md`)
- AI uploads → Image recognition: uses recognition
- Image recognition → Vision runtime: runs inference (evidence: `README.md`)
- Speech requests → Speech processing: uses processor
- Speech processing → Speech APIs: calls speech API (evidence: `README.md`)
- ChatServer → MySQL access: reads and writes
- Account access → MySQL access: queries accounts
- MySQL access → DB connection pool: gets connection (evidence: `HttpServer/include/utils/MysqlUtil.h`)
- DB connection pool → MySQL database: queries
- ChatServer → Message queue manager: queues persistence (evidence: `README.md`)
- Message queue manager → RabbitMQ: publishes messages
- HTTP sessions → Memory session store: stores sessions
- HTTP server → HTTP sessions: manages sessions
