# seakee/cpa-manager-plus architecture

> Architecture diagram of the GitHub repository seakee/cpa-manager-plus, 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/seakee/cpa-manager-plus
- Repository: https://github.com/seakee/cpa-manager-plus

## Overview

CPA Manager Plus is a self-hosted management panel and observability dashboard for CPA / CLIProxyAPI; it manages the gateway but does not proxy model traffic. Operators use the web UI to configure providers and credentials, inspect accounts and quotas, and analyze persistent request, usage, and cost data. In full mode, the manager server exposes HTTP APIs, collects usage events, and persists operational and analytics state in SQLite. The README documents these major capabilities; wiring for unsampled controllers and services is represented at subsystem level rather than inferred function by function.

Main entry points: [`apps/web/src/router/MainRoutes.tsx`](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/router/MainRoutes.tsx) (Feature routes), [`apps/manager-server/internal/httpapi/server.go`](https://github.com/seakee/cpa-manager-plus/blob/main/apps/manager-server/internal/httpapi/server.go) (Manager HTTP API), [`apps/manager-server/internal/service`](https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/service) (Domain services), [`apps/manager-server/internal/repository`](https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/repository) (Data repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Operator interface"]
  node_webapp["Web application<br/>[appRoutes.tsx]"]
  node_webroutes["Feature routes<br/>[MainRoutes.tsx]"]
end

subgraph group_gateway["CPA management"]
  node_providerui["Provider settings"]
  node_authfilesui["Credential management"]
  node_configui["Gateway configuration<br/>[ConfigPage.tsx]"]
end

subgraph group_observability["Request observability"]
  node_monitorui["Request monitoring"]
  node_usageui["Usage analytics<br/>[DashboardPage.tsx]"]
  node_priceui["Model prices"]
  node_collector["Usage collector<br/>[collector.go]"]
end

subgraph group_accounts["Account operations"]
  node_accountsui["Account health<br/>[AccountsPage.tsx]"]
  node_inspectionui["Health inspection"]
  node_actionsui["Account actions"]
end

subgraph group_runtime["Manager runtime"]
  node_manager["Manager HTTP API<br/>[server.go]"]
  node_controllers["API controllers"]
  node_services["Domain services"]
  node_workers["Background workers"]
  node_repositories["Data repositories"]
  node_sqlite[("Local state<br/>[db.go]")]
end

node_operator(("Operator"))
node_cpa["CPA / CLIProxyAPI"]
node_usagequeue["CPA usage queue"]
node_pricefeeds["Model price sources"]

node_operator -->|"uses"| node_webapp
node_webapp -->|"routes"| node_webroutes
node_webroutes -->|"opens"| node_providerui
node_webroutes -->|"opens"| node_authfilesui
node_webroutes -->|"opens"| node_configui
node_webroutes -->|"opens"| node_monitorui
node_webroutes -->|"opens"| node_usageui
node_webroutes -->|"opens"| node_priceui
node_webroutes -->|"opens"| node_accountsui
node_webroutes -->|"opens"| node_inspectionui
node_webroutes -->|"opens"| node_actionsui
node_providerui -->|"API requests"| node_manager
node_authfilesui -->|"API requests"| node_manager
node_configui -->|"API requests"| node_manager
node_monitorui -->|"API requests"| node_manager
node_usageui -->|"API requests"| node_manager
node_priceui -->|"API requests"| node_manager
node_accountsui -->|"API requests"| node_manager
node_inspectionui -->|"API requests"| node_manager
node_actionsui -->|"API requests"| node_manager
node_manager -->|"dispatches"| node_controllers
node_controllers -->|"invokes"| node_services
node_services -->|"reads and writes"| node_repositories
node_repositories -->|"persists state"| node_sqlite
node_cpa -->|"publishes events"| node_usagequeue
node_collector -->|"consumes events"| node_usagequeue
node_collector -->|"persists history"| node_repositories
node_workers -->|"updates analytics"| node_repositories
node_services -->|"management API"| node_cpa
node_services -.->|"syncs prices"| node_pricefeeds

click node_webapp "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/app/appRoutes.tsx"
click node_webroutes "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/router/MainRoutes.tsx"
click node_providerui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/aiProviders/AiProvidersPage.tsx"
click node_authfilesui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/authFiles/hooks/useAuthFilesData.ts"
click node_configui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/config/ConfigPage.tsx"
click node_monitorui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/MonitoringCenterPage.tsx"
click node_usageui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/dashboard/DashboardPage.tsx"
click node_priceui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/ModelPricesPage.tsx"
click node_accountsui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/accounts/AccountsPage.tsx"
click node_inspectionui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/CodexInspectionPage.tsx"
click node_actionsui "https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/AccountActionCandidatesPage.tsx"
click node_manager "https://github.com/seakee/cpa-manager-plus/blob/main/apps/manager-server/internal/httpapi/server.go"
click node_controllers "https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/http/controller"
click node_services "https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/service"
click node_collector "https://github.com/seakee/cpa-manager-plus/blob/main/apps/manager-server/internal/collector/collector.go"
click node_workers "https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/worker"
click node_repositories "https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/repository"
click node_sqlite "https://github.com/seakee/cpa-manager-plus/blob/main/apps/manager-server/internal/repository/sqlite/db.go"

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_webapp,node_webroutes toneBlue
class node_providerui,node_authfilesui,node_configui toneAmber
class node_monitorui,node_usageui,node_priceui,node_collector,node_cpa toneMint
class node_accountsui,node_inspectionui,node_actionsui,node_usagequeue toneRose
class node_manager,node_controllers,node_services,node_workers,node_repositories,node_sqlite,node_operator,node_pricefeeds toneIndigo
```

## Components

### Operator interface

- [Web application](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/app/appRoutes.tsx): `apps/web/src/app/appRoutes.tsx`
- [Feature routes](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/router/MainRoutes.tsx): `apps/web/src/router/MainRoutes.tsx`

### CPA management

- [Provider settings](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/aiProviders/AiProvidersPage.tsx): `apps/web/src/features/aiProviders/AiProvidersPage.tsx`
- [Credential management](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/authFiles/hooks/useAuthFilesData.ts): `apps/web/src/features/authFiles/hooks/useAuthFilesData.ts`
- [Gateway configuration](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/config/ConfigPage.tsx): `apps/web/src/features/config/ConfigPage.tsx`

### Request observability

- [Request monitoring](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/MonitoringCenterPage.tsx): `apps/web/src/features/monitoring/MonitoringCenterPage.tsx`
- [Usage analytics](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/dashboard/DashboardPage.tsx): `apps/web/src/features/dashboard/DashboardPage.tsx`
- [Model prices](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/ModelPricesPage.tsx): `apps/web/src/features/monitoring/ModelPricesPage.tsx`
- [Usage collector](https://github.com/seakee/cpa-manager-plus/blob/main/apps/manager-server/internal/collector/collector.go): `apps/manager-server/internal/collector/collector.go`

### Account operations

- [Account health](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/accounts/AccountsPage.tsx): `apps/web/src/features/accounts/AccountsPage.tsx`
- [Health inspection](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/CodexInspectionPage.tsx): `apps/web/src/features/monitoring/CodexInspectionPage.tsx`
- [Account actions](https://github.com/seakee/cpa-manager-plus/blob/main/apps/web/src/features/monitoring/AccountActionCandidatesPage.tsx): `apps/web/src/features/monitoring/AccountActionCandidatesPage.tsx`

### Manager runtime

- [Manager HTTP API](https://github.com/seakee/cpa-manager-plus/blob/main/apps/manager-server/internal/httpapi/server.go): `apps/manager-server/internal/httpapi/server.go`
- [API controllers](https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/http/controller): `apps/manager-server/internal/http/controller`
- [Domain services](https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/service): `apps/manager-server/internal/service`
- [Background workers](https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/worker): `apps/manager-server/internal/worker`
- [Data repositories](https://github.com/seakee/cpa-manager-plus/tree/main/apps/manager-server/internal/repository): `apps/manager-server/internal/repository`
- [Local state](https://github.com/seakee/cpa-manager-plus/blob/main/apps/manager-server/internal/repository/sqlite/db.go): `apps/manager-server/internal/repository/sqlite/db.go`

### Other components

- **Operator**
- **CPA / CLIProxyAPI**
- **CPA usage queue**
- **Model price sources**

## Connections

- Operator → Web application: uses
- Web application → Feature routes: routes
- Feature routes → Provider settings: opens
- Feature routes → Credential management: opens
- Feature routes → Gateway configuration: opens
- Feature routes → Request monitoring: opens
- Feature routes → Usage analytics: opens
- Feature routes → Model prices: opens
- Feature routes → Account health: opens
- Feature routes → Health inspection: opens
- Feature routes → Account actions: opens
- Provider settings → Manager HTTP API: API requests
- Credential management → Manager HTTP API: API requests
- Gateway configuration → Manager HTTP API: API requests
- Request monitoring → Manager HTTP API: API requests
- Usage analytics → Manager HTTP API: API requests
- Model prices → Manager HTTP API: API requests
- Account health → Manager HTTP API: API requests
- Health inspection → Manager HTTP API: API requests
- Account actions → Manager HTTP API: API requests
- Manager HTTP API → API controllers: dispatches
- API controllers → Domain services: invokes
- Domain services → Data repositories: reads and writes
- Data repositories → Local state: persists state
- CPA / CLIProxyAPI → CPA usage queue: publishes events
- Usage collector → CPA usage queue: consumes events
- Usage collector → Data repositories: persists history
- Background workers → Data repositories: updates analytics
- Domain services → CPA / CLIProxyAPI: management API
- Domain services → Model price sources: syncs prices
