# girishg17/ai-benchmark architecture

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

- Interactive diagram: https://gitdiagram.com/girishg17/ai-benchmark
- Repository: https://github.com/girishg17/ai-benchmark

## Overview

AI Benchmark is a multi-model query router with two ways to build routing knowledge: interactive user feedback and offline model benchmarking. In the interactive path, the CLI builds the router, classifies a question, selects a capable model using exploration/UCB, returns its answer, and records feedback. Offline benchmarking evaluates configured models against datasets to initialize stats. The graph preserves the documented benchmark and provider capabilities; benchmark internals and configuration details are represented at their supported directory paths because their source was not excerpted.

Main entry points: [`router/dynamic_router.py`](https://github.com/girishg17/ai-benchmark/blob/main/router/dynamic_router.py) (Dynamic routing), [`router/models.py`](https://github.com/girishg17/ai-benchmark/blob/main/router/models.py) (Model clients), [`scripts/run_offline_bench.py`](https://github.com/girishg17/ai-benchmark/blob/main/scripts/run_offline_bench.py) (Benchmark launcher), [`router/main.py`](https://github.com/girishg17/ai-benchmark/blob/main/router/main.py) (Router setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_cli["Interactive CLI<br/>[cli.py]"]
  node_app["Router setup<br/>[main.py]"]
end

subgraph group_routing["Routing"]
  node_classifier["Task classifier<br/>[classifier.py]"]
  node_dynamic["Dynamic routing<br/>[dynamic_router.py]"]
  node_policy["Best-fit policy<br/>[routing_policy.py]"]
end

subgraph group_models["Models"]
  node_model_clients["Model clients<br/>[models.py]"]
end

subgraph group_learning["Evaluation"]
  node_feedback["Feedback record<br/>[feedback.py]"]
  node_bench_runner["Benchmark launcher"]
  node_bench_suite["Benchmark execution"]
  node_bench_data["Benchmark datasets"]
  node_bench_metrics["Benchmark metrics<br/>[metrics.py]"]
end

subgraph group_support["State and config"]
  node_model_config["Model configuration<br/>[models.yaml]"]
  node_route_config["Routing configuration<br/>[routing.yaml]"]
  node_stats[("Routing statistics<br/>[router_stats.json]")]
  node_io["JSON persistence<br/>[io.py]"]
  node_logger["Logging<br/>[logger.py]"]
end

node_user(("Questioner"))
node_provider_openai{{"OpenAI API"}}
node_provider_rapid{{"RapidAPI models"}}
node_provider_perplexity{{"Perplexity API"}}

node_user -->|"enters question"| node_cli
node_cli -->|"starts CLI"| node_app
node_app -->|"builds router"| node_dynamic
node_app -->|"loads models"| node_model_clients
node_app -->|"reads settings"| node_route_config
node_app -->|"loads definitions"| node_model_config
node_cli -->|"routes question"| node_dynamic
node_dynamic -->|"classifies query"| node_classifier
node_dynamic -->|"calls selected model"| node_model_clients
node_dynamic -->|"loads and saves stats"| node_io
node_io -->|"reads and writes"| node_stats
node_dynamic -->|"logs decisions"| node_logger
node_cli -->|"records feedback"| node_dynamic
node_model_clients -->|"sends requests"| node_provider_rapid
node_model_clients -->|"sends requests"| node_provider_perplexity
node_model_clients -.->|"supports client"| node_provider_openai
node_bench_runner -->|"runs benchmark"| node_bench_suite
node_bench_runner -->|"selects datasets"| node_bench_data
node_bench_runner -->|"loads models"| node_model_clients
node_bench_suite -.->|"uses metrics"| node_bench_metrics
node_bench_runner -->|"initializes scores"| node_stats
node_bench_runner -->|"writes scores"| node_io
node_feedback -->|"uses task types"| node_classifier
node_policy -->|"uses task types"| node_classifier
node_policy -->|"uses model stats"| node_dynamic

click node_cli "https://github.com/girishg17/ai-benchmark/blob/main/scripts/cli.py"
click node_app "https://github.com/girishg17/ai-benchmark/blob/main/router/main.py"
click node_classifier "https://github.com/girishg17/ai-benchmark/blob/main/router/classifier.py"
click node_dynamic "https://github.com/girishg17/ai-benchmark/blob/main/router/dynamic_router.py"
click node_policy "https://github.com/girishg17/ai-benchmark/blob/main/router/routing_policy.py"
click node_feedback "https://github.com/girishg17/ai-benchmark/blob/main/router/feedback.py"
click node_model_clients "https://github.com/girishg17/ai-benchmark/blob/main/router/models.py"
click node_bench_runner "https://github.com/girishg17/ai-benchmark/blob/main/scripts/run_offline_bench.py"
click node_bench_suite "https://github.com/girishg17/ai-benchmark/tree/main/benchmark"
click node_bench_data "https://github.com/girishg17/ai-benchmark/tree/main/benchmark/data"
click node_bench_metrics "https://github.com/girishg17/ai-benchmark/blob/main/benchmark/metrics.py"
click node_model_config "https://github.com/girishg17/ai-benchmark/blob/main/config/models.yaml"
click node_route_config "https://github.com/girishg17/ai-benchmark/blob/main/config/routing.yaml"
click node_stats "https://github.com/girishg17/ai-benchmark/blob/main/storage/router_stats.json"
click node_io "https://github.com/girishg17/ai-benchmark/blob/main/utils/io.py"
click node_logger "https://github.com/girishg17/ai-benchmark/blob/main/utils/logger.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_app toneBlue
class node_classifier,node_dynamic,node_policy toneAmber
class node_model_clients,node_provider_openai,node_provider_rapid,node_provider_perplexity toneMint
class node_feedback,node_bench_runner,node_bench_suite,node_bench_data,node_bench_metrics toneRose
class node_model_config,node_route_config,node_stats,node_io,node_logger,node_user toneIndigo
```

## Components

### User entry

- [Interactive CLI](https://github.com/girishg17/ai-benchmark/blob/main/scripts/cli.py): `scripts/cli.py`
- [Router setup](https://github.com/girishg17/ai-benchmark/blob/main/router/main.py): `router/main.py`

### Routing

- [Task classifier](https://github.com/girishg17/ai-benchmark/blob/main/router/classifier.py): `router/classifier.py`
- [Dynamic routing](https://github.com/girishg17/ai-benchmark/blob/main/router/dynamic_router.py): `router/dynamic_router.py`
- [Best-fit policy](https://github.com/girishg17/ai-benchmark/blob/main/router/routing_policy.py): `router/routing_policy.py`

### Models

- [Model clients](https://github.com/girishg17/ai-benchmark/blob/main/router/models.py): `router/models.py`

### Evaluation

- [Feedback record](https://github.com/girishg17/ai-benchmark/blob/main/router/feedback.py): `router/feedback.py`
- [Benchmark launcher](https://github.com/girishg17/ai-benchmark/blob/main/scripts/run_offline_bench.py): `scripts/run_offline_bench.py`
- [Benchmark execution](https://github.com/girishg17/ai-benchmark/tree/main/benchmark): `benchmark`
- [Benchmark datasets](https://github.com/girishg17/ai-benchmark/tree/main/benchmark/data): `benchmark/data`
- [Benchmark metrics](https://github.com/girishg17/ai-benchmark/blob/main/benchmark/metrics.py): `benchmark/metrics.py`

### State and config

- [Model configuration](https://github.com/girishg17/ai-benchmark/blob/main/config/models.yaml): `config/models.yaml`
- [Routing configuration](https://github.com/girishg17/ai-benchmark/blob/main/config/routing.yaml): `config/routing.yaml`
- [Routing statistics](https://github.com/girishg17/ai-benchmark/blob/main/storage/router_stats.json): `storage/router_stats.json`
- [JSON persistence](https://github.com/girishg17/ai-benchmark/blob/main/utils/io.py): `utils/io.py`
- [Logging](https://github.com/girishg17/ai-benchmark/blob/main/utils/logger.py): `utils/logger.py`

### Other components

- **Questioner**
- **OpenAI API**
- **RapidAPI models**
- **Perplexity API**

## Connections

- Questioner → Interactive CLI: enters question (evidence: `README.md`)
- Interactive CLI → Router setup: starts CLI (evidence: `scripts/cli.py`)
- Router setup → Dynamic routing: builds router (evidence: `router/main.py`)
- Router setup → Model clients: loads models (evidence: `router/main.py`)
- Router setup → Routing configuration: reads settings (evidence: `router/main.py`)
- Router setup → Model configuration: loads definitions (evidence: `router/main.py`)
- Interactive CLI → Dynamic routing: routes question
- Dynamic routing → Task classifier: classifies query (evidence: `router/dynamic_router.py`)
- Dynamic routing → Model clients: calls selected model (evidence: `router/dynamic_router.py`)
- Dynamic routing → JSON persistence: loads and saves stats (evidence: `router/dynamic_router.py`)
- JSON persistence → Routing statistics: reads and writes
- Dynamic routing → Logging: logs decisions (evidence: `router/dynamic_router.py`)
- Interactive CLI → Dynamic routing: records feedback
- Model clients → RapidAPI models: sends requests (evidence: `router/models.py`)
- Model clients → Perplexity API: sends requests (evidence: `router/models.py`)
- Model clients → OpenAI API: supports client
- Benchmark launcher → Benchmark execution: runs benchmark (evidence: `scripts/run_offline_bench.py`)
- Benchmark launcher → Benchmark datasets: selects datasets (evidence: `scripts/run_offline_bench.py`)
- Benchmark launcher → Model clients: loads models (evidence: `scripts/run_offline_bench.py`)
- Benchmark execution → Benchmark metrics: uses metrics
- Benchmark launcher → Routing statistics: initializes scores (evidence: `scripts/run_offline_bench.py`)
- Benchmark launcher → JSON persistence: writes scores (evidence: `scripts/run_offline_bench.py`)
- Feedback record → Task classifier: uses task types (evidence: `router/feedback.py`)
- Best-fit policy → Task classifier: uses task types (evidence: `router/routing_policy.py`)
- Best-fit policy → Dynamic routing: uses model stats (evidence: `router/routing_policy.py`)
