# jasa-chi-ray/chatgpt-mirror architecture

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

- Interactive diagram: https://gitdiagram.com/jasa-chi-ray/chatgpt-mirror
- Repository: https://github.com/jasa-chi-ray/chatgpt-mirror

## Overview

ChatGPT Mirror combines a Vue administration console with a Django management API and a gateway-backed ChatGPT access service. The principal operator workflow is to authenticate, configure users and upstream accounts/pools, assign access and model/capability policies, then review logs and account health. README capabilities also include proxy/script/access controls, announcements, moderation, and health notifications. The sampled source confirms frontend routing and requests, account policy handling, and gateway health probes; some feature wiring is documented but its implementation was not sampled.

Main entry points: [`backend/app/accounts/views/__init__.py`](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/views/__init__.py) (Accounts API), [`backend/app/chatgpt/health_monitor.py`](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/health_monitor.py) (Health Monitor), [`frontend/src/router/index.ts`](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/router/index.ts) (Route Guards), [`backend/app/chatgpt/views/chatgpt.py`](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/views/chatgpt.py) (ChatGPT API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_console["Admin Console"]
  node_admin_ui["Admin UI<br/>[App.vue]"]
  node_router["Route Guards<br/>[index.ts]"]
  node_login_ui["Login UI<br/>[index.vue]"]
  node_user_store["User Session<br/>[user.ts]"]
  node_account_pages["Account Console<br/>[user.vue]"]
  node_request_client["API Client<br/>[request.ts]"]
end

subgraph group_management["Management API"]
  node_accounts_api["Accounts API<br/>[__init__.py]"]
  node_account_domain["Account Policies"]
  node_account_store[("Account Data<br/>[models.py]")]
  node_gptcar_api["Account Pools<br/>[gptcar.py]"]
  node_site_admin["Site Configuration<br/>[cfg.py]"]
  node_announcements["Announcements<br/>[announcements.py]"]
  node_moderation["Content Moderation<br/>[health.py]"]
end

subgraph group_mirror["ChatGPT Access"]
  node_chatgpt_api["ChatGPT API<br/>[chatgpt.py]"]
end

subgraph group_operations["Operations"]
  node_health_monitor["Health Monitor<br/>[health_monitor.py]"]
  node_health_settings[("Health Settings<br/>[models.py]")]
  node_visit_logs[("Usage Logs<br/>[models.py]")]
end

node_operator(("Operator"))
node_mirror_user(("Mirror User"))
node_gateway{{"Gateway"}}
node_upstream{{"ChatGPT Service"}}
node_mailer{{"SMTP Service"}}

node_operator -->|"uses"| node_admin_ui
node_admin_ui -->|"routes"| node_router
node_router -->|"opens login"| node_login_ui
node_router -->|"guards pages"| node_account_pages
node_login_ui -->|"authenticates"| node_user_store
node_account_pages -->|"requests data"| node_request_client
node_user_store -->|"calls"| node_request_client
node_request_client -->|"sends API requests"| node_accounts_api
node_accounts_api -->|"checks policies"| node_account_domain
node_accounts_api -->|"reads and writes"| node_account_store
node_accounts_api -->|"requests pool options"| node_gptcar_api
node_mirror_user -->|"uses mirror"| node_chatgpt_api
node_chatgpt_api -->|"dispatches requests"| node_gateway
node_gateway -->|"proxies traffic"| node_upstream
node_health_monitor -->|"claims scheduled checks"| node_health_settings
node_health_monitor -->|"probes credentials"| node_gateway
node_health_monitor -->|"updates check status"| node_account_store
node_health_monitor -.->|"sends failure notices"| node_mailer
node_accounts_api -->|"requests site configuration"| node_gateway
node_accounts_api -->|"serves announcements"| node_announcements
node_chatgpt_api -.->|"applies content checks"| node_moderation
node_accounts_api -.->|"records and queries"| node_visit_logs

click node_admin_ui "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/App.vue"
click node_router "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/router/index.ts"
click node_login_ui "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/pages/login/index.vue"
click node_user_store "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/store/user.ts"
click node_account_pages "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/pages/account/user.vue"
click node_request_client "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/api/request.ts"
click node_accounts_api "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/views/__init__.py"
click node_account_domain "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/session_authority.py"
click node_account_store "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/models.py"
click node_chatgpt_api "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/views/chatgpt.py"
click node_gptcar_api "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/views/gptcar.py"
click node_health_monitor "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/health_monitor.py"
click node_health_settings "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/models.py"
click node_site_admin "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/views/cfg.py"
click node_announcements "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/views/announcements.py"
click node_moderation "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/views/health.py"
click node_visit_logs "https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/models.py"

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_admin_ui,node_router,node_login_ui,node_user_store,node_account_pages,node_request_client,node_mirror_user toneBlue
class node_accounts_api,node_account_domain,node_account_store,node_gptcar_api,node_site_admin,node_announcements,node_moderation toneAmber
class node_chatgpt_api toneMint
class node_health_monitor,node_health_settings,node_visit_logs toneRose
class node_operator,node_gateway,node_upstream,node_mailer toneIndigo
```

## Components

### Admin Console

- [Admin UI](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/App.vue): `frontend/src/App.vue`
- [Route Guards](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/router/index.ts): `frontend/src/router/index.ts`
- [Login UI](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/pages/login/index.vue): `frontend/src/pages/login/index.vue`
- [User Session](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/store/user.ts): `frontend/src/store/user.ts`
- [Account Console](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/pages/account/user.vue): `frontend/src/pages/account/user.vue`
- [API Client](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/frontend/src/api/request.ts): `frontend/src/api/request.ts`

### Management API

- [Accounts API](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/views/__init__.py): `backend/app/accounts/views/__init__.py`
- [Account Policies](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/session_authority.py): `backend/app/accounts/session_authority.py`
- [Account Data](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/models.py): `backend/app/accounts/models.py`
- [Account Pools](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/views/gptcar.py): `backend/app/chatgpt/views/gptcar.py`
- [Site Configuration](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/views/cfg.py): `backend/app/accounts/views/cfg.py`
- [Announcements](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/views/announcements.py): `backend/app/accounts/views/announcements.py`
- [Content Moderation](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/views/health.py): `backend/app/chatgpt/views/health.py`

### ChatGPT Access

- [ChatGPT API](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/views/chatgpt.py): `backend/app/chatgpt/views/chatgpt.py`

### Operations

- [Health Monitor](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/health_monitor.py): `backend/app/chatgpt/health_monitor.py`
- [Health Settings](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/chatgpt/models.py): `backend/app/chatgpt/models.py`
- [Usage Logs](https://github.com/jasa-chi-ray/chatgpt-mirror/blob/main/backend/app/accounts/models.py): `backend/app/accounts/models.py`

### Other components

- **Operator**
- **Mirror User**
- **Gateway**
- **ChatGPT Service**
- **SMTP Service**

## Connections

- Operator → Admin UI: uses
- Admin UI → Route Guards: routes
- Route Guards → Login UI: opens login
- Route Guards → Account Console: guards pages
- Login UI → User Session: authenticates
- Account Console → API Client: requests data
- User Session → API Client: calls
- API Client → Accounts API: sends API requests
- Accounts API → Account Policies: checks policies
- Accounts API → Account Data: reads and writes
- Accounts API → Account Pools: requests pool options
- Mirror User → ChatGPT API: uses mirror
- ChatGPT API → Gateway: dispatches requests
- Gateway → ChatGPT Service: proxies traffic
- Health Monitor → Health Settings: claims scheduled checks
- Health Monitor → Gateway: probes credentials
- Health Monitor → Account Data: updates check status
- Health Monitor → SMTP Service: sends failure notices
- Accounts API → Gateway: requests site configuration
- Accounts API → Announcements: serves announcements
- ChatGPT API → Content Moderation: applies content checks
- Accounts API → Usage Logs: records and queries
