# zmlone/tokenledger architecture

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

- Interactive diagram: https://gitdiagram.com/zmlone/tokenledger
- Repository: https://github.com/zmlone/tokenledger

## Overview

PromptBill is a web application for exploring LLM benchmarks and API pricing, comparing models, and estimating usage costs. The visible workflow starts with a model leaderboard or directory, continues to model details or head-to-head comparisons, and can use interactive calculators to estimate spend. Related product areas include provider and curated rankings, token counting, routing simulation, and selection tools. Source evidence is strongest for the leaderboard, model/comparison pages, and pricing calculations; several tools and supporting components are indexed but not excerpted, so their internal links are omitted.

Main entry points: [`src/components/PromptBillHome.tsx`](https://github.com/zmlone/tokenledger/blob/main/src/components/PromptBillHome.tsx) (Cost workspace), [`src/lib/catalog.ts`](https://github.com/zmlone/tokenledger/blob/main/src/lib/catalog.ts) (Model catalog), [`src/app/page.tsx`](https://github.com/zmlone/tokenledger/blob/main/src/app/page.tsx) (Leaderboard), [`src/app/models/[slug]/page.tsx`](https://github.com/zmlone/tokenledger/blob/main/src/app/models/%5Bslug%5D/page.tsx) (Model detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Model discovery"]
  node_leaderboard["Leaderboard<br/>[page.tsx]"]
  node_catalog["Model catalog<br/>[catalog.ts]"]
  node_model_directory["Model directory<br/>[page.tsx]"]
  node_provider_page["Provider page<br/>[page.tsx]"]
  node_curated_rankings["Curated rankings<br/>[page.tsx]"]
  node_model_detail["Model detail<br/>[page.tsx]"]
end

subgraph group_comparison["Model comparisons"]
  node_comparison_hub["Comparison hub<br/>[page.tsx]"]
  node_comparison_detail["Head-to-head<br/>[page.tsx]"]
  node_comparison_matrix["Comparison matrix"]
end

subgraph group_costing["Cost tools"]
  node_cost_calculator["Model calculator"]
  node_pricing_engine["Pricing engine<br/>[pricingEngine.ts]"]
  node_prompt_bill_home["Cost workspace<br/>[PromptBillHome.tsx]"]
  node_tokenizer["Prompt tokenizer"]
  node_routing_simulator["Routing simulator"]
  node_selector_tool["Model selector<br/>[page.tsx]"]
  node_token_counter["Token counter<br/>[page.tsx]"]
  node_routing_tool_page["Routing tool page<br/>[page.tsx]"]
  node_feature_guides["Feature guides"]
end

subgraph group_presentation["Application shell"]
  node_site_shell["Site navigation<br/>[SiteShell.tsx]"]
  node_brand_mark["Brand mark<br/>[BrandMark.tsx]"]
end

subgraph group_telemetry["Usage telemetry"]
  node_posthog_log["Event logging<br/>[posthogLog.ts]"]
end

node_visitor(("Visitor"))

node_visitor -->|"browses"| node_leaderboard
node_leaderboard -->|"reads models"| node_catalog
node_leaderboard -->|"links to"| node_model_detail
node_leaderboard -->|"links to"| node_comparison_hub
node_model_directory -->|"reads models"| node_catalog
node_provider_page -->|"reads provider models"| node_catalog
node_curated_rankings -->|"filters models"| node_catalog
node_model_detail -->|"looks up model"| node_catalog
node_model_detail -->|"renders calculator"| node_cost_calculator
node_cost_calculator -->|"calculates cost"| node_pricing_engine
node_comparison_hub -->|"reads models"| node_catalog
node_comparison_detail -->|"parses comparison"| node_catalog
node_prompt_bill_home -->|"calculates cost"| node_pricing_engine
node_prompt_bill_home -->|"renders mark"| node_brand_mark
node_prompt_bill_home -->|"renders tokenizer"| node_tokenizer
node_prompt_bill_home -->|"renders matrix"| node_comparison_matrix
node_prompt_bill_home -->|"renders simulator"| node_routing_simulator
node_prompt_bill_home -->|"renders guides"| node_feature_guides
node_tokenizer -->|"estimates tokens"| node_pricing_engine
node_routing_simulator -->|"calculates routing costs"| node_pricing_engine
node_comparison_detail -->|"links to models"| node_model_detail
node_visitor -.->|"navigates"| node_site_shell

click node_leaderboard "https://github.com/zmlone/tokenledger/blob/main/src/app/page.tsx"
click node_catalog "https://github.com/zmlone/tokenledger/blob/main/src/lib/catalog.ts"
click node_model_directory "https://github.com/zmlone/tokenledger/blob/main/src/app/models/page.tsx"
click node_provider_page "https://github.com/zmlone/tokenledger/blob/main/src/app/providers/%5Bprovider%5D/page.tsx"
click node_curated_rankings "https://github.com/zmlone/tokenledger/blob/main/src/app/best-llms-for-coding/page.tsx"
click node_model_detail "https://github.com/zmlone/tokenledger/blob/main/src/app/models/%5Bslug%5D/page.tsx"
click node_comparison_hub "https://github.com/zmlone/tokenledger/blob/main/src/app/compare/page.tsx"
click node_comparison_detail "https://github.com/zmlone/tokenledger/blob/main/src/app/compare/%5Bslug%5D/page.tsx"
click node_comparison_matrix "https://github.com/zmlone/tokenledger/blob/main/src/components/ComparisonMatrix.tsx"
click node_cost_calculator "https://github.com/zmlone/tokenledger/blob/main/src/components/ModelDetailCalculator.tsx"
click node_pricing_engine "https://github.com/zmlone/tokenledger/blob/main/src/lib/pricingEngine.ts"
click node_prompt_bill_home "https://github.com/zmlone/tokenledger/blob/main/src/components/PromptBillHome.tsx"
click node_tokenizer "https://github.com/zmlone/tokenledger/blob/main/src/components/LivePromptTokenizer.tsx"
click node_routing_simulator "https://github.com/zmlone/tokenledger/blob/main/src/components/RoutingSimulator.tsx"
click node_selector_tool "https://github.com/zmlone/tokenledger/blob/main/src/app/tools/llm-selector/page.tsx"
click node_token_counter "https://github.com/zmlone/tokenledger/blob/main/src/app/tools/token-counter/page.tsx"
click node_routing_tool_page "https://github.com/zmlone/tokenledger/blob/main/src/app/tools/routing-simulator/page.tsx"
click node_feature_guides "https://github.com/zmlone/tokenledger/blob/main/src/components/FeatureGuideAndFaq.tsx"
click node_site_shell "https://github.com/zmlone/tokenledger/blob/main/src/components/SiteShell.tsx"
click node_brand_mark "https://github.com/zmlone/tokenledger/blob/main/src/components/BrandMark.tsx"
click node_posthog_log "https://github.com/zmlone/tokenledger/blob/main/src/lib/posthogLog.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_leaderboard,node_catalog,node_model_directory,node_provider_page,node_curated_rankings,node_model_detail toneBlue
class node_comparison_hub,node_comparison_detail,node_comparison_matrix toneAmber
class node_cost_calculator,node_pricing_engine,node_prompt_bill_home,node_tokenizer,node_routing_simulator,node_selector_tool,node_token_counter,node_routing_tool_page,node_feature_guides toneMint
class node_site_shell,node_brand_mark toneRose
class node_posthog_log,node_visitor toneIndigo
```

## Components

### Model discovery

- [Leaderboard](https://github.com/zmlone/tokenledger/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Model catalog](https://github.com/zmlone/tokenledger/blob/main/src/lib/catalog.ts): `src/lib/catalog.ts`
- [Model directory](https://github.com/zmlone/tokenledger/blob/main/src/app/models/page.tsx): `src/app/models/page.tsx`
- [Provider page](https://github.com/zmlone/tokenledger/blob/main/src/app/providers/%5Bprovider%5D/page.tsx): `src/app/providers/[provider]/page.tsx`
- [Curated rankings](https://github.com/zmlone/tokenledger/blob/main/src/app/best-llms-for-coding/page.tsx): `src/app/best-llms-for-coding/page.tsx`
- [Model detail](https://github.com/zmlone/tokenledger/blob/main/src/app/models/%5Bslug%5D/page.tsx): `src/app/models/[slug]/page.tsx`

### Model comparisons

- [Comparison hub](https://github.com/zmlone/tokenledger/blob/main/src/app/compare/page.tsx): `src/app/compare/page.tsx`
- [Head-to-head](https://github.com/zmlone/tokenledger/blob/main/src/app/compare/%5Bslug%5D/page.tsx): `src/app/compare/[slug]/page.tsx`
- [Comparison matrix](https://github.com/zmlone/tokenledger/blob/main/src/components/ComparisonMatrix.tsx): `src/components/ComparisonMatrix.tsx`

### Cost tools

- [Model calculator](https://github.com/zmlone/tokenledger/blob/main/src/components/ModelDetailCalculator.tsx): `src/components/ModelDetailCalculator.tsx`
- [Pricing engine](https://github.com/zmlone/tokenledger/blob/main/src/lib/pricingEngine.ts): `src/lib/pricingEngine.ts`
- [Cost workspace](https://github.com/zmlone/tokenledger/blob/main/src/components/PromptBillHome.tsx): `src/components/PromptBillHome.tsx`
- [Prompt tokenizer](https://github.com/zmlone/tokenledger/blob/main/src/components/LivePromptTokenizer.tsx): `src/components/LivePromptTokenizer.tsx`
- [Routing simulator](https://github.com/zmlone/tokenledger/blob/main/src/components/RoutingSimulator.tsx): `src/components/RoutingSimulator.tsx`
- [Model selector](https://github.com/zmlone/tokenledger/blob/main/src/app/tools/llm-selector/page.tsx): `src/app/tools/llm-selector/page.tsx`
- [Token counter](https://github.com/zmlone/tokenledger/blob/main/src/app/tools/token-counter/page.tsx): `src/app/tools/token-counter/page.tsx`
- [Routing tool page](https://github.com/zmlone/tokenledger/blob/main/src/app/tools/routing-simulator/page.tsx): `src/app/tools/routing-simulator/page.tsx`
- [Feature guides](https://github.com/zmlone/tokenledger/blob/main/src/components/FeatureGuideAndFaq.tsx): `src/components/FeatureGuideAndFaq.tsx`

### Application shell

- [Site navigation](https://github.com/zmlone/tokenledger/blob/main/src/components/SiteShell.tsx): `src/components/SiteShell.tsx`
- [Brand mark](https://github.com/zmlone/tokenledger/blob/main/src/components/BrandMark.tsx): `src/components/BrandMark.tsx`

### Usage telemetry

- [Event logging](https://github.com/zmlone/tokenledger/blob/main/src/lib/posthogLog.ts): `src/lib/posthogLog.ts`

### Other components

- **Visitor**

## Connections

- Visitor → Leaderboard: browses (evidence: `src/app/page.tsx`)
- Leaderboard → Model catalog: reads models (evidence: `src/app/page.tsx`)
- Leaderboard → Model detail: links to (evidence: `src/app/page.tsx`)
- Leaderboard → Comparison hub: links to (evidence: `src/app/page.tsx`)
- Model directory → Model catalog: reads models (evidence: `src/app/models/page.tsx`)
- Provider page → Model catalog: reads provider models (evidence: `src/app/providers/[provider]/page.tsx`)
- Curated rankings → Model catalog: filters models (evidence: `src/app/best-llms-for-coding/page.tsx`)
- Model detail → Model catalog: looks up model (evidence: `src/app/models/[slug]/page.tsx`)
- Model detail → Model calculator: renders calculator (evidence: `src/app/models/[slug]/page.tsx`)
- Model calculator → Pricing engine: calculates cost (evidence: `src/components/ModelDetailCalculator.tsx`)
- Comparison hub → Model catalog: reads models (evidence: `src/app/compare/page.tsx`)
- Head-to-head → Model catalog: parses comparison (evidence: `src/app/compare/[slug]/page.tsx`)
- Cost workspace → Pricing engine: calculates cost (evidence: `src/components/PromptBillHome.tsx`)
- Cost workspace → Brand mark: renders mark (evidence: `src/components/PromptBillHome.tsx`)
- Cost workspace → Prompt tokenizer: renders tokenizer (evidence: `src/components/PromptBillHome.tsx`)
- Cost workspace → Comparison matrix: renders matrix (evidence: `src/components/PromptBillHome.tsx`)
- Cost workspace → Routing simulator: renders simulator (evidence: `src/components/PromptBillHome.tsx`)
- Cost workspace → Feature guides: renders guides (evidence: `src/components/PromptBillHome.tsx`)
- Prompt tokenizer → Pricing engine: estimates tokens (evidence: `src/components/LivePromptTokenizer.tsx`)
- Routing simulator → Pricing engine: calculates routing costs (evidence: `src/components/RoutingSimulator.tsx`)
- Head-to-head → Model detail: links to models (evidence: `src/app/compare/[slug]/page.tsx`)
- Visitor → Site navigation: navigates (evidence: `src/components/SiteShell.tsx`)
