# debguin452/routeway architecture

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

- Interactive diagram: https://gitdiagram.com/debguin452/routeway
- Repository: https://github.com/debguin452/routeway

## Overview

Routeway lets developers configure fixed-destination API proxy routes and issue public tokens that cannot redirect to another upstream. The main workflow is dashboard/API signup and project-route management, followed by client requests through the Worker, which validates route controls, injects a decrypted secret, forwards upstream, and returns a filtered response. The README documents D1, KV, Durable Objects, and Pages as runtime services. Edges use excerpts or README statements; unsampled implementation details are represented only where documented.

Main entry points: [`src/proxy.ts`](https://github.com/debguin452/routeway/blob/main/src/proxy.ts) (Proxy Handler), [`src/index.ts`](https://github.com/debguin452/routeway/blob/main/src/index.ts) (Worker Router), [`src/auth.ts`](https://github.com/debguin452/routeway/blob/main/src/auth.ts) (Authentication), [`src/projects.ts`](https://github.com/debguin452/routeway/blob/main/src/projects.ts) (Project and Route Management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Dashboard and API"]
  node_dashboard["Dashboard<br/>[app.js]"]
  node_worker["Worker Router<br/>[index.ts]"]
  node_responses["HTTP Responses and CORS<br/>[responses.ts]"]
end

subgraph group_management["Accounts and Routes"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_identity["Identity Helpers<br/>[identity.ts]"]
  node_projects["Project and Route Management<br/>[projects.ts]"]
  node_settings["Route Controls<br/>[settings.ts]"]
  node_crypto["Secrets and Password Crypto<br/>[crypto.ts]"]
end

subgraph group_proxy["Secure Proxy"]
  node_proxy["Proxy Handler<br/>[proxy.ts]"]
  node_target["Target URL Builder<br/>[target.ts]"]
  node_human["Human Verification<br/>[human.ts]"]
end

subgraph group_platform["Runtime Services"]
  node_db_access["D1 Data Access<br/>[db.ts]"]
  node_d1[("D1 Database")]
  node_sessions[("Session Store")]
  node_limiter["Rate Limit and Activity<br/>[rateLimiter.ts]"]
  node_durable_objects[("Durable Objects")]
end

node_developer(("Developer"))
node_api_client(("API Client"))
node_upstream["Fixed Upstream API"]
node_turnstile["Cloudflare Turnstile"]

node_developer -->|"configures routes"| node_dashboard
node_dashboard -->|"calls API"| node_worker
node_api_client -->|"sends token request"| node_worker
node_worker -->|"routes auth"| node_auth
node_worker -->|"routes management"| node_projects
node_worker -->|"dispatches proxy"| node_proxy
node_worker -->|"adds CORS"| node_responses
node_worker -->|"reads session"| node_sessions
node_auth -->|"reads and writes users"| node_db_access
node_auth -->|"hashes passwords"| node_crypto
node_auth -->|"throttles login"| node_limiter
node_auth -->|"stores sessions"| node_sessions
node_identity -->|"derives signing keys"| node_crypto
node_projects -->|"manages records"| node_db_access
node_projects -->|"creates token hashes"| node_crypto
node_projects -->|"validates controls"| node_settings
node_projects -->|"reads activity"| node_limiter
node_proxy -->|"looks up token route"| node_db_access
node_proxy -->|"hashes and decrypts"| node_crypto
node_proxy -->|"checks verification"| node_human
node_proxy -->|"applies route controls"| node_settings
node_proxy -->|"builds target URL"| node_target
node_proxy -->|"checks and logs"| node_limiter
node_proxy -->|"forwards request"| node_upstream
node_proxy -->|"verifies challenge"| node_turnstile
node_db_access -->|"reads and writes"| node_d1
node_limiter -->|"dispatches counters"| node_durable_objects
node_human -->|"signs passes"| node_identity

click node_dashboard "https://github.com/debguin452/routeway/blob/main/dashboard/app.js"
click node_worker "https://github.com/debguin452/routeway/blob/main/src/index.ts"
click node_auth "https://github.com/debguin452/routeway/blob/main/src/auth.ts"
click node_identity "https://github.com/debguin452/routeway/blob/main/src/identity.ts"
click node_projects "https://github.com/debguin452/routeway/blob/main/src/projects.ts"
click node_settings "https://github.com/debguin452/routeway/blob/main/src/settings.ts"
click node_proxy "https://github.com/debguin452/routeway/blob/main/src/proxy.ts"
click node_target "https://github.com/debguin452/routeway/blob/main/src/target.ts"
click node_human "https://github.com/debguin452/routeway/blob/main/src/human.ts"
click node_crypto "https://github.com/debguin452/routeway/blob/main/src/crypto.ts"
click node_responses "https://github.com/debguin452/routeway/blob/main/src/responses.ts"
click node_db_access "https://github.com/debguin452/routeway/blob/main/src/db.ts"
click node_limiter "https://github.com/debguin452/routeway/blob/main/src/rateLimiter.ts"

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_dashboard,node_worker,node_responses,node_api_client toneBlue
class node_auth,node_identity,node_projects,node_settings,node_crypto toneAmber
class node_proxy,node_target,node_human,node_upstream toneMint
class node_db_access,node_d1,node_sessions,node_limiter,node_durable_objects toneRose
class node_developer,node_turnstile toneIndigo
```

## Components

### Dashboard and API

- [Dashboard](https://github.com/debguin452/routeway/blob/main/dashboard/app.js): `dashboard/app.js`
- [Worker Router](https://github.com/debguin452/routeway/blob/main/src/index.ts): `src/index.ts`
- [HTTP Responses and CORS](https://github.com/debguin452/routeway/blob/main/src/responses.ts): `src/responses.ts`

### Accounts and Routes

- [Authentication](https://github.com/debguin452/routeway/blob/main/src/auth.ts): `src/auth.ts`
- [Identity Helpers](https://github.com/debguin452/routeway/blob/main/src/identity.ts): `src/identity.ts`
- [Project and Route Management](https://github.com/debguin452/routeway/blob/main/src/projects.ts): `src/projects.ts`
- [Route Controls](https://github.com/debguin452/routeway/blob/main/src/settings.ts): `src/settings.ts`
- [Secrets and Password Crypto](https://github.com/debguin452/routeway/blob/main/src/crypto.ts): `src/crypto.ts`

### Secure Proxy

- [Proxy Handler](https://github.com/debguin452/routeway/blob/main/src/proxy.ts): `src/proxy.ts`
- [Target URL Builder](https://github.com/debguin452/routeway/blob/main/src/target.ts): `src/target.ts`
- [Human Verification](https://github.com/debguin452/routeway/blob/main/src/human.ts): `src/human.ts`

### Runtime Services

- [D1 Data Access](https://github.com/debguin452/routeway/blob/main/src/db.ts): `src/db.ts`
- **D1 Database**
- **Session Store**
- [Rate Limit and Activity](https://github.com/debguin452/routeway/blob/main/src/rateLimiter.ts): `src/rateLimiter.ts`
- **Durable Objects**

### Other components

- **Developer**
- **API Client**
- **Fixed Upstream API**
- **Cloudflare Turnstile**

## Connections

- Developer → Dashboard: configures routes (evidence: `README.md`)
- Dashboard → Worker Router: calls API (evidence: `README.md`)
- API Client → Worker Router: sends token request (evidence: `README.md`)
- Worker Router → Authentication: routes auth (evidence: `src/index.ts`)
- Worker Router → Project and Route Management: routes management (evidence: `src/index.ts`)
- Worker Router → Proxy Handler: dispatches proxy (evidence: `src/index.ts`)
- Worker Router → HTTP Responses and CORS: adds CORS (evidence: `src/index.ts`)
- Worker Router → Session Store: reads session (evidence: `README.md`)
- Authentication → D1 Data Access: reads and writes users (evidence: `src/auth.ts`)
- Authentication → Secrets and Password Crypto: hashes passwords (evidence: `src/auth.ts`)
- Authentication → Rate Limit and Activity: throttles login (evidence: `src/auth.ts`)
- Authentication → Session Store: stores sessions (evidence: `README.md`)
- Identity Helpers → Secrets and Password Crypto: derives signing keys (evidence: `src/identity.ts`)
- Project and Route Management → D1 Data Access: manages records (evidence: `src/projects.ts`)
- Project and Route Management → Secrets and Password Crypto: creates token hashes (evidence: `src/projects.ts`)
- Project and Route Management → Route Controls: validates controls (evidence: `src/projects.ts`)
- Project and Route Management → Rate Limit and Activity: reads activity (evidence: `src/projects.ts`)
- Proxy Handler → D1 Data Access: looks up token route (evidence: `src/proxy.ts`)
- Proxy Handler → Secrets and Password Crypto: hashes and decrypts (evidence: `src/proxy.ts`)
- Proxy Handler → Human Verification: checks verification (evidence: `src/proxy.ts`)
- Proxy Handler → Route Controls: applies route controls (evidence: `src/proxy.ts`)
- Proxy Handler → Target URL Builder: builds target URL (evidence: `src/proxy.ts`)
- Proxy Handler → Rate Limit and Activity: checks and logs (evidence: `src/proxy.ts`)
- Proxy Handler → Fixed Upstream API: forwards request (evidence: `README.md`)
- Proxy Handler → Cloudflare Turnstile: verifies challenge (evidence: `README.md`)
- D1 Data Access → D1 Database: reads and writes (evidence: `README.md`)
- Rate Limit and Activity → Durable Objects: dispatches counters (evidence: `src/rateLimiter.ts`)
- Human Verification → Identity Helpers: signs passes (evidence: `src/human.ts`)
