# wsss777/wsai architecture

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

- Interactive diagram: https://gitdiagram.com/wsss777/wsai
- Repository: https://github.com/wsss777/wsai

## Overview

WsAI is an AI conversation and knowledge-document platform. Users authenticate, upload and manage documents, bind documents to a chat session, and send messages through streaming chat; the backend exposes these capabilities through authenticated HTTP routes. The frontend API client and backend router establish the HTTP boundary. Source excerpts do not show most application-to-infrastructure calls, so uncertain internal connections are omitted; major RAG and persistence stages are represented without asserting unverified call sequences.

Main entry points: [`backend/handler/router.go`](https://github.com/wsss777/wsai/blob/master/backend/handler/router.go) (HTTP router), [`frontend/src/App.vue`](https://github.com/wsss777/wsai/blob/master/frontend/src/App.vue) (Vue application), [`backend/application/session/session.go`](https://github.com/wsss777/wsai/blob/master/backend/application/session/session.go) (Session application), [`frontend/src/services/api.js`](https://github.com/wsss777/wsai/blob/master/frontend/src/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web frontend"]
  node_app["Vue application<br/>[App.vue]"]
  node_auth_view["Account access<br/>[AuthView.vue]"]
  node_chat_view["Streaming chat<br/>[ChatView.vue]"]
  node_documents_view["Document workspace<br/>[DocumentsView.vue]"]
  node_auth_store["Auth state<br/>[auth.js]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_http["HTTP interface"]
  node_server["Backend server<br/>[main.go]"]
  node_router["HTTP router<br/>[router.go]"]
  node_user_handler["Account endpoints<br/>[user.go]"]
  node_session_handler["Chat endpoints<br/>[session.go]"]
  node_rag_handler["Document endpoints<br/>[document.go]"]
  node_image_handler["Image endpoint<br/>[image.go]"]
end

subgraph group_rag["Knowledge pipeline"]
  node_doc_application["Document management"]
  node_ingest["Document ingestion"]
  node_parser["Document parsing<br/>[parser.go]"]
  node_chunker["Text chunking<br/>[chunker.go]"]
  node_query_planner["Query planning"]
  node_retrieval["Context retrieval"]
end

subgraph group_services["Application services"]
  node_session_app["Session application<br/>[session.go]"]
  node_user_app["User application<br/>[user.go]"]
  node_image_app["Image application<br/>[image.go]"]
end

subgraph group_infra["Infrastructure"]
  node_llm["Model integration<br/>[aiModel.go]"]
  node_helper_manager["Chat helper manager<br/>[helperManager.go]"]
  node_rag_client["RAG client<br/>[client.go]"]
  node_mysql[("MySQL repositories")]
  node_redis[("Redis client<br/>[client.go]")]
  node_rabbitmq["RabbitMQ client<br/>[client.go]"]
end

node_user(("Platform user"))

node_user -->|"uses"| node_app
node_app -->|"routes"| node_auth_view
node_app -->|"routes"| node_chat_view
node_app -->|"routes"| node_documents_view
node_auth_view -->|"calls"| node_api_client
node_auth_view -->|"updates"| node_auth_store
node_api_client -->|"reads token"| node_auth_store
node_chat_view -.->|"requests chat"| node_api_client
node_documents_view -.->|"requests documents"| node_api_client
node_server -->|"initializes"| node_router
node_router -->|"routes account"| node_user_handler
node_router -->|"routes chat"| node_session_handler
node_router -->|"routes documents"| node_rag_handler
node_router -->|"routes images"| node_image_handler
node_rag_handler -.->|"delegates"| node_doc_application
node_doc_application -.->|"delegates"| node_ingest
node_ingest -.->|"parses"| node_parser
node_ingest -.->|"chunks"| node_chunker
node_session_handler -.->|"delegates"| node_session_app
node_user_handler -.->|"delegates"| node_user_app
node_image_handler -.->|"delegates"| node_image_app
node_session_app -.->|"plans retrieval"| node_query_planner
node_query_planner -->|"creates model"| node_llm
node_session_app -.->|"retrieves context"| node_retrieval
node_retrieval -.->|"queries"| node_rag_client
node_session_app -.->|"manages helpers"| node_helper_manager
node_helper_manager -->|"loads messages"| node_mysql

click node_app "https://github.com/wsss777/wsai/blob/master/frontend/src/App.vue"
click node_auth_view "https://github.com/wsss777/wsai/blob/master/frontend/src/views/AuthView.vue"
click node_chat_view "https://github.com/wsss777/wsai/blob/master/frontend/src/views/ChatView.vue"
click node_documents_view "https://github.com/wsss777/wsai/blob/master/frontend/src/views/DocumentsView.vue"
click node_auth_store "https://github.com/wsss777/wsai/blob/master/frontend/src/stores/auth.js"
click node_api_client "https://github.com/wsss777/wsai/blob/master/frontend/src/services/api.js"
click node_server "https://github.com/wsss777/wsai/blob/master/backend/cmd/server/main.go"
click node_router "https://github.com/wsss777/wsai/blob/master/backend/handler/router.go"
click node_user_handler "https://github.com/wsss777/wsai/blob/master/backend/handler/user/user.go"
click node_session_handler "https://github.com/wsss777/wsai/blob/master/backend/handler/session/session.go"
click node_rag_handler "https://github.com/wsss777/wsai/blob/master/backend/handler/rag/document.go"
click node_image_handler "https://github.com/wsss777/wsai/blob/master/backend/handler/image/image.go"
click node_doc_application "https://github.com/wsss777/wsai/blob/master/backend/application/rag/document_application.go"
click node_ingest "https://github.com/wsss777/wsai/blob/master/backend/application/rag/ingest_application.go"
click node_parser "https://github.com/wsss777/wsai/blob/master/backend/domain/rag/parser.go"
click node_chunker "https://github.com/wsss777/wsai/blob/master/backend/domain/rag/chunker.go"
click node_query_planner "https://github.com/wsss777/wsai/blob/master/backend/application/rag/query_preprocessor.go"
click node_retrieval "https://github.com/wsss777/wsai/blob/master/backend/application/rag/retrieval_application.go"
click node_session_app "https://github.com/wsss777/wsai/blob/master/backend/application/session/session.go"
click node_user_app "https://github.com/wsss777/wsai/blob/master/backend/application/user/user.go"
click node_image_app "https://github.com/wsss777/wsai/blob/master/backend/application/image/image.go"
click node_llm "https://github.com/wsss777/wsai/blob/master/backend/infra/llm/aiModel.go"
click node_helper_manager "https://github.com/wsss777/wsai/blob/master/backend/infra/llm/helperManager.go"
click node_rag_client "https://github.com/wsss777/wsai/blob/master/backend/infra/rag/client.go"
click node_mysql "https://github.com/wsss777/wsai/tree/master/backend/infra/mysql/repository"
click node_redis "https://github.com/wsss777/wsai/blob/master/backend/infra/redis/client.go"
click node_rabbitmq "https://github.com/wsss777/wsai/blob/master/backend/infra/rabbitmq/client.go"

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_auth_view,node_chat_view,node_documents_view,node_auth_store,node_api_client,node_user toneBlue
class node_server,node_router,node_user_handler,node_session_handler,node_rag_handler,node_image_handler toneAmber
class node_doc_application,node_ingest,node_parser,node_chunker,node_query_planner,node_retrieval toneMint
class node_session_app,node_user_app,node_image_app toneRose
class node_llm,node_helper_manager,node_rag_client,node_mysql,node_redis,node_rabbitmq toneIndigo
```

## Components

### Web frontend

- [Vue application](https://github.com/wsss777/wsai/blob/master/frontend/src/App.vue): `frontend/src/App.vue`
- [Account access](https://github.com/wsss777/wsai/blob/master/frontend/src/views/AuthView.vue): `frontend/src/views/AuthView.vue`
- [Streaming chat](https://github.com/wsss777/wsai/blob/master/frontend/src/views/ChatView.vue): `frontend/src/views/ChatView.vue`
- [Document workspace](https://github.com/wsss777/wsai/blob/master/frontend/src/views/DocumentsView.vue): `frontend/src/views/DocumentsView.vue`
- [Auth state](https://github.com/wsss777/wsai/blob/master/frontend/src/stores/auth.js): `frontend/src/stores/auth.js`
- [API client](https://github.com/wsss777/wsai/blob/master/frontend/src/services/api.js): `frontend/src/services/api.js`

### HTTP interface

- [Backend server](https://github.com/wsss777/wsai/blob/master/backend/cmd/server/main.go): `backend/cmd/server/main.go`
- [HTTP router](https://github.com/wsss777/wsai/blob/master/backend/handler/router.go): `backend/handler/router.go`
- [Account endpoints](https://github.com/wsss777/wsai/blob/master/backend/handler/user/user.go): `backend/handler/user/user.go`
- [Chat endpoints](https://github.com/wsss777/wsai/blob/master/backend/handler/session/session.go): `backend/handler/session/session.go`
- [Document endpoints](https://github.com/wsss777/wsai/blob/master/backend/handler/rag/document.go): `backend/handler/rag/document.go`
- [Image endpoint](https://github.com/wsss777/wsai/blob/master/backend/handler/image/image.go): `backend/handler/image/image.go`

### Knowledge pipeline

- [Document management](https://github.com/wsss777/wsai/blob/master/backend/application/rag/document_application.go): `backend/application/rag/document_application.go`
- [Document ingestion](https://github.com/wsss777/wsai/blob/master/backend/application/rag/ingest_application.go): `backend/application/rag/ingest_application.go`
- [Document parsing](https://github.com/wsss777/wsai/blob/master/backend/domain/rag/parser.go): `backend/domain/rag/parser.go`
- [Text chunking](https://github.com/wsss777/wsai/blob/master/backend/domain/rag/chunker.go): `backend/domain/rag/chunker.go`
- [Query planning](https://github.com/wsss777/wsai/blob/master/backend/application/rag/query_preprocessor.go): `backend/application/rag/query_preprocessor.go`
- [Context retrieval](https://github.com/wsss777/wsai/blob/master/backend/application/rag/retrieval_application.go): `backend/application/rag/retrieval_application.go`

### Application services

- [Session application](https://github.com/wsss777/wsai/blob/master/backend/application/session/session.go): `backend/application/session/session.go`
- [User application](https://github.com/wsss777/wsai/blob/master/backend/application/user/user.go): `backend/application/user/user.go`
- [Image application](https://github.com/wsss777/wsai/blob/master/backend/application/image/image.go): `backend/application/image/image.go`

### Infrastructure

- [Model integration](https://github.com/wsss777/wsai/blob/master/backend/infra/llm/aiModel.go): `backend/infra/llm/aiModel.go`
- [Chat helper manager](https://github.com/wsss777/wsai/blob/master/backend/infra/llm/helperManager.go): `backend/infra/llm/helperManager.go`
- [RAG client](https://github.com/wsss777/wsai/blob/master/backend/infra/rag/client.go): `backend/infra/rag/client.go`
- [MySQL repositories](https://github.com/wsss777/wsai/tree/master/backend/infra/mysql/repository): `backend/infra/mysql/repository`
- [Redis client](https://github.com/wsss777/wsai/blob/master/backend/infra/redis/client.go): `backend/infra/redis/client.go`
- [RabbitMQ client](https://github.com/wsss777/wsai/blob/master/backend/infra/rabbitmq/client.go): `backend/infra/rabbitmq/client.go`

### Other components

- **Platform user**

## Connections

- Platform user → Vue application: uses
- Vue application → Account access: routes
- Vue application → Streaming chat: routes
- Vue application → Document workspace: routes
- Account access → API client: calls (evidence: `frontend/src/views/AuthView.vue`)
- Account access → Auth state: updates (evidence: `frontend/src/views/AuthView.vue`)
- API client → Auth state: reads token (evidence: `frontend/src/services/api.js`)
- Streaming chat → API client: requests chat
- Document workspace → API client: requests documents
- Backend server → HTTP router: initializes (evidence: `backend/cmd/server/main.go`)
- HTTP router → Account endpoints: routes account (evidence: `backend/handler/router.go`)
- HTTP router → Chat endpoints: routes chat (evidence: `backend/handler/router.go`)
- HTTP router → Document endpoints: routes documents (evidence: `backend/handler/router.go`)
- HTTP router → Image endpoint: routes images (evidence: `backend/handler/router.go`)
- Document endpoints → Document management: delegates
- Document management → Document ingestion: delegates
- Document ingestion → Document parsing: parses
- Document ingestion → Text chunking: chunks
- Chat endpoints → Session application: delegates
- Account endpoints → User application: delegates
- Image endpoint → Image application: delegates
- Session application → Query planning: plans retrieval
- Query planning → Model integration: creates model (evidence: `backend/application/rag/query_preprocessor.go`)
- Session application → Context retrieval: retrieves context
- Context retrieval → RAG client: queries
- Session application → Chat helper manager: manages helpers
- Chat helper manager → MySQL repositories: loads messages (evidence: `backend/infra/llm/helperManager.go`)
