# superdesigndev/treg architecture

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

- Interactive diagram: https://gitdiagram.com/superdesigndev/treg
- Repository: https://github.com/superdesigndev/treg
- Video tour (about a minute): https://gitdiagram.com/superdesigndev/treg/video

## Overview

Treg is a shared registry and credential-injecting proxy for agent tools. The main workflow is: an agent or user discovers a catalog endpoint, authenticates with a Treg token, invokes it, and receives a relayed provider response; calls may use team credentials, verified public routes, or Treg-managed credentials and prepaid billing. Teams can also register tools, CLIs, skills, and connections for shared use. The graph combines README-documented capabilities with sampled call-service, dashboard, and worker code; unsampled subsystem wiring is represented only where the tree or documentation supports it.

Main entry points: [`src/treg/api.py`](https://github.com/superdesigndev/treg/blob/main/src/treg/api.py) (HTTP application), [`src/treg/application/call/service.py`](https://github.com/superdesigndev/treg/blob/main/src/treg/application/call/service.py) (Call orchestration), [`src/treg/worker.py`](https://github.com/superdesigndev/treg/blob/main/src/treg/worker.py) (Scheduled worker), [`src/treg/domain/catalog/store.py`](https://github.com/superdesigndev/treg/blob/main/src/treg/domain/catalog/store.py) (Catalog index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients and dashboard"]
  node_cli["Treg CLI<br/>[cli.py]"]
  node_dashboard["Dashboard UI<br/>[App.vue]"]
  node_frontend_api["Dashboard API client<br/>[api.ts]"]
  node_http_api["HTTP application<br/>[api.py]"]
end

subgraph group_registry["Catalog and tools"]
  node_catalog_routes["Catalog routes<br/>[catalog.py]"]
  node_catalog_domain[("Catalog index<br/>[store.py]")]
  node_tool_routes["Tool and resource routes<br/>[resources.py]"]
  node_tool_domain["Tool bindings and bundles<br/>[bindings.py]"]
  node_connection_routes["Connections and OAuth<br/>[connections.py]"]
end

subgraph group_execution["Call execution"]
  node_call_routes["Call endpoints<br/>[call.py]"]
  node_call_service["Call orchestration<br/>[service.py]"]
  node_provider_relay["Upstream relay<br/>[relay.py]"]
  node_billing["Billing and settlement<br/>[billing.py]"]
  node_async_tasks["Deferred task settlement<br/>[asynctasks.py]"]
end

subgraph group_accounts["Identity and accounts"]
  node_identity_routes["Auth and API keys<br/>[auth.py]"]
  node_governance["Teams and governance<br/>[teams.py]"]
end

subgraph group_operations["Insights and operations"]
  node_arena["Enrich Arena<br/>[arena.py]"]
  node_feedback["Feedback and reviews<br/>[feedback.py]"]
  node_worker["Scheduled worker<br/>[worker.py]"]
  node_audit_db[("Application database<br/>[db.py]")]
end

node_agent(("Agent or user"))
node_providers(("Tool providers"))
node_stripe(("Stripe"))

node_agent -->|"runs commands"| node_cli
node_cli -->|"sends requests"| node_http_api
node_agent -->|"uses dashboard"| node_dashboard
node_dashboard -->|"requests data"| node_frontend_api
node_frontend_api -->|"calls API"| node_http_api
node_http_api -->|"dispatches catalog"| node_catalog_routes
node_catalog_routes -->|"reads catalog"| node_catalog_domain
node_http_api -->|"dispatches tools"| node_tool_routes
node_tool_routes -->|"manages bindings"| node_tool_domain
node_http_api -->|"dispatches connections"| node_connection_routes
node_http_api -->|"dispatches calls"| node_call_routes
node_call_routes -->|"executes call"| node_call_service
node_call_service -->|"resolves endpoint"| node_catalog_domain
node_call_service -->|"relays request"| node_provider_relay
node_provider_relay -->|"forwards request"| node_providers
node_call_service -->|"charges or holds"| node_billing
node_call_service -->|"records deferred task"| node_async_tasks
node_http_api -->|"dispatches identity"| node_identity_routes
node_http_api -->|"serves team policies"| node_governance
node_billing -.->|"handles payments"| node_stripe
node_http_api -->|"dispatches Arena"| node_arena
node_http_api -->|"dispatches feedback"| node_feedback
node_worker -->|"aggregates records"| node_audit_db
node_worker -->|"loads catalog"| node_catalog_domain
node_worker -.->|"checks routes"| node_providers
node_call_service -->|"persists call state"| node_audit_db
node_async_tasks -->|"settles task records"| node_audit_db

click node_cli "https://github.com/superdesigndev/treg/blob/main/src/treg/cli.py"
click node_dashboard "https://github.com/superdesigndev/treg/blob/main/frontend/src/App.vue"
click node_frontend_api "https://github.com/superdesigndev/treg/blob/main/frontend/src/api.ts"
click node_http_api "https://github.com/superdesigndev/treg/blob/main/src/treg/api.py"
click node_catalog_routes "https://github.com/superdesigndev/treg/blob/main/src/treg/routers/catalog.py"
click node_catalog_domain "https://github.com/superdesigndev/treg/blob/main/src/treg/domain/catalog/store.py"
click node_tool_routes "https://github.com/superdesigndev/treg/blob/main/src/treg/routers/resources.py"
click node_tool_domain "https://github.com/superdesigndev/treg/blob/main/src/treg/domain/tools/bindings.py"
click node_connection_routes "https://github.com/superdesigndev/treg/blob/main/src/treg/routers/connections.py"
click node_call_routes "https://github.com/superdesigndev/treg/blob/main/src/treg/routers/call.py"
click node_call_service "https://github.com/superdesigndev/treg/blob/main/src/treg/application/call/service.py"
click node_provider_relay "https://github.com/superdesigndev/treg/blob/main/src/treg/infra/upstream/relay.py"
click node_billing "https://github.com/superdesigndev/treg/blob/main/src/treg/application/billing.py"
click node_async_tasks "https://github.com/superdesigndev/treg/blob/main/src/treg/application/asynctasks.py"
click node_identity_routes "https://github.com/superdesigndev/treg/blob/main/src/treg/routers/auth.py"
click node_governance "https://github.com/superdesigndev/treg/blob/main/src/treg/domain/governance/teams.py"
click node_arena "https://github.com/superdesigndev/treg/blob/main/src/treg/routers/arena.py"
click node_feedback "https://github.com/superdesigndev/treg/blob/main/src/treg/routers/feedback.py"
click node_worker "https://github.com/superdesigndev/treg/blob/main/src/treg/worker.py"
click node_audit_db "https://github.com/superdesigndev/treg/blob/main/src/treg/infra/db.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_cli,node_dashboard,node_frontend_api,node_http_api,node_agent toneBlue
class node_catalog_routes,node_catalog_domain,node_tool_routes,node_tool_domain,node_connection_routes toneAmber
class node_call_routes,node_call_service,node_provider_relay,node_billing,node_async_tasks toneMint
class node_identity_routes,node_governance toneRose
class node_arena,node_feedback,node_worker,node_audit_db,node_providers,node_stripe toneIndigo
```

## Components

### Clients and dashboard

- [Treg CLI](https://github.com/superdesigndev/treg/blob/main/src/treg/cli.py): `src/treg/cli.py`
- [Dashboard UI](https://github.com/superdesigndev/treg/blob/main/frontend/src/App.vue): `frontend/src/App.vue`
- [Dashboard API client](https://github.com/superdesigndev/treg/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [HTTP application](https://github.com/superdesigndev/treg/blob/main/src/treg/api.py): `src/treg/api.py`

### Catalog and tools

- [Catalog routes](https://github.com/superdesigndev/treg/blob/main/src/treg/routers/catalog.py): `src/treg/routers/catalog.py`
- [Catalog index](https://github.com/superdesigndev/treg/blob/main/src/treg/domain/catalog/store.py): `src/treg/domain/catalog/store.py`
- [Tool and resource routes](https://github.com/superdesigndev/treg/blob/main/src/treg/routers/resources.py): `src/treg/routers/resources.py`
- [Tool bindings and bundles](https://github.com/superdesigndev/treg/blob/main/src/treg/domain/tools/bindings.py): `src/treg/domain/tools/bindings.py`
- [Connections and OAuth](https://github.com/superdesigndev/treg/blob/main/src/treg/routers/connections.py): `src/treg/routers/connections.py`

### Call execution

- [Call endpoints](https://github.com/superdesigndev/treg/blob/main/src/treg/routers/call.py): `src/treg/routers/call.py`
- [Call orchestration](https://github.com/superdesigndev/treg/blob/main/src/treg/application/call/service.py): `src/treg/application/call/service.py`
- [Upstream relay](https://github.com/superdesigndev/treg/blob/main/src/treg/infra/upstream/relay.py): `src/treg/infra/upstream/relay.py`
- [Billing and settlement](https://github.com/superdesigndev/treg/blob/main/src/treg/application/billing.py): `src/treg/application/billing.py`
- [Deferred task settlement](https://github.com/superdesigndev/treg/blob/main/src/treg/application/asynctasks.py): `src/treg/application/asynctasks.py`

### Identity and accounts

- [Auth and API keys](https://github.com/superdesigndev/treg/blob/main/src/treg/routers/auth.py): `src/treg/routers/auth.py`
- [Teams and governance](https://github.com/superdesigndev/treg/blob/main/src/treg/domain/governance/teams.py): `src/treg/domain/governance/teams.py`

### Insights and operations

- [Enrich Arena](https://github.com/superdesigndev/treg/blob/main/src/treg/routers/arena.py): `src/treg/routers/arena.py`
- [Feedback and reviews](https://github.com/superdesigndev/treg/blob/main/src/treg/routers/feedback.py): `src/treg/routers/feedback.py`
- [Scheduled worker](https://github.com/superdesigndev/treg/blob/main/src/treg/worker.py): `src/treg/worker.py`
- [Application database](https://github.com/superdesigndev/treg/blob/main/src/treg/infra/db.py): `src/treg/infra/db.py`

### Other components

- **Agent or user**
- **Tool providers**
- **Stripe**

## Connections

- Agent or user → Treg CLI: runs commands
- Treg CLI → HTTP application: sends requests
- Agent or user → Dashboard UI: uses dashboard
- Dashboard UI → Dashboard API client: requests data
- Dashboard API client → HTTP application: calls API
- HTTP application → Catalog routes: dispatches catalog
- Catalog routes → Catalog index: reads catalog
- HTTP application → Tool and resource routes: dispatches tools
- Tool and resource routes → Tool bindings and bundles: manages bindings
- HTTP application → Connections and OAuth: dispatches connections
- HTTP application → Call endpoints: dispatches calls
- Call endpoints → Call orchestration: executes call
- Call orchestration → Catalog index: resolves endpoint
- Call orchestration → Upstream relay: relays request
- Upstream relay → Tool providers: forwards request
- Call orchestration → Billing and settlement: charges or holds
- Call orchestration → Deferred task settlement: records deferred task
- HTTP application → Auth and API keys: dispatches identity
- HTTP application → Teams and governance: serves team policies
- Billing and settlement → Stripe: handles payments
- HTTP application → Enrich Arena: dispatches Arena
- HTTP application → Feedback and reviews: dispatches feedback
- Scheduled worker → Application database: aggregates records
- Scheduled worker → Catalog index: loads catalog
- Scheduled worker → Tool providers: checks routes
- Call orchestration → Application database: persists call state
- Deferred task settlement → Application database: settles task records
