# mcalrifle789/ozone architecture

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

- Interactive diagram: https://gitdiagram.com/mcalrifle789/ozone
- Repository: https://github.com/mcalrifle789/ozone

## Overview

OZONE is an AI-agent website with account management, subscriptions and credits, and chat and media-generation features. Users browse the site, authenticate, select a plan or fund an account, then submit generation requests; prompts are screened before model requests are relayed through a per-user key vault. Payments and usage are tracked in a split-fund ledger. The README documents both standalone internal services and an embedded Vercel deployment; the graph captures their shared product roles. Some frontend-to-handler and handler-to-service details are documented at the architecture level rather than shown in sampled calls.

Main entry points: [`gateway/main.go`](https://github.com/mcalrifle789/ozone/blob/main/gateway/main.go) (Gateway routes), [`gateway/services.go`](https://github.com/mcalrifle789/ozone/blob/main/gateway/services.go) (Service adapter), [`keyvault/src/main.rs`](https://github.com/mcalrifle789/ozone/blob/main/keyvault/src/main.rs) (Key vault and relay), [`web/assets/js`](https://github.com/mcalrifle789/ozone/tree/main/web/assets/js) (Feature scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Website"]
  node_site["OZONE site<br/>[index.html]"]
  node_site_scripts["Feature scripts"]
  node_wasm["Interactive visuals"]
end

subgraph group_gateway["Gateway"]
  node_gateway_app["Gateway routes<br/>[main.go]"]
  node_accounts["Accounts and sessions<br/>[auth.go]"]
  node_plans["Plans and models<br/>[plans.go]"]
  node_studio["Agent and studio<br/>[studio.go]"]
  node_store[("Application state<br/>[store.go]")]
end

subgraph group_safety["Safety and generation"]
  node_guardrails["Prompt guardrails<br/>[guardrails.py]"]
  node_vault["Key vault and relay<br/>[main.rs]"]
  node_sealing["Key sealing<br/>[seal.rs]"]
end

subgraph group_finance["Billing and ledger"]
  node_billing["Checkout and webhooks<br/>[billing.go]"]
  node_ledger_server["Ledger API<br/>[LedgerServer.java]"]
  node_ledger[("Payment and usage ledger<br/>[Ledger.java]")]
  node_ledger_json["Ledger JSON codec<br/>[Json.java]"]
end

subgraph group_runtime["Runtime services"]
  node_services["Service adapter<br/>[services.go]"]
  node_vercel["Vercel entrypoint<br/>[ozone.go]"]
end

node_visitor(("Visitor"))
node_console["Crazyrouter console"]
node_models_upstream["Crazyrouter models"]
node_stripe["Stripe"]

node_visitor -->|"browses"| node_site
node_site -.->|"loads features"| node_site_scripts
node_site_scripts -.->|"requests APIs"| node_gateway_app
node_site_scripts -.->|"uses visuals"| node_wasm
node_gateway_app -->|"routes account requests"| node_accounts
node_gateway_app -->|"routes catalog requests"| node_plans
node_gateway_app -->|"routes generation requests"| node_studio
node_gateway_app -->|"routes billing requests"| node_billing
node_gateway_app -->|"opens state"| node_store
node_gateway_app -->|"wires services"| node_services
node_billing -->|"processes payments"| node_stripe
node_billing -.->|"records payment"| node_services
node_studio -->|"screens prompts"| node_guardrails
node_studio -.->|"relays generation"| node_services
node_services -->|"requests relay"| node_vault
node_vault -->|"seals keys"| node_sealing
node_vault -->|"manages user keys"| node_console
node_vault -->|"relays model calls"| node_models_upstream
node_services -->|"sends ledger requests"| node_ledger_server
node_ledger_server -->|"records and queries"| node_ledger
node_ledger -->|"parses and writes"| node_ledger_json
node_vercel -->|"serves API routes"| node_gateway_app

click node_site "https://github.com/mcalrifle789/ozone/blob/main/web/index.html"
click node_site_scripts "https://github.com/mcalrifle789/ozone/tree/main/web/assets/js"
click node_wasm "https://github.com/mcalrifle789/ozone/tree/main/wasm"
click node_gateway_app "https://github.com/mcalrifle789/ozone/blob/main/gateway/main.go"
click node_accounts "https://github.com/mcalrifle789/ozone/blob/main/gateway/auth.go"
click node_plans "https://github.com/mcalrifle789/ozone/blob/main/gateway/plans.go"
click node_studio "https://github.com/mcalrifle789/ozone/blob/main/gateway/studio.go"
click node_store "https://github.com/mcalrifle789/ozone/blob/main/gateway/store.go"
click node_guardrails "https://github.com/mcalrifle789/ozone/blob/main/guardrails/guardrails.py"
click node_vault "https://github.com/mcalrifle789/ozone/blob/main/keyvault/src/main.rs"
click node_sealing "https://github.com/mcalrifle789/ozone/blob/main/keyvault/src/seal.rs"
click node_billing "https://github.com/mcalrifle789/ozone/blob/main/gateway/billing.go"
click node_services "https://github.com/mcalrifle789/ozone/blob/main/gateway/services.go"
click node_ledger_server "https://github.com/mcalrifle789/ozone/blob/main/ledger/src/main/java/ai/ozone/ledger/LedgerServer.java"
click node_ledger "https://github.com/mcalrifle789/ozone/blob/main/ledger/src/main/java/ai/ozone/ledger/Ledger.java"
click node_ledger_json "https://github.com/mcalrifle789/ozone/blob/main/ledger/src/main/java/ai/ozone/ledger/Json.java"
click node_vercel "https://github.com/mcalrifle789/ozone/blob/main/api/ozone.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_site,node_site_scripts,node_wasm toneBlue
class node_gateway_app,node_accounts,node_plans,node_studio,node_store toneAmber
class node_guardrails,node_vault,node_sealing,node_console,node_models_upstream toneMint
class node_billing,node_ledger_server,node_ledger,node_ledger_json toneRose
class node_services,node_vercel,node_visitor,node_stripe toneIndigo
```

## Components

### Website

- [OZONE site](https://github.com/mcalrifle789/ozone/blob/main/web/index.html): `web/index.html`
- [Feature scripts](https://github.com/mcalrifle789/ozone/tree/main/web/assets/js): `web/assets/js`
- [Interactive visuals](https://github.com/mcalrifle789/ozone/tree/main/wasm): `wasm`

### Gateway

- [Gateway routes](https://github.com/mcalrifle789/ozone/blob/main/gateway/main.go): `gateway/main.go`
- [Accounts and sessions](https://github.com/mcalrifle789/ozone/blob/main/gateway/auth.go): `gateway/auth.go`
- [Plans and models](https://github.com/mcalrifle789/ozone/blob/main/gateway/plans.go): `gateway/plans.go`
- [Agent and studio](https://github.com/mcalrifle789/ozone/blob/main/gateway/studio.go): `gateway/studio.go`
- [Application state](https://github.com/mcalrifle789/ozone/blob/main/gateway/store.go): `gateway/store.go`

### Safety and generation

- [Prompt guardrails](https://github.com/mcalrifle789/ozone/blob/main/guardrails/guardrails.py): `guardrails/guardrails.py`
- [Key vault and relay](https://github.com/mcalrifle789/ozone/blob/main/keyvault/src/main.rs): `keyvault/src/main.rs`
- [Key sealing](https://github.com/mcalrifle789/ozone/blob/main/keyvault/src/seal.rs): `keyvault/src/seal.rs`

### Billing and ledger

- [Checkout and webhooks](https://github.com/mcalrifle789/ozone/blob/main/gateway/billing.go): `gateway/billing.go`
- [Ledger API](https://github.com/mcalrifle789/ozone/blob/main/ledger/src/main/java/ai/ozone/ledger/LedgerServer.java): `ledger/src/main/java/ai/ozone/ledger/LedgerServer.java`
- [Payment and usage ledger](https://github.com/mcalrifle789/ozone/blob/main/ledger/src/main/java/ai/ozone/ledger/Ledger.java): `ledger/src/main/java/ai/ozone/ledger/Ledger.java`
- [Ledger JSON codec](https://github.com/mcalrifle789/ozone/blob/main/ledger/src/main/java/ai/ozone/ledger/Json.java): `ledger/src/main/java/ai/ozone/ledger/Json.java`

### Runtime services

- [Service adapter](https://github.com/mcalrifle789/ozone/blob/main/gateway/services.go): `gateway/services.go`
- [Vercel entrypoint](https://github.com/mcalrifle789/ozone/blob/main/api/ozone.go): `api/ozone.go`

### Other components

- **Visitor**
- **Crazyrouter console**
- **Crazyrouter models**
- **Stripe**

## Connections

- Visitor → OZONE site: browses (evidence: `README.md`)
- OZONE site → Feature scripts: loads features
- Feature scripts → Gateway routes: requests APIs
- Feature scripts → Interactive visuals: uses visuals
- Gateway routes → Accounts and sessions: routes account requests (evidence: `gateway/main.go`)
- Gateway routes → Plans and models: routes catalog requests (evidence: `gateway/main.go`)
- Gateway routes → Agent and studio: routes generation requests (evidence: `gateway/main.go`)
- Gateway routes → Checkout and webhooks: routes billing requests (evidence: `gateway/main.go`)
- Gateway routes → Application state: opens state (evidence: `gateway/main.go`)
- Gateway routes → Service adapter: wires services (evidence: `gateway/main.go`)
- Checkout and webhooks → Stripe: processes payments (evidence: `README.md`)
- Checkout and webhooks → Service adapter: records payment
- Agent and studio → Prompt guardrails: screens prompts (evidence: `README.md`)
- Agent and studio → Service adapter: relays generation
- Service adapter → Key vault and relay: requests relay (evidence: `gateway/services.go`)
- Key vault and relay → Key sealing: seals keys (evidence: `keyvault/src/main.rs`)
- Key vault and relay → Crazyrouter console: manages user keys
- Key vault and relay → Crazyrouter models: relays model calls (evidence: `keyvault/src/main.rs`)
- Service adapter → Ledger API: sends ledger requests (evidence: `gateway/services.go`)
- Ledger API → Payment and usage ledger: records and queries (evidence: `ledger/src/main/java/ai/ozone/ledger/LedgerServer.java`)
- Payment and usage ledger → Ledger JSON codec: parses and writes (evidence: `ledger/src/main/java/ai/ozone/ledger/Ledger.java`)
- Vercel entrypoint → Gateway routes: serves API routes (evidence: `api/ozone.go`)
