# adithyan-b-raj/claudemax-vps architecture

> Architecture diagram of the GitHub repository adithyan-b-raj/claudemax-vps, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adithyan-b-raj/claudemax-vps
- Repository: https://github.com/adithyan-b-raj/claudemax-vps

## Overview

This is a small Express service that provides an Anthropic-compatible message proxy, model listing, and an admin interface for managing share keys and token usage. Clients send messages through key validation and upstream forwarding; the proxy records returned token usage in SQLite. Administrators manage keys and inspect usage through admin routes, while the server serves the dashboard. Source excerpts show route registration and database calls; dashboard behavior and external request initiation are not shown, so those links are marked unverified.

Main entry points: [`src/server.js`](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/server.js) (Express server), [`src/routes/proxy.js`](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/proxy.js) (Message proxy), [`src/routes/admin.js`](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/admin.js) (Admin routes), [`src/auth.js`](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/auth.js) (Share-key validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["HTTP entry points"]
  node_server["Express server<br/>[server.js]"]
  node_dashboard["Admin dashboard<br/>[dashboard.html]"]
end

subgraph group_admin["Key administration"]
  node_admin_routes["Admin routes<br/>[admin.js]"]
end

subgraph group_proxy["Proxy and metering"]
  node_auth["Share-key validation<br/>[auth.js]"]
  node_message_proxy["Message proxy<br/>[proxy.js]"]
  node_model_routes["Model listing<br/>[models.js]"]
end

subgraph group_storage["Persistent state"]
  node_share_state[("Share-key state<br/>[db.js]")]
  node_usage_state[("Usage records<br/>[db.js]")]
end

node_api_clients(("API clients"))
node_admins(("Administrators"))
node_upstream["Anthropic upstream"]

node_server -->|"mounts admin routes"| node_admin_routes
node_server -->|"mounts proxy routes"| node_message_proxy
node_server -->|"mounts model routes"| node_model_routes
node_server -->|"initializes database"| node_share_state
node_server -->|"serves static files"| node_dashboard
node_api_clients -.->|"submits messages"| node_message_proxy
node_api_clients -.->|"requests models"| node_model_routes
node_admins -.->|"uses dashboard"| node_dashboard
node_dashboard -.->|"calls admin API"| node_admin_routes
node_admin_routes -->|"manages shares"| node_share_state
node_admin_routes -->|"reads and resets usage"| node_usage_state
node_message_proxy -->|"validates key"| node_auth
node_auth -->|"checks and binds key"| node_share_state
node_auth -->|"checks window usage"| node_usage_state
node_message_proxy -->|"forwards messages"| node_upstream
node_message_proxy -->|"records token usage"| node_usage_state
node_model_routes -->|"fetches models"| node_upstream

click node_server "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/server.js"
click node_dashboard "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/public/dashboard.html"
click node_admin_routes "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/admin.js"
click node_auth "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/auth.js"
click node_message_proxy "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/proxy.js"
click node_model_routes "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/models.js"
click node_share_state "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/db.js"
click node_usage_state "https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/db.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_server,node_dashboard,node_api_clients toneBlue
class node_admin_routes toneAmber
class node_auth,node_message_proxy,node_model_routes toneMint
class node_share_state,node_usage_state toneRose
class node_admins,node_upstream toneIndigo
```

## Components

### HTTP entry points

- [Express server](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/server.js): `src/server.js`
- [Admin dashboard](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/public/dashboard.html): `public/dashboard.html`

### Key administration

- [Admin routes](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/admin.js): `src/routes/admin.js`

### Proxy and metering

- [Share-key validation](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/auth.js): `src/auth.js`
- [Message proxy](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/proxy.js): `src/routes/proxy.js`
- [Model listing](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/routes/models.js): `src/routes/models.js`

### Persistent state

- [Share-key state](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/db.js): `src/db.js`
- [Usage records](https://github.com/adithyan-b-raj/claudemax-vps/blob/master/src/db.js): `src/db.js`

### Other components

- **API clients**
- **Administrators**
- **Anthropic upstream**

## Connections

- Express server → Admin routes: mounts admin routes (evidence: `src/server.js`)
- Express server → Message proxy: mounts proxy routes (evidence: `src/server.js`)
- Express server → Model listing: mounts model routes (evidence: `src/server.js`)
- Express server → Share-key state: initializes database (evidence: `src/server.js`)
- Express server → Admin dashboard: serves static files (evidence: `src/server.js`)
- API clients → Message proxy: submits messages
- API clients → Model listing: requests models
- Administrators → Admin dashboard: uses dashboard
- Admin dashboard → Admin routes: calls admin API
- Admin routes → Share-key state: manages shares (evidence: `src/routes/admin.js`)
- Admin routes → Usage records: reads and resets usage (evidence: `src/routes/admin.js`)
- Message proxy → Share-key validation: validates key (evidence: `src/routes/proxy.js`)
- Share-key validation → Share-key state: checks and binds key (evidence: `src/auth.js`)
- Share-key validation → Usage records: checks window usage (evidence: `src/auth.js`)
- Message proxy → Anthropic upstream: forwards messages (evidence: `src/routes/proxy.js`)
- Message proxy → Usage records: records token usage (evidence: `src/routes/proxy.js`)
- Model listing → Anthropic upstream: fetches models (evidence: `src/routes/models.js`)
