How chanzhaoyu/chatgpt-web works
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: index.vue Chat view · src/index.ts HTTP service · chat/index.ts Chat sessions · router/index.ts Router and guards
Components 25
Web runtime
- App shell
src/App.vue - Router and guards
src/router/index.ts - Page permission
src/router/permission.ts - HTTP request layer
src/utils/request/axios.ts
Chat experience
- Chat view
src/views/chat/index.vue - Chat API client
src/api/index.ts - Chat actions
src/views/chat/hooks/useChat.ts - Context toggle
src/views/chat/hooks/useUsingContext.ts - Scroll handling
src/views/chat/hooks/useScroll.ts - Message rendering
src/views/chat/components/Message/index.vue - Session sidebar
src/views/chat/layout/sider/List.vue
State and preferences
- Chat sessions
src/store/modules/chat/index.ts - Local storage
src/utils/storage/index.ts - Settings UI
src/components/common/Setting/General.vue - Prompt templates
src/components/common/PromptStore/index.vue - Theme and language
src/hooks/useTheme.ts - Responsive layout
src/hooks/useBasicLayout.ts
Chat service
- HTTP service
service/src/index.ts - Access control
service/src/middleware/auth.ts - Request limiter
service/src/middleware/limiter.ts - Model adapters
service/src/chatgpt/index.ts - Service utilities
service/src/utils/is.ts
Other components
- User
- OpenAI API
- Unofficial proxy
Connections 24
- User → Chat view: submits prompt
src/views/chat/index.vue - Chat view → Chat API client: requests reply
src/views/chat/index.vue - Chat API client → HTTP request layer: uses client
src/api/index.ts - Chat API client → Chat sessions: reads session
src/api/index.ts - Chat view → Chat actions: uses actions
src/views/chat/index.vue - Chat view → Context toggle: uses toggle
src/views/chat/index.vue - Context toggle → Chat sessions: updates context
src/views/chat/hooks/useUsingContext.ts - Chat view → Scroll handling: uses scrolling
src/views/chat/index.vue - Chat view → Message rendering: renders messages
src/views/chat/index.vue - Session sidebar → Chat sessions: manages sessions
- Chat sessions → Local storage: persists sessions
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
src/App.vue - App shell → Router and guards: renders routes
- Router and guards → Page permission: sets guard
src/router/index.ts - Router and guards → Chat view: routes to
src/router/index.ts - HTTP request layer → HTTP service: sends requests
- HTTP service → Access control: checks access
service/src/index.ts - HTTP service → Request limiter: limits chat
service/src/index.ts - HTTP service → Model adapters: streams reply
service/src/index.ts - HTTP service → Service utilities: checks values
service/src/index.ts - Model adapters → OpenAI API: supports API mode
README.md - Model adapters → Unofficial proxy: supports token mode
README.md