# user-wurun/pandora architecture

> Architecture diagram of the GitHub repository user-wurun/pandora, 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/user-wurun/pandora
- Repository: https://github.com/user-wurun/pandora

## Overview

Pandora offers ChatGPT through a command-line client and an optional Flask server with a bundled browser interface. The main workflow is token selection or login, then conversation requests through either the legacy CLI or HTTP routes, and onward to ChatGPT; the turbo mode instead uses the completion-style API. The README also describes token acquisition and multi-device use. The graph follows documented capabilities and sampled call sites; some implementation details, including unsampled route and frontend wiring, are intentionally left unspecified.

Main entry points: [`src/pandora/launcher.py`](https://github.com/user-wurun/pandora/blob/master/src/pandora/launcher.py) (CLI launcher), [`src/pandora/openai/api.py`](https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/api.py) (ChatGPT client), [`src/pandora/turbo/chat.py`](https://github.com/user-wurun/pandora/blob/master/src/pandora/turbo/chat.py) (Turbo client), [`src/pandora/openai/auth.py`](https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/auth.py) (Login flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_launcher["CLI launcher<br/>[launcher.py]"]
end

subgraph group_interfaces["User interfaces"]
  node_legacy["Terminal chat<br/>[legacy.py]"]
  node_server["Flask server<br/>[server.py]"]
  node_webui["Browser UI"]
end

subgraph group_clients["Chat clients"]
  node_chatgpt["ChatGPT client<br/>[api.py]"]
  node_turbo["Turbo client<br/>[chat.py]"]
  node_conversation["Conversation state<br/>[base.py]"]
  node_transport["Async transport<br/>[api.py]"]
end

subgraph group_auth["Authentication"]
  node_authflow["Login flow<br/>[auth.py]"]
  node_tokencheck["Token validation<br/>[token.py]"]
end

node_user(("User"))
node_openai(("OpenAI services"))
node_auth0(("Auth0"))

node_user -->|"starts"| node_launcher
node_launcher -->|"requests login"| node_authflow
node_authflow -->|"authenticates with"| node_auth0
node_authflow -->|"gets access token"| node_openai
node_launcher -->|"validates token"| node_tokencheck
node_launcher -->|"creates client"| node_chatgpt
node_launcher -->|"selects turbo mode"| node_turbo
node_launcher -->|"starts terminal UI"| node_legacy
node_launcher -->|"starts server"| node_server
node_user -->|"chats"| node_legacy
node_legacy -->|"requests conversations"| node_chatgpt
node_user -->|"chats"| node_webui
node_webui -->|"sends API requests"| node_server
node_server -->|"dispatches chat operations"| node_chatgpt
node_chatgpt -->|"uses request transport"| node_transport
node_transport -->|"sends API requests"| node_openai
node_turbo -->|"manages conversation state"| node_conversation
node_turbo -->|"requests completions"| node_openai

click node_launcher "https://github.com/user-wurun/pandora/blob/master/src/pandora/launcher.py"
click node_legacy "https://github.com/user-wurun/pandora/blob/master/src/pandora/bots/legacy.py"
click node_server "https://github.com/user-wurun/pandora/blob/master/src/pandora/bots/server.py"
click node_webui "https://github.com/user-wurun/pandora/blob/master/src/pandora/flask/static/_next/static/chunks/pages/chat/%5B%5B...chatId%5D%5D-76751174916fa3f7.js"
click node_chatgpt "https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/api.py"
click node_turbo "https://github.com/user-wurun/pandora/blob/master/src/pandora/turbo/chat.py"
click node_conversation "https://github.com/user-wurun/pandora/blob/master/src/pandora/turbo/base.py"
click node_transport "https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/api.py"
click node_authflow "https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/auth.py"
click node_tokencheck "https://github.com/user-wurun/pandora/blob/master/src/pandora/exts/token.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_launcher,node_user toneBlue
class node_legacy,node_server,node_webui toneAmber
class node_chatgpt,node_turbo,node_conversation,node_transport toneMint
class node_authflow,node_tokencheck toneRose
class node_openai,node_auth0 toneIndigo
```

## Components

### Entry points

- [CLI launcher](https://github.com/user-wurun/pandora/blob/master/src/pandora/launcher.py): `src/pandora/launcher.py`

### User interfaces

- [Terminal chat](https://github.com/user-wurun/pandora/blob/master/src/pandora/bots/legacy.py): `src/pandora/bots/legacy.py`
- [Flask server](https://github.com/user-wurun/pandora/blob/master/src/pandora/bots/server.py): `src/pandora/bots/server.py`
- [Browser UI](https://github.com/user-wurun/pandora/blob/master/src/pandora/flask/static/_next/static/chunks/pages/chat/%5B%5B...chatId%5D%5D-76751174916fa3f7.js): `src/pandora/flask/static/_next/static/chunks/pages/chat/[[...chatId]]-76751174916fa3f7.js`

### Chat clients

- [ChatGPT client](https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/api.py): `src/pandora/openai/api.py`
- [Turbo client](https://github.com/user-wurun/pandora/blob/master/src/pandora/turbo/chat.py): `src/pandora/turbo/chat.py`
- [Conversation state](https://github.com/user-wurun/pandora/blob/master/src/pandora/turbo/base.py): `src/pandora/turbo/base.py`
- [Async transport](https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/api.py): `src/pandora/openai/api.py`

### Authentication

- [Login flow](https://github.com/user-wurun/pandora/blob/master/src/pandora/openai/auth.py): `src/pandora/openai/auth.py`
- [Token validation](https://github.com/user-wurun/pandora/blob/master/src/pandora/exts/token.py): `src/pandora/exts/token.py`

### Other components

- **User**
- **OpenAI services**
- **Auth0**

## Connections

- User → CLI launcher: starts
- CLI launcher → Login flow: requests login
- Login flow → Auth0: authenticates with
- Login flow → OpenAI services: gets access token
- CLI launcher → Token validation: validates token
- CLI launcher → ChatGPT client: creates client
- CLI launcher → Turbo client: selects turbo mode
- CLI launcher → Terminal chat: starts terminal UI
- CLI launcher → Flask server: starts server
- User → Terminal chat: chats
- Terminal chat → ChatGPT client: requests conversations
- User → Browser UI: chats
- Browser UI → Flask server: sends API requests
- Flask server → ChatGPT client: dispatches chat operations
- ChatGPT client → Async transport: uses request transport
- Async transport → OpenAI services: sends API requests
- Turbo client → Conversation state: manages conversation state
- Turbo client → OpenAI services: requests completions
