# chanzhaoyu/chatgpt-web architecture

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

- Interactive diagram: https://gitdiagram.com/chanzhaoyu/chatgpt-web
- Repository: https://github.com/chanzhaoyu/chatgpt-web

## Overview

ChatGPT Web is a Vue chat application backed by an Express service. A user submits a prompt in the chat view; the frontend sends it through its API client, and the service applies access and rate-limit middleware before streaming a model response back. Chat sessions and preferences are managed in frontend stores and local storage. The README documents both OpenAI API-key and unofficial access-token model modes, plus prompt-template management, import/export, themes, multilingual UI, and access control. Some frontend and provider connections are inferred from the product description or tree and are marked unverified where appropriate.

Main entry points: [`src/views/chat/index.vue`](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/index.vue) (Chat view), [`service/src/index.ts`](https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/index.ts) (HTTP service), [`src/store/modules/chat/index.ts`](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/store/modules/chat/index.ts) (Chat sessions), [`src/router/index.ts`](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/router/index.ts) (Router and guards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web runtime"]
  node_app["App shell<br/>[App.vue]"]
  node_router["Router and guards<br/>[index.ts]"]
  node_permission["Page permission<br/>[permission.ts]"]
  node_request["HTTP request layer<br/>[axios.ts]"]
end

subgraph group_chat["Chat experience"]
  node_chat_view["Chat view<br/>[index.vue]"]
  node_chat_api["Chat API client<br/>[index.ts]"]
  node_chat_hooks["Chat actions<br/>[useChat.ts]"]
  node_context["Context toggle<br/>[useUsingContext.ts]"]
  node_scroll["Scroll handling<br/>[useScroll.ts]"]
  node_messages["Message rendering<br/>[index.vue]"]
  node_sidebar["Session sidebar<br/>[List.vue]"]
end

subgraph group_state["State and preferences"]
  node_chat_store["Chat sessions<br/>[index.ts]"]
  node_storage[("Local storage<br/>[index.ts]")]
  node_settings["Settings UI<br/>[General.vue]"]
  node_prompt_store["Prompt templates<br/>[index.vue]"]
  node_theme["Theme and language<br/>[useTheme.ts]"]
  node_layout["Responsive layout<br/>[useBasicLayout.ts]"]
end

subgraph group_service["Chat service"]
  node_service_entry["HTTP service<br/>[index.ts]"]
  node_auth["Access control<br/>[auth.ts]"]
  node_limiter["Request limiter<br/>[limiter.ts]"]
  node_model["Model adapters<br/>[index.ts]"]
  node_service_utils["Service utilities<br/>[is.ts]"]
end

node_user(("User"))
node_openai{{"OpenAI API"}}
node_proxy{{"Unofficial proxy"}}

node_user -->|"submits prompt"| node_chat_view
node_chat_view -->|"requests reply"| node_chat_api
node_chat_api -->|"uses client"| node_request
node_chat_api -->|"reads session"| node_chat_store
node_chat_view -->|"uses actions"| node_chat_hooks
node_chat_view -->|"uses toggle"| node_context
node_context -->|"updates context"| node_chat_store
node_chat_view -->|"uses scrolling"| node_scroll
node_chat_view -->|"renders messages"| node_messages
node_sidebar -.->|"manages sessions"| node_chat_store
node_chat_store -->|"persists sessions"| node_storage
node_settings -.->|"persists preferences"| node_storage
node_prompt_store -.->|"persists templates"| node_storage
node_app -->|"applies theme"| node_theme
node_app -.->|"renders routes"| node_router
node_router -->|"sets guard"| node_permission
node_router -->|"routes to"| node_chat_view
node_request -.->|"sends requests"| node_service_entry
node_service_entry -->|"checks access"| node_auth
node_service_entry -->|"limits chat"| node_limiter
node_service_entry -->|"streams reply"| node_model
node_service_entry -->|"checks values"| node_service_utils
node_model -.->|"supports API mode"| node_openai
node_model -.->|"supports token mode"| node_proxy

click node_app "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/App.vue"
click node_router "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/router/index.ts"
click node_permission "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/router/permission.ts"
click node_chat_view "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/index.vue"
click node_chat_api "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/api/index.ts"
click node_chat_hooks "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/hooks/useChat.ts"
click node_context "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/hooks/useUsingContext.ts"
click node_scroll "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/hooks/useScroll.ts"
click node_messages "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/components/Message/index.vue"
click node_sidebar "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/layout/sider/List.vue"
click node_chat_store "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/store/modules/chat/index.ts"
click node_storage "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/utils/storage/index.ts"
click node_settings "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/components/common/Setting/General.vue"
click node_prompt_store "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/components/common/PromptStore/index.vue"
click node_theme "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/hooks/useTheme.ts"
click node_layout "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/hooks/useBasicLayout.ts"
click node_request "https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/utils/request/axios.ts"
click node_service_entry "https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/index.ts"
click node_auth "https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/middleware/auth.ts"
click node_limiter "https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/middleware/limiter.ts"
click node_model "https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/chatgpt/index.ts"
click node_service_utils "https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/utils/is.ts"

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_router,node_permission,node_request,node_user toneBlue
class node_chat_view,node_chat_api,node_chat_hooks,node_context,node_scroll,node_messages,node_sidebar toneAmber
class node_chat_store,node_storage,node_settings,node_prompt_store,node_theme,node_layout,node_openai toneMint
class node_service_entry,node_auth,node_limiter,node_model,node_service_utils toneRose
class node_proxy toneIndigo
```

## Components

### Web runtime

- [App shell](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/App.vue): `src/App.vue`
- [Router and guards](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/router/index.ts): `src/router/index.ts`
- [Page permission](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/router/permission.ts): `src/router/permission.ts`
- [HTTP request layer](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/utils/request/axios.ts): `src/utils/request/axios.ts`

### Chat experience

- [Chat view](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/index.vue): `src/views/chat/index.vue`
- [Chat API client](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/api/index.ts): `src/api/index.ts`
- [Chat actions](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/hooks/useChat.ts): `src/views/chat/hooks/useChat.ts`
- [Context toggle](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/hooks/useUsingContext.ts): `src/views/chat/hooks/useUsingContext.ts`
- [Scroll handling](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/hooks/useScroll.ts): `src/views/chat/hooks/useScroll.ts`
- [Message rendering](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/components/Message/index.vue): `src/views/chat/components/Message/index.vue`
- [Session sidebar](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/views/chat/layout/sider/List.vue): `src/views/chat/layout/sider/List.vue`

### State and preferences

- [Chat sessions](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/store/modules/chat/index.ts): `src/store/modules/chat/index.ts`
- [Local storage](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/utils/storage/index.ts): `src/utils/storage/index.ts`
- [Settings UI](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/components/common/Setting/General.vue): `src/components/common/Setting/General.vue`
- [Prompt templates](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/components/common/PromptStore/index.vue): `src/components/common/PromptStore/index.vue`
- [Theme and language](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/hooks/useTheme.ts): `src/hooks/useTheme.ts`
- [Responsive layout](https://github.com/chanzhaoyu/chatgpt-web/blob/main/src/hooks/useBasicLayout.ts): `src/hooks/useBasicLayout.ts`

### Chat service

- [HTTP service](https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/index.ts): `service/src/index.ts`
- [Access control](https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/middleware/auth.ts): `service/src/middleware/auth.ts`
- [Request limiter](https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/middleware/limiter.ts): `service/src/middleware/limiter.ts`
- [Model adapters](https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/chatgpt/index.ts): `service/src/chatgpt/index.ts`
- [Service utilities](https://github.com/chanzhaoyu/chatgpt-web/blob/main/service/src/utils/is.ts): `service/src/utils/is.ts`

### Other components

- **User**
- **OpenAI API**
- **Unofficial proxy**

## Connections

- User → Chat view: submits prompt (evidence: `src/views/chat/index.vue`)
- Chat view → Chat API client: requests reply (evidence: `src/views/chat/index.vue`)
- Chat API client → HTTP request layer: uses client (evidence: `src/api/index.ts`)
- Chat API client → Chat sessions: reads session (evidence: `src/api/index.ts`)
- Chat view → Chat actions: uses actions (evidence: `src/views/chat/index.vue`)
- Chat view → Context toggle: uses toggle (evidence: `src/views/chat/index.vue`)
- Context toggle → Chat sessions: updates context (evidence: `src/views/chat/hooks/useUsingContext.ts`)
- Chat view → Scroll handling: uses scrolling (evidence: `src/views/chat/index.vue`)
- Chat view → Message rendering: renders messages (evidence: `src/views/chat/index.vue`)
- Session sidebar → Chat sessions: manages sessions
- Chat sessions → Local storage: persists sessions (evidence: `src/store/modules/chat/index.ts`)
- Settings UI → Local storage: persists preferences
- Prompt templates → Local storage: persists templates
- App shell → Theme and language: applies theme (evidence: `src/App.vue`)
- App shell → Router and guards: renders routes
- Router and guards → Page permission: sets guard (evidence: `src/router/index.ts`)
- Router and guards → Chat view: routes to (evidence: `src/router/index.ts`)
- HTTP request layer → HTTP service: sends requests
- HTTP service → Access control: checks access (evidence: `service/src/index.ts`)
- HTTP service → Request limiter: limits chat (evidence: `service/src/index.ts`)
- HTTP service → Model adapters: streams reply (evidence: `service/src/index.ts`)
- HTTP service → Service utilities: checks values (evidence: `service/src/index.ts`)
- Model adapters → OpenAI API: supports API mode (evidence: `README.md`)
- Model adapters → Unofficial proxy: supports token mode (evidence: `README.md`)
