# sexlovr/dpsk-2-api-v3 architecture

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

- Interactive diagram: https://gitdiagram.com/sexlovr/dpsk-2-api-v3
- Repository: https://github.com/sexlovr/dpsk-2-api-v3

## Overview

DeepSeek2API is an OpenAI-compatible proxy and account-management dashboard. Its main request flow authenticates an API key, prepares a stateless DeepSeek chat request, obtains the upstream response, and translates streamed events to OpenAI-style SSE. The README also describes model feature flags and admin management; the excerpts show the dashboard and interactive browser login. Some index.js sections and other modules were not sampled, so uncertain internal links are omitted.

Main entry points: [`index.js`](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js) (Proxy server), [`lib/deepseekClient.js`](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/deepseekClient.js) (DeepSeek client), [`lib/page.js`](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/page.js) (Admin dashboard), [`lib/database.js`](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/database.js) (SQLite database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_proxy["Proxy workflow"]
  node_proxy_server["Proxy server<br/>[index.js]"]
  node_key_auth["API key auth<br/>[index.js]"]
  node_model_mapping["Model mapping<br/>[index.js]"]
  node_request_context["Stateless context<br/>[index.js]"]
  node_sse_translation["SSE translation<br/>[index.js]"]
end

subgraph group_upstream["DeepSeek integration"]
  node_deepseek_client["DeepSeek client<br/>[deepseekClient.js]"]
  node_pow_solver["PoW solver<br/>[deepseekClient.js]"]
  node_pow_wasm["PoW WebAssembly<br/>[sha3_wasm_bg.wasm]"]
  node_deepseek_service["DeepSeek service"]
end

subgraph group_admin["Admin and accounts"]
  node_admin_dashboard["Admin dashboard<br/>[page.js]"]
  node_admin_routes["Admin routes<br/>[index.js]"]
  node_interactive_login["Interactive login"]
  node_automated_login["Automated login<br/>[playwrightLogin.js]"]
end

subgraph group_state["Persistent state"]
  node_database[("SQLite database<br/>[database.js]")]
end

node_api_clients(("API clients"))
node_admin_user(("Admin"))

node_api_clients -->|"sends requests"| node_proxy_server
node_proxy_server -->|"checks keys"| node_key_auth
node_proxy_server -->|"resolves model"| node_model_mapping
node_proxy_server -->|"builds request"| node_request_context
node_proxy_server -->|"creates session"| node_deepseek_client
node_proxy_server -->|"requests PoW"| node_deepseek_client
node_proxy_server -->|"sends completion"| node_deepseek_client
node_deepseek_client -->|"calls API"| node_deepseek_service
node_deepseek_client -->|"solves challenge"| node_pow_solver
node_pow_solver -->|"runs solver"| node_pow_wasm
node_proxy_server -->|"translates events"| node_sse_translation
node_admin_user -->|"uses dashboard"| node_admin_dashboard
node_proxy_server -->|"serves page"| node_admin_dashboard
node_admin_dashboard -->|"calls routes"| node_admin_routes
node_proxy_server -->|"registers routes"| node_admin_routes
node_admin_routes -->|"launches browser"| node_interactive_login
node_interactive_login -->|"saves credentials"| node_database
node_proxy_server -->|"reads and updates"| node_database
node_admin_routes -->|"manages records"| node_database

click node_proxy_server "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js"
click node_key_auth "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js"
click node_model_mapping "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js"
click node_request_context "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js"
click node_sse_translation "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js"
click node_deepseek_client "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/deepseekClient.js"
click node_pow_solver "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/deepseekClient.js"
click node_pow_wasm "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/sha3_wasm_bg.wasm"
click node_admin_dashboard "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/page.js"
click node_admin_routes "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js"
click node_interactive_login "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/browser_controller.js"
click node_automated_login "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/playwrightLogin.js"
click node_database "https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/database.js"

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_proxy_server,node_key_auth,node_model_mapping,node_request_context,node_sse_translation,node_api_clients toneBlue
class node_deepseek_client,node_pow_solver,node_pow_wasm,node_deepseek_service toneAmber
class node_admin_dashboard,node_admin_routes,node_interactive_login,node_automated_login toneMint
class node_database toneRose
class node_admin_user toneIndigo
```

## Components

### Proxy workflow

- [Proxy server](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js): `index.js`
- [API key auth](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js): `index.js`
- [Model mapping](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js): `index.js`
- [Stateless context](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js): `index.js`
- [SSE translation](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js): `index.js`

### DeepSeek integration

- [DeepSeek client](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/deepseekClient.js): `lib/deepseekClient.js`
- [PoW solver](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/deepseekClient.js): `lib/deepseekClient.js`
- [PoW WebAssembly](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/sha3_wasm_bg.wasm): `sha3_wasm_bg.wasm`
- **DeepSeek service**

### Admin and accounts

- [Admin dashboard](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/page.js): `lib/page.js`
- [Admin routes](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/index.js): `index.js`
- [Interactive login](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/browser_controller.js): `lib/browser_controller.js`
- [Automated login](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/playwrightLogin.js): `lib/playwrightLogin.js`

### Persistent state

- [SQLite database](https://github.com/sexlovr/dpsk-2-api-v3/blob/main/lib/database.js): `lib/database.js`

### Other components

- **API clients**
- **Admin**

## Connections

- API clients → Proxy server: sends requests (evidence: `README.md`)
- Proxy server → API key auth: checks keys (evidence: `index.js`)
- Proxy server → Model mapping: resolves model (evidence: `index.js`)
- Proxy server → Stateless context: builds request (evidence: `index.js`)
- Proxy server → DeepSeek client: creates session (evidence: `index.js`)
- Proxy server → DeepSeek client: requests PoW (evidence: `index.js`)
- Proxy server → DeepSeek client: sends completion (evidence: `index.js`)
- DeepSeek client → DeepSeek service: calls API (evidence: `lib/deepseekClient.js`)
- DeepSeek client → PoW solver: solves challenge (evidence: `lib/deepseekClient.js`)
- PoW solver → PoW WebAssembly: runs solver (evidence: `lib/deepseekClient.js`)
- Proxy server → SSE translation: translates events (evidence: `index.js`)
- Admin → Admin dashboard: uses dashboard (evidence: `README.md`)
- Proxy server → Admin dashboard: serves page (evidence: `index.js`)
- Admin dashboard → Admin routes: calls routes (evidence: `lib/page.js`)
- Proxy server → Admin routes: registers routes (evidence: `index.js`)
- Admin routes → Interactive login: launches browser (evidence: `index.js`)
- Interactive login → SQLite database: saves credentials (evidence: `lib/browser_controller.js`)
- Proxy server → SQLite database: reads and updates (evidence: `index.js`)
- Admin routes → SQLite database: manages records (evidence: `index.js`)
