# thakshil/routelab architecture

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

- Interactive diagram: https://gitdiagram.com/thakshil/routelab
- Repository: https://github.com/thakshil/routelab

## Overview

RouteLab classifies a query, applies deterministic policy, and returns a model tier; it does not invoke that model or generate an answer. The principal flow runs from the browser through the API to a configured classifier, then through routing policy to a displayed decision. Jev, Groq, and mock classification are distinct modes; task-shape signals provide a routing floor. The README documents the browser’s same-origin API calls and the external classifier endpoints. Groq’s implementation was not excerpted, so its internal behavior is not detailed here.

Main entry points: [`backend/app/api/query.py`](https://github.com/thakshil/routelab/blob/main/backend/app/api/query.py) (Query endpoint), [`backend/app/services/jev_client.py`](https://github.com/thakshil/routelab/blob/main/backend/app/services/jev_client.py) (Jev adapter and mock), [`frontend/src/App.jsx`](https://github.com/thakshil/routelab/blob/main/frontend/src/App.jsx) (Query interface), [`backend/app/config.py`](https://github.com/thakshil/routelab/blob/main/backend/app/config.py) (Runtime settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser UI"]
  node_app["Query interface<br/>[App.jsx]"]
  node_browser_api["Browser API client<br/>[api.js]"]
  node_frontend_entry["UI entry<br/>[main.jsx]"]
end

subgraph group_api["API and contracts"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_query_endpoint["Query endpoint<br/>[query.py]"]
  node_contracts["Request and response models<br/>[schemas.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
end

subgraph group_policy["Routing policy"]
  node_router["Tier selection policy<br/>[router.py]"]
  node_task_signals["Task-shape rules<br/>[task_signals.py]"]
end

subgraph group_classifiers["Classification providers"]
  node_jev_adapter["Jev adapter and mock<br/>[jev_client.py]"]
  node_groq_adapter["Groq classifier<br/>[groq_classifier.py]"]
end

node_user(("User"))
node_jev_service{{"TypeSafe Jev"}}
node_groq_service{{"Groq API"}}

node_user -->|"enters query"| node_app
node_frontend_entry -->|"renders"| node_app
node_app -->|"requests status and routing"| node_browser_api
node_browser_api -->|"calls same-origin API"| node_api_app
node_api_app -->|"mounts route"| node_query_endpoint
node_api_app -->|"reads status mode"| node_settings
node_query_endpoint -->|"loads settings"| node_settings
node_query_endpoint -->|"validates and returns"| node_contracts
node_query_endpoint -->|"classifies in Jev or mock mode"| node_jev_adapter
node_query_endpoint -->|"classifies in Groq mode"| node_groq_adapter
node_query_endpoint -->|"routes judgment"| node_router
node_jev_adapter -->|"posts classification request"| node_jev_service
node_groq_adapter -->|"classifies query"| node_groq_service
node_jev_adapter -->|"uses provider settings"| node_settings
node_jev_adapter -->|"creates judgment"| node_contracts
node_jev_adapter -->|"uses mock rules"| node_task_signals
node_router -->|"selects configured model"| node_settings
node_router -->|"applies task floor"| node_task_signals
node_browser_api -->|"posts query"| node_query_endpoint
node_query_endpoint -->|"returns routing result"| node_app

click node_app "https://github.com/thakshil/routelab/blob/main/frontend/src/App.jsx"
click node_browser_api "https://github.com/thakshil/routelab/blob/main/frontend/src/services/api.js"
click node_frontend_entry "https://github.com/thakshil/routelab/blob/main/frontend/src/main.jsx"
click node_api_app "https://github.com/thakshil/routelab/blob/main/backend/app/main.py"
click node_query_endpoint "https://github.com/thakshil/routelab/blob/main/backend/app/api/query.py"
click node_contracts "https://github.com/thakshil/routelab/blob/main/backend/app/schemas.py"
click node_settings "https://github.com/thakshil/routelab/blob/main/backend/app/config.py"
click node_router "https://github.com/thakshil/routelab/blob/main/backend/app/services/router.py"
click node_task_signals "https://github.com/thakshil/routelab/blob/main/backend/app/services/task_signals.py"
click node_jev_adapter "https://github.com/thakshil/routelab/blob/main/backend/app/services/jev_client.py"
click node_groq_adapter "https://github.com/thakshil/routelab/blob/main/backend/app/services/groq_classifier.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_app,node_browser_api,node_frontend_entry,node_user toneBlue
class node_api_app,node_query_endpoint,node_contracts,node_settings toneAmber
class node_router,node_task_signals,node_groq_service toneMint
class node_jev_adapter,node_groq_adapter toneRose
class node_jev_service toneIndigo
```

## Components

### Browser UI

- [Query interface](https://github.com/thakshil/routelab/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Browser API client](https://github.com/thakshil/routelab/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [UI entry](https://github.com/thakshil/routelab/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### API and contracts

- [FastAPI application](https://github.com/thakshil/routelab/blob/main/backend/app/main.py): `backend/app/main.py`
- [Query endpoint](https://github.com/thakshil/routelab/blob/main/backend/app/api/query.py): `backend/app/api/query.py`
- [Request and response models](https://github.com/thakshil/routelab/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Runtime settings](https://github.com/thakshil/routelab/blob/main/backend/app/config.py): `backend/app/config.py`

### Routing policy

- [Tier selection policy](https://github.com/thakshil/routelab/blob/main/backend/app/services/router.py): `backend/app/services/router.py`
- [Task-shape rules](https://github.com/thakshil/routelab/blob/main/backend/app/services/task_signals.py): `backend/app/services/task_signals.py`

### Classification providers

- [Jev adapter and mock](https://github.com/thakshil/routelab/blob/main/backend/app/services/jev_client.py): `backend/app/services/jev_client.py`
- [Groq classifier](https://github.com/thakshil/routelab/blob/main/backend/app/services/groq_classifier.py): `backend/app/services/groq_classifier.py`

### Other components

- **User**
- **TypeSafe Jev**
- **Groq API**

## Connections

- User → Query interface: enters query (evidence: `frontend/src/App.jsx`)
- UI entry → Query interface: renders (evidence: `frontend/src/main.jsx`)
- Query interface → Browser API client: requests status and routing (evidence: `frontend/src/App.jsx`)
- Browser API client → FastAPI application: calls same-origin API (evidence: `README.md`)
- FastAPI application → Query endpoint: mounts route (evidence: `backend/app/main.py`)
- FastAPI application → Runtime settings: reads status mode (evidence: `backend/app/main.py`)
- Query endpoint → Runtime settings: loads settings (evidence: `backend/app/api/query.py`)
- Query endpoint → Request and response models: validates and returns (evidence: `backend/app/api/query.py`)
- Query endpoint → Jev adapter and mock: classifies in Jev or mock mode (evidence: `backend/app/api/query.py`)
- Query endpoint → Groq classifier: classifies in Groq mode (evidence: `backend/app/api/query.py`)
- Query endpoint → Tier selection policy: routes judgment (evidence: `backend/app/api/query.py`)
- Jev adapter and mock → TypeSafe Jev: posts classification request (evidence: `backend/app/services/jev_client.py`)
- Groq classifier → Groq API: classifies query (evidence: `README.md`)
- Jev adapter and mock → Runtime settings: uses provider settings (evidence: `backend/app/services/jev_client.py`)
- Jev adapter and mock → Request and response models: creates judgment (evidence: `backend/app/services/jev_client.py`)
- Jev adapter and mock → Task-shape rules: uses mock rules (evidence: `backend/app/services/jev_client.py`)
- Tier selection policy → Runtime settings: selects configured model (evidence: `backend/app/services/router.py`)
- Tier selection policy → Task-shape rules: applies task floor (evidence: `backend/app/services/router.py`)
- Browser API client → Query endpoint: posts query (evidence: `README.md`)
- Query endpoint → Query interface: returns routing result (evidence: `README.md`)
