# lolmaobruhhh/dpsk-2-api architecture

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

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

## Overview

DeepSeek2API is a stateless OpenAI-compatible proxy to DeepSeek’s web chat API, with an admin dashboard for managing accounts, keys, models, and browser-assisted login. The main request path authenticates an API key, starts a new upstream chat, prepares proof-of-work and model settings, then translates the upstream stream into OpenAI-style SSE. The graph includes documented capabilities whose full implementation was not sampled; edges are limited to relationships shown in excerpts or the README.

Main entry points: [`index.js`](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js) (HTTP Gateway), [`lib/deepseekClient.js`](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/deepseekClient.js) (DeepSeek Client), [`lib/page.js`](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/page.js) (Admin Dashboard), [`lib/database.js`](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/database.js) (Database API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Proxy Gateway"]
  node_gateway["HTTP Gateway<br/>[index.js]"]
  node_api_auth["API Key Auth<br/>[index.js]"]
  node_completion_flow["Completion Flow<br/>[index.js]"]
  node_sse_translation["SSE Translation<br/>[index.js]"]
end

subgraph group_upstream["DeepSeek Integration"]
  node_upstream_client["DeepSeek Client<br/>[deepseekClient.js]"]
  node_pow_solver["PoW Solver<br/>[deepseekClient.js]"]
  node_wasm_pow["SHA3 WASM<br/>[sha3_wasm_bg.wasm]"]
end

subgraph group_admin["Administration"]
  node_admin_dashboard["Admin Dashboard<br/>[page.js]"]
  node_admin_routes["Admin Routes<br/>[index.js]"]
  node_browser_login["Interactive Login"]
  node_automated_login["Automated Login<br/>[playwrightLogin.js]"]
end

subgraph group_persistence["Persistence"]
  node_database_api["Database API<br/>[database.js]"]
  node_sqlite_store[("SQLite Store<br/>[database.js]")]
end

node_api_client(("API Client"))
node_admin_operator(("Admin Operator"))
node_deepseek_service["DeepSeek Chat"]

node_api_client -->|"sends requests"| node_gateway
node_gateway -->|"authenticates keys"| node_api_auth
node_api_auth -->|"checks keys"| node_database_api
node_gateway -->|"routes completions"| node_completion_flow
node_completion_flow -->|"creates chat"| node_upstream_client
node_completion_flow -->|"prepares PoW"| node_pow_solver
node_completion_flow -->|"streams completion"| node_upstream_client
node_upstream_client -->|"calls chat API"| node_deepseek_service
node_pow_solver -->|"solves challenge"| node_wasm_pow
node_completion_flow -->|"translates events"| node_sse_translation
node_sse_translation -->|"streams SSE"| node_api_client
node_admin_operator -->|"uses dashboard"| node_admin_dashboard
node_gateway -->|"serves page"| node_admin_dashboard
node_admin_dashboard -->|"calls admin APIs"| node_admin_routes
node_gateway -->|"handles admin routes"| node_admin_routes
node_admin_routes -->|"manages records"| node_database_api
node_admin_routes -->|"launches browser"| node_browser_login
node_browser_login -->|"saves credentials"| node_sqlite_store
node_database_api -->|"reads and writes"| node_sqlite_store

click node_gateway "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js"
click node_api_auth "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js"
click node_completion_flow "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js"
click node_sse_translation "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js"
click node_upstream_client "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/deepseekClient.js"
click node_pow_solver "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/deepseekClient.js"
click node_wasm_pow "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/sha3_wasm_bg.wasm"
click node_admin_dashboard "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/page.js"
click node_admin_routes "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js"
click node_browser_login "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/browser_controller.js"
click node_automated_login "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/playwrightLogin.js"
click node_database_api "https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/database.js"
click node_sqlite_store "https://github.com/lolmaobruhhh/dpsk-2-api/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_gateway,node_api_auth,node_completion_flow,node_sse_translation,node_api_client toneBlue
class node_upstream_client,node_pow_solver,node_wasm_pow toneAmber
class node_admin_dashboard,node_admin_routes,node_browser_login,node_automated_login toneMint
class node_database_api,node_sqlite_store toneRose
class node_admin_operator,node_deepseek_service toneIndigo
```

## Components

### Proxy Gateway

- [HTTP Gateway](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js): `index.js`
- [API Key Auth](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js): `index.js`
- [Completion Flow](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js): `index.js`
- [SSE Translation](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js): `index.js`

### DeepSeek Integration

- [DeepSeek Client](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/deepseekClient.js): `lib/deepseekClient.js`
- [PoW Solver](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/deepseekClient.js): `lib/deepseekClient.js`
- [SHA3 WASM](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/sha3_wasm_bg.wasm): `sha3_wasm_bg.wasm`

### Administration

- [Admin Dashboard](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/page.js): `lib/page.js`
- [Admin Routes](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/index.js): `index.js`
- [Interactive Login](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/browser_controller.js): `lib/browser_controller.js`
- [Automated Login](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/playwrightLogin.js): `lib/playwrightLogin.js`

### Persistence

- [Database API](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/database.js): `lib/database.js`
- [SQLite Store](https://github.com/lolmaobruhhh/dpsk-2-api/blob/main/lib/database.js): `lib/database.js`

### Other components

- **API Client**
- **Admin Operator**
- **DeepSeek Chat**

## Connections

- API Client → HTTP Gateway: sends requests (evidence: `README.md`)
- HTTP Gateway → API Key Auth: authenticates keys (evidence: `index.js`)
- API Key Auth → Database API: checks keys (evidence: `index.js`)
- HTTP Gateway → Completion Flow: routes completions (evidence: `index.js`)
- Completion Flow → DeepSeek Client: creates chat (evidence: `index.js`)
- Completion Flow → PoW Solver: prepares PoW (evidence: `index.js`)
- Completion Flow → DeepSeek Client: streams completion (evidence: `index.js`)
- DeepSeek Client → DeepSeek Chat: calls chat API (evidence: `lib/deepseekClient.js`)
- PoW Solver → SHA3 WASM: solves challenge (evidence: `lib/deepseekClient.js`)
- Completion Flow → SSE Translation: translates events (evidence: `index.js`)
- SSE Translation → API Client: streams SSE (evidence: `README.md`)
- Admin Operator → Admin Dashboard: uses dashboard (evidence: `README.md`)
- HTTP Gateway → Admin Dashboard: serves page (evidence: `index.js`)
- Admin Dashboard → Admin Routes: calls admin APIs (evidence: `lib/page.js`)
- HTTP Gateway → Admin Routes: handles admin routes (evidence: `index.js`)
- Admin Routes → Database API: manages records (evidence: `index.js`)
- Admin Routes → Interactive Login: launches browser (evidence: `index.js`)
- Interactive Login → SQLite Store: saves credentials (evidence: `lib/browser_controller.js`)
- Database API → SQLite Store: reads and writes (evidence: `lib/database.js`)
