# mayank3613/ramllm architecture

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

- Interactive diagram: https://gitdiagram.com/mayank3613/ramllm
- Repository: https://github.com/mayank3613/ramllm

## Overview

RAMLLM profiles a machine, analyzes GGUF models, plans a feasible memory-tier placement and speed estimate, then launches inference through a backend while monitoring memory budgets. The README documents CLI workflows for profiling, planning, running, and inspecting dependencies; the API exposes OpenAI-compatible inference and RAMLLM plan/metrics endpoints. Source evidence is partial: unsampled major capabilities are represented where documented, but uncertain implementation links are omitted.

Main entry points: [`src/ramllm/cli/main.py`](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/cli/main.py) (CLI commands), [`src/ramllm/api/server.py`](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/api/server.py) (HTTP API), [`src/ramllm/core/planner/candidates.py`](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/candidates.py) (Placement candidates), [`src/ramllm/core/planner/planner.py`](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/planner.py) (Plan coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_cli["CLI commands<br/>[main.py]"]
  node_api["HTTP API<br/>[server.py]"]
end

subgraph group_hardware["Hardware profiling"]
  node_profiler["Hardware profiler<br/>[prober.py]"]
  node_gpu_probe["GPU probes<br/>[gpu_nvidia.py]"]
end

subgraph group_planning["Model analysis and planning"]
  node_schemas["Domain schemas<br/>[schemas.py]"]
  node_gguf["GGUF analyzer<br/>[gguf.py]"]
  node_moe["MoE analysis<br/>[moe.py]"]
  node_kv["KV sizing<br/>[kv.py]"]
  node_planner["Plan coordinator<br/>[planner.py]"]
  node_candidates["Placement candidates<br/>[candidates.py]"]
  node_cost["Speed model<br/>[cost_model.py]"]
  node_feasibility["Feasibility verdict<br/>[feasibility.py]"]
  node_recommend["Model recommender<br/>[recommend.py]"]
  node_calibration["Speed calibration<br/>[calibration.py]"]
end

subgraph group_runtime["Inference runtime"]
  node_backend["Backend interface<br/>[base.py]"]
  node_llamacpp["llama.cpp adapter<br/>[adapter.py]"]
  node_governor["Memory governor<br/>[monitor.py]"]
  node_enforcement["OS enforcement<br/>[base.py]"]
end

subgraph group_catalog["Model catalog"]
  node_catalog_store[("Local catalog<br/>[catalog.py]")]
  node_downloads["Model downloads<br/>[download.py]"]
end

node_user(("Operator"))
node_backend_service["Backend engine"]
node_client(("API client"))

node_user -->|"runs commands"| node_cli
node_user -->|"starts server"| node_api
node_cli -->|"profiles hardware"| node_profiler
node_profiler -->|"probes GPUs"| node_gpu_probe
node_cli -->|"analyzes model"| node_gguf
node_gguf -->|"uses MoE analysis"| node_moe
node_cli -->|"requests plans"| node_planner
node_planner -->|"generates candidates"| node_candidates
node_planner -->|"checks feasibility"| node_feasibility
node_candidates -->|"sizes KV cache"| node_kv
node_candidates -->|"sizes expert sets"| node_moe
node_candidates -->|"estimates speed"| node_cost
node_candidates -->|"reads calibration"| node_calibration
node_cli -->|"requests recommendations"| node_recommend
node_recommend -->|"analyzes catalog models"| node_gguf
node_recommend -->|"plans candidates"| node_planner
node_recommend -->|"lists models"| node_catalog_store
node_catalog_store -->|"analyzes added model"| node_gguf
node_cli -->|"manages catalog"| node_catalog_store
node_cli -->|"downloads models"| node_downloads
node_api -->|"analyzes model"| node_gguf
node_api -->|"creates execution plan"| node_planner
node_api -->|"probes hardware"| node_profiler
node_api -->|"launches through"| node_backend
node_api -->|"starts monitoring"| node_governor
node_governor -->|"samples process"| node_backend
node_governor -->|"applies limits"| node_enforcement
node_llamacpp -->|"implements interface"| node_backend
node_backend -.->|"launches engine"| node_backend_service
node_client -->|"requests completions"| node_api

click node_cli "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/cli/main.py"
click node_api "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/api/server.py"
click node_profiler "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/profiler/prober.py"
click node_gpu_probe "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/profiler/gpu_nvidia.py"
click node_schemas "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/schemas.py"
click node_gguf "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/analyzer/gguf.py"
click node_moe "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/analyzer/moe.py"
click node_kv "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/analyzer/kv.py"
click node_planner "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/planner.py"
click node_candidates "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/candidates.py"
click node_cost "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/cost_model.py"
click node_feasibility "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/feasibility.py"
click node_recommend "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/recommend.py"
click node_calibration "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/telemetry/calibration.py"
click node_backend "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/backends/base.py"
click node_llamacpp "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/backends/llamacpp/adapter.py"
click node_governor "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/governor/monitor.py"
click node_enforcement "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/governor/enforcement/base.py"
click node_catalog_store "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/registry/catalog.py"
click node_downloads "https://github.com/mayank3613/ramllm/blob/main/src/ramllm/registry/download.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_api,node_client toneBlue
class node_profiler,node_gpu_probe toneAmber
class node_schemas,node_gguf,node_moe,node_kv,node_planner,node_candidates,node_cost,node_feasibility,node_recommend,node_calibration toneMint
class node_backend,node_llamacpp,node_governor,node_enforcement toneRose
class node_catalog_store,node_downloads,node_user,node_backend_service toneIndigo
```

## Components

### User interfaces

- [CLI commands](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/cli/main.py): `src/ramllm/cli/main.py`
- [HTTP API](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/api/server.py): `src/ramllm/api/server.py`

### Hardware profiling

- [Hardware profiler](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/profiler/prober.py): `src/ramllm/core/profiler/prober.py`
- [GPU probes](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/profiler/gpu_nvidia.py): `src/ramllm/core/profiler/gpu_nvidia.py`

### Model analysis and planning

- [Domain schemas](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/schemas.py): `src/ramllm/core/schemas.py`
- [GGUF analyzer](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/analyzer/gguf.py): `src/ramllm/core/analyzer/gguf.py`
- [MoE analysis](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/analyzer/moe.py): `src/ramllm/core/analyzer/moe.py`
- [KV sizing](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/analyzer/kv.py): `src/ramllm/core/analyzer/kv.py`
- [Plan coordinator](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/planner.py): `src/ramllm/core/planner/planner.py`
- [Placement candidates](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/candidates.py): `src/ramllm/core/planner/candidates.py`
- [Speed model](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/cost_model.py): `src/ramllm/core/planner/cost_model.py`
- [Feasibility verdict](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/feasibility.py): `src/ramllm/core/planner/feasibility.py`
- [Model recommender](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/planner/recommend.py): `src/ramllm/core/planner/recommend.py`
- [Speed calibration](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/telemetry/calibration.py): `src/ramllm/telemetry/calibration.py`

### Inference runtime

- [Backend interface](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/backends/base.py): `src/ramllm/backends/base.py`
- [llama.cpp adapter](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/backends/llamacpp/adapter.py): `src/ramllm/backends/llamacpp/adapter.py`
- [Memory governor](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/governor/monitor.py): `src/ramllm/core/governor/monitor.py`
- [OS enforcement](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/core/governor/enforcement/base.py): `src/ramllm/core/governor/enforcement/base.py`

### Model catalog

- [Local catalog](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/registry/catalog.py): `src/ramllm/registry/catalog.py`
- [Model downloads](https://github.com/mayank3613/ramllm/blob/main/src/ramllm/registry/download.py): `src/ramllm/registry/download.py`

### Other components

- **Operator**
- **Backend engine**
- **API client**

## Connections

- Operator → CLI commands: runs commands (evidence: `README.md`)
- Operator → HTTP API: starts server (evidence: `README.md`)
- CLI commands → Hardware profiler: profiles hardware (evidence: `src/ramllm/cli/main.py`)
- Hardware profiler → GPU probes: probes GPUs (evidence: `src/ramllm/core/profiler/prober.py`)
- CLI commands → GGUF analyzer: analyzes model (evidence: `src/ramllm/cli/main.py`)
- GGUF analyzer → MoE analysis: uses MoE analysis (evidence: `src/ramllm/core/analyzer/gguf.py`)
- CLI commands → Plan coordinator: requests plans (evidence: `src/ramllm/cli/main.py`)
- Plan coordinator → Placement candidates: generates candidates (evidence: `src/ramllm/core/planner/planner.py`)
- Plan coordinator → Feasibility verdict: checks feasibility (evidence: `src/ramllm/core/planner/planner.py`)
- Placement candidates → KV sizing: sizes KV cache (evidence: `src/ramllm/core/planner/candidates.py`)
- Placement candidates → MoE analysis: sizes expert sets (evidence: `src/ramllm/core/planner/candidates.py`)
- Placement candidates → Speed model: estimates speed (evidence: `src/ramllm/core/planner/candidates.py`)
- Placement candidates → Speed calibration: reads calibration (evidence: `src/ramllm/core/planner/candidates.py`)
- CLI commands → Model recommender: requests recommendations (evidence: `src/ramllm/cli/main.py`)
- Model recommender → GGUF analyzer: analyzes catalog models (evidence: `src/ramllm/core/planner/recommend.py`)
- Model recommender → Plan coordinator: plans candidates (evidence: `src/ramllm/core/planner/recommend.py`)
- Model recommender → Local catalog: lists models (evidence: `src/ramllm/core/planner/recommend.py`)
- Local catalog → GGUF analyzer: analyzes added model (evidence: `src/ramllm/registry/catalog.py`)
- CLI commands → Local catalog: manages catalog (evidence: `src/ramllm/cli/main.py`)
- CLI commands → Model downloads: downloads models (evidence: `src/ramllm/cli/main.py`)
- HTTP API → GGUF analyzer: analyzes model (evidence: `src/ramllm/api/server.py`)
- HTTP API → Plan coordinator: creates execution plan (evidence: `src/ramllm/api/server.py`)
- HTTP API → Hardware profiler: probes hardware (evidence: `src/ramllm/api/server.py`)
- HTTP API → Backend interface: launches through (evidence: `src/ramllm/api/server.py`)
- HTTP API → Memory governor: starts monitoring (evidence: `src/ramllm/api/server.py`)
- Memory governor → Backend interface: samples process (evidence: `src/ramllm/core/governor/monitor.py`)
- Memory governor → OS enforcement: applies limits (evidence: `src/ramllm/core/governor/monitor.py`)
- llama.cpp adapter → Backend interface: implements interface
- Backend interface → Backend engine: launches engine
- API client → HTTP API: requests completions (evidence: `src/ramllm/api/server.py`)
