# dipesh10110n1/llm-local-runtime-optimizer-main architecture

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

- Interactive diagram: https://gitdiagram.com/dipesh10110n1/llm-local-runtime-optimizer-main
- Repository: https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main

## Overview

Local LLM Runtime Optimizer selects tested configurations using quality, latency, memory, and optional energy evidence, then serves local inference. The main workflow is a request to optimize or generate, configuration selection, prompt preparation and local runtime execution, followed by telemetry recording. Separate branches cover calibration/evidence reporting and hardware-energy capability. The API excerpts show optimization and selection persistence; README and source-index references establish other major capabilities, but unsampled call details are not assumed.

Main entry points: [`api/app.py`](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/api/app.py) (REST API), [`optimizer/live_comparator.py`](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/live_comparator.py) (Live comparison), [`runtime/clients.py`](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/runtime/clients.py) (Inference clients), [`optimizer/request_router.py`](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/request_router.py) (Request router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_api["REST API<br/>[app.py]"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
end

subgraph group_selection["Configuration selection"]
  node_model_registry["Model registry<br/>[model_registry.py]"]
  node_request_router["Request router<br/>[request_router.py]"]
  node_optimizer["Profile optimizer<br/>[optimizer.py]"]
  node_scoring["Candidate scoring<br/>[scoring_engine.py]"]
  node_catalog["Configuration catalog"]
  node_live_comparator["Live comparison<br/>[live_comparator.py]"]
end

subgraph group_evidence["Evidence and calibration"]
  node_calibration["Calibrated profiles"]
  node_evidence_report["Evidence reports<br/>[evidence_report.py]"]
  node_dataset_loader["Dataset loading<br/>[dataset_loader.py]"]
end

subgraph group_inference["Local inference"]
  node_prompt_pipeline["Prompt preparation<br/>[prompt_pipeline.py]"]
  node_supervisor["Runtime supervisor<br/>[supervisor.py]"]
  node_clients["Inference clients<br/>[clients.py]"]
  node_energy["Energy capability"]
end

subgraph group_state["Telemetry and state"]
  node_telemetry["Telemetry service<br/>[telemetry.py]"]
  node_repository[("Database repository<br/>[repository.py]")]
  node_schema[("Database schema<br/>[schema.py]")]
end

node_user(("User"))
node_llama_server{{"Local model server"}}

node_user -->|"submits request"| node_api
node_user -->|"uses"| node_dashboard
node_api -->|"optimizes"| node_optimizer
node_api -->|"lists models"| node_model_registry
node_api -.->|"routes generation"| node_request_router
node_api -.->|"requests comparison"| node_live_comparator
node_api -.->|"prepares prompt"| node_prompt_pipeline
node_api -.->|"ensures runtime"| node_supervisor
node_api -.->|"generates response"| node_clients
node_api -->|"records selection"| node_telemetry
node_dashboard -->|"loads models"| node_model_registry
node_dashboard -.->|"requests comparison"| node_live_comparator
node_optimizer -->|"scores candidates"| node_scoring
node_optimizer -->|"uses profiles"| node_calibration
node_request_router -->|"reads calibration"| node_calibration
node_request_router -->|"records selection"| node_telemetry
node_live_comparator -->|"uses configurations"| node_catalog
node_live_comparator -->|"routes request"| node_request_router
node_live_comparator -->|"runs comparisons"| node_clients
node_live_comparator -->|"prepares prompts"| node_prompt_pipeline
node_evidence_report -->|"loads benchmark data"| node_dataset_loader
node_evidence_report -->|"uses profiles"| node_calibration
node_prompt_pipeline -.->|"supplies prompt"| node_clients
node_supervisor -->|"checks backend"| node_clients
node_clients -->|"sends inference"| node_llama_server
node_clients -->|"checks readings"| node_energy
node_telemetry -->|"persists records"| node_repository
node_repository -->|"uses tables"| node_schema

click node_api "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/api/app.py"
click node_dashboard "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/dashboard.py"
click node_model_registry "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/core/model_registry.py"
click node_request_router "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/request_router.py"
click node_optimizer "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/optimizer.py"
click node_scoring "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/scoring_engine.py"
click node_catalog "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/configuration_catalog.py"
click node_live_comparator "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/live_comparator.py"
click node_calibration "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/calibrated_profiles.py"
click node_evidence_report "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/evidence_report.py"
click node_dataset_loader "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/datasets/dataset_loader.py"
click node_prompt_pipeline "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/runtime/prompt_pipeline.py"
click node_supervisor "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/runtime/supervisor.py"
click node_clients "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/runtime/clients.py"
click node_energy "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/hardware/energy_capability.py"
click node_telemetry "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/database/telemetry.py"
click node_repository "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/database/repository.py"
click node_schema "https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/database/schema.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_api,node_dashboard,node_user toneBlue
class node_model_registry,node_request_router,node_optimizer,node_scoring,node_catalog,node_live_comparator toneAmber
class node_calibration,node_evidence_report,node_dataset_loader,node_llama_server toneMint
class node_prompt_pipeline,node_supervisor,node_clients,node_energy toneRose
class node_telemetry,node_repository,node_schema toneIndigo
```

## Components

### User interfaces

- [REST API](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/api/app.py): `api/app.py`
- [Dashboard](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/dashboard.py): `dashboard.py`

### Configuration selection

- [Model registry](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/core/model_registry.py): `core/model_registry.py`
- [Request router](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/request_router.py): `optimizer/request_router.py`
- [Profile optimizer](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/optimizer.py): `optimizer/optimizer.py`
- [Candidate scoring](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/scoring_engine.py): `optimizer/scoring_engine.py`
- [Configuration catalog](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/configuration_catalog.py): `optimizer/configuration_catalog.py`
- [Live comparison](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/live_comparator.py): `optimizer/live_comparator.py`

### Evidence and calibration

- [Calibrated profiles](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/calibrated_profiles.py): `optimizer/calibrated_profiles.py`
- [Evidence reports](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/optimizer/evidence_report.py): `optimizer/evidence_report.py`
- [Dataset loading](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/datasets/dataset_loader.py): `datasets/dataset_loader.py`

### Local inference

- [Prompt preparation](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/runtime/prompt_pipeline.py): `runtime/prompt_pipeline.py`
- [Runtime supervisor](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/runtime/supervisor.py): `runtime/supervisor.py`
- [Inference clients](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/runtime/clients.py): `runtime/clients.py`
- [Energy capability](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/hardware/energy_capability.py): `hardware/energy_capability.py`

### Telemetry and state

- [Telemetry service](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/database/telemetry.py): `database/telemetry.py`
- [Database repository](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/database/repository.py): `database/repository.py`
- [Database schema](https://github.com/dipesh10110n1/llm-local-runtime-optimizer-main/blob/main/database/schema.py): `database/schema.py`

### Other components

- **User**
- **Local model server**

## Connections

- User → REST API: submits request (evidence: `README.md`)
- User → Dashboard: uses (evidence: `README.md`)
- REST API → Profile optimizer: optimizes (evidence: `api/app.py`)
- REST API → Model registry: lists models (evidence: `api/app.py`)
- REST API → Request router: routes generation (evidence: `api/app.py`)
- REST API → Live comparison: requests comparison (evidence: `api/app.py`)
- REST API → Prompt preparation: prepares prompt (evidence: `api/app.py`)
- REST API → Runtime supervisor: ensures runtime (evidence: `api/app.py`)
- REST API → Inference clients: generates response (evidence: `api/app.py`)
- REST API → Telemetry service: records selection (evidence: `api/app.py`)
- Dashboard → Model registry: loads models (evidence: `dashboard.py`)
- Dashboard → Live comparison: requests comparison (evidence: `dashboard.py`)
- Profile optimizer → Candidate scoring: scores candidates (evidence: `optimizer/optimizer.py`)
- Profile optimizer → Calibrated profiles: uses profiles (evidence: `optimizer/optimizer.py`)
- Request router → Calibrated profiles: reads calibration (evidence: `optimizer/request_router.py`)
- Request router → Telemetry service: records selection (evidence: `optimizer/request_router.py`)
- Live comparison → Configuration catalog: uses configurations (evidence: `optimizer/live_comparator.py`)
- Live comparison → Request router: routes request (evidence: `optimizer/live_comparator.py`)
- Live comparison → Inference clients: runs comparisons (evidence: `optimizer/live_comparator.py`)
- Live comparison → Prompt preparation: prepares prompts (evidence: `optimizer/live_comparator.py`)
- Evidence reports → Dataset loading: loads benchmark data (evidence: `optimizer/evidence_report.py`)
- Evidence reports → Calibrated profiles: uses profiles (evidence: `optimizer/evidence_report.py`)
- Prompt preparation → Inference clients: supplies prompt
- Runtime supervisor → Inference clients: checks backend (evidence: `runtime/supervisor.py`)
- Inference clients → Local model server: sends inference (evidence: `runtime/clients.py`)
- Inference clients → Energy capability: checks readings (evidence: `runtime/clients.py`)
- Telemetry service → Database repository: persists records (evidence: `database/telemetry.py`)
- Database repository → Database schema: uses tables (evidence: `database/repository.py`)
