# ardeyouxipianyi/workbuddy2api-hub architecture

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

- Interactive diagram: https://gitdiagram.com/ardeyouxipianyi/workbuddy2api-hub
- Repository: https://github.com/ardeyouxipianyi/workbuddy2api-hub

## Overview

WorkBuddy2API-Hub is a local multi-account gateway that exposes OpenAI-compatible APIs for international WorkBuddy, domestic WorkBuddy, and CodeArts. A client sends a model or media request to the gateway; configured keys and account-pool policy govern which upstream can serve it. Separate product branches cover media generation, automated activity and sign-in, and an operator dashboard with usage and quota visibility. The README documents these capabilities, but the main gateway implementation was not sampled, so edges between internal modules are omitted where their call ownership cannot be verified.

Main entry points: [`wb_proxy.py`](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_proxy.py) (API gateway), [`wb_webtools.py`](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_webtools.py) (Web dashboard), [`wb_accounts.py`](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_accounts.py) (Account pool), [`wb_scheduler.py`](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_scheduler.py) (Automation scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway and policy"]
  node_gateway["API gateway<br/>[wb_proxy.py]"]
  node_settings["Key and settings<br/>[wb_settings.py]"]
  node_identity["Request identity<br/>[wb_identity.py]"]
  node_catalog["Model catalog<br/>[wb_catalog.py]"]
  node_pricing["Cost estimates<br/>[wb_pricing.py]"]
end

subgraph group_accounts["Accounts and upstreams"]
  node_accounts[("Account pool<br/>[wb_accounts.py]")]
  node_upstream["Upstream pool"]
  node_codearts["CodeArts client<br/>[wb_codearts.py]"]
  node_agents["Browser OAuth<br/>[wb_agents.py]"]
end

subgraph group_media["Media generation"]
  node_media_protocol["Media protocol<br/>[wb_media.py]"]
  node_media_client["Media I/O<br/>[wb_media_client.py]"]
  node_media_tasks["Video task manager<br/>[wb_media_tasks.py]"]
end

subgraph group_automation["Automation"]
  node_task_engine["Growth task engine<br/>[wb_tasks.py]"]
  node_activity["Activity tracking<br/>[wb_activity.py]"]
  node_scheduler["Automation scheduler<br/>[wb_scheduler.py]"]
  node_quota["Quota scanning<br/>[wb_quota_scan.py]"]
end

subgraph group_operations["Operations and insight"]
  node_dashboard["Web dashboard<br/>[wb_webtools.py]"]
  node_web_prompts["Web prompts<br/>[wb_webprompts.py]"]
  node_logstore[("Request logs<br/>[wb_logstore.py]")]
  node_usage[("Usage records<br/>[wb_usage_io.py]")]
end

node_client(("API client"))
node_operator(("Operator"))

node_client -->|"sends API requests"| node_gateway
node_operator -->|"manages gateway"| node_dashboard
node_operator -->|"imports accounts"| node_accounts
node_gateway -.->|"enforces key policy"| node_settings
node_gateway -.->|"dispatches requests"| node_accounts
node_gateway -->|"lists models"| node_catalog
node_gateway -->|"routes CodeArts"| node_codearts
node_gateway -.->|"serves media APIs"| node_media_protocol
node_media_protocol -->|"specifies media requests"| node_media_client
node_media_tasks -->|"polls and retrieves"| node_media_client
node_gateway -.->|"exposes task automation"| node_task_engine
node_scheduler -.->|"runs tasks"| node_task_engine
node_scheduler -.->|"runs activity checks"| node_activity
node_scheduler -.->|"scans quotas"| node_quota
node_dashboard -->|"manages keys"| node_settings
node_dashboard -->|"shows request logs"| node_logstore
node_dashboard -->|"shows usage"| node_usage
node_dashboard -.->|"shows cost insight"| node_pricing
node_agents -->|"imports OAuth accounts"| node_accounts
node_upstream -.->|"coordinates account pool"| node_accounts

click node_gateway "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_proxy.py"
click node_settings "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_settings.py"
click node_identity "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_identity.py"
click node_catalog "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_catalog.py"
click node_pricing "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_pricing.py"
click node_accounts "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_accounts.py"
click node_upstream "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_upstream_pool.py"
click node_codearts "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_codearts.py"
click node_media_protocol "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_media.py"
click node_media_client "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_media_client.py"
click node_media_tasks "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_media_tasks.py"
click node_task_engine "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_tasks.py"
click node_activity "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_activity.py"
click node_scheduler "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_scheduler.py"
click node_quota "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_quota_scan.py"
click node_dashboard "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_webtools.py"
click node_web_prompts "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_webprompts.py"
click node_logstore "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_logstore.py"
click node_usage "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_usage_io.py"
click node_agents "https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_agents.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_gateway,node_settings,node_identity,node_catalog,node_pricing,node_client toneBlue
class node_accounts,node_upstream,node_codearts,node_agents toneAmber
class node_media_protocol,node_media_client,node_media_tasks toneMint
class node_task_engine,node_activity,node_scheduler,node_quota toneRose
class node_dashboard,node_web_prompts,node_logstore,node_usage,node_operator toneIndigo
```

## Components

### Gateway and policy

- [API gateway](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_proxy.py): `wb_proxy.py`
- [Key and settings](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_settings.py): `wb_settings.py`
- [Request identity](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_identity.py): `wb_identity.py`
- [Model catalog](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_catalog.py): `wb_catalog.py`
- [Cost estimates](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_pricing.py): `wb_pricing.py`

### Accounts and upstreams

- [Account pool](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_accounts.py): `wb_accounts.py`
- [Upstream pool](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_upstream_pool.py): `wb_upstream_pool.py`
- [CodeArts client](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_codearts.py): `wb_codearts.py`
- [Browser OAuth](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_agents.py): `wb_agents.py`

### Media generation

- [Media protocol](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_media.py): `wb_media.py`
- [Media I/O](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_media_client.py): `wb_media_client.py`
- [Video task manager](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_media_tasks.py): `wb_media_tasks.py`

### Automation

- [Growth task engine](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_tasks.py): `wb_tasks.py`
- [Activity tracking](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_activity.py): `wb_activity.py`
- [Automation scheduler](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_scheduler.py): `wb_scheduler.py`
- [Quota scanning](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_quota_scan.py): `wb_quota_scan.py`

### Operations and insight

- [Web dashboard](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_webtools.py): `wb_webtools.py`
- [Web prompts](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_webprompts.py): `wb_webprompts.py`
- [Request logs](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_logstore.py): `wb_logstore.py`
- [Usage records](https://github.com/ardeyouxipianyi/workbuddy2api-hub/blob/main/wb_usage_io.py): `wb_usage_io.py`

### Other components

- **API client**
- **Operator**

## Connections

- API client → API gateway: sends API requests (evidence: `README.md`)
- Operator → Web dashboard: manages gateway (evidence: `README.md`)
- Operator → Account pool: imports accounts (evidence: `README.md`)
- API gateway → Key and settings: enforces key policy
- API gateway → Account pool: dispatches requests (evidence: `wb_accounts.py`)
- API gateway → Model catalog: lists models (evidence: `README.md`)
- API gateway → CodeArts client: routes CodeArts (evidence: `README.md`)
- API gateway → Media protocol: serves media APIs
- Media protocol → Media I/O: specifies media requests (evidence: `wb_media.py`)
- Video task manager → Media I/O: polls and retrieves (evidence: `wb_media_tasks.py`)
- API gateway → Growth task engine: exposes task automation
- Automation scheduler → Growth task engine: runs tasks (evidence: `wb_scheduler.py`)
- Automation scheduler → Activity tracking: runs activity checks (evidence: `wb_scheduler.py`)
- Automation scheduler → Quota scanning: scans quotas (evidence: `wb_scheduler.py`)
- Web dashboard → Key and settings: manages keys (evidence: `README.md`)
- Web dashboard → Request logs: shows request logs (evidence: `README.md`)
- Web dashboard → Usage records: shows usage (evidence: `README.md`)
- Web dashboard → Cost estimates: shows cost insight
- Browser OAuth → Account pool: imports OAuth accounts (evidence: `README.md`)
- Upstream pool → Account pool: coordinates account pool (evidence: `wb_accounts.py`)
