# aaarya2117/quadrants architecture

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

- Interactive diagram: https://gitdiagram.com/aaarya2117/quadrants
- Repository: https://github.com/aaarya2117/quadrants

## Overview

ML Model Swap is a Python tool for comparing compatible model checkpoints, promoting a candidate by updating a role registry, smoke-testing the change, and rolling back. The main workflow starts at the CLI, runs through a shared command dispatcher and selected engine, then reaches comparison or swap logic; applications can separately load the registry’s active model at inference time. The README also describes MATLAB visualization, but no MATLAB source appears in the supplied tree, so that capability is not mapped as an implemented component.

Main entry points: [`modelswap/compare.py`](https://github.com/aaarya2117/quadrants/blob/main/modelswap/compare.py) (Model Comparison), [`modelswap/swap.py`](https://github.com/aaarya2117/quadrants/blob/main/modelswap/swap.py) (Swap and Rollback), [`modelswap/runtime.py`](https://github.com/aaarya2117/quadrants/blob/main/modelswap/runtime.py) (Role Runtime), [`modelswap/cli.py`](https://github.com/aaarya2117/quadrants/blob/main/modelswap/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and Demo"]
  node_cli["CLI<br/>[cli.py]"]
  node_demo["Scripted Demo<br/>[demo.py]"]
  node_commands["Command Dispatcher<br/>[commands.py]"]
  node_render["Result Rendering<br/>[render.py]"]
end

subgraph group_evaluation["Model Evaluation"]
  node_compare["Model Comparison<br/>[compare.py]"]
  node_architecture["Checkpoint Architecture<br/>[arch.py]"]
  node_evaluation_data["Evaluation Dataset<br/>[test.npz]"]
  node_checkpoints["Model Checkpoints<br/>[model_a.pt]"]
end

subgraph group_management["Swap Management"]
  node_engine_contract["Engine Selection<br/>[engine.py]"]
  node_stub_engine["Stub Backend<br/>[stub_engine.py]"]
  node_real_engine["Registry Backend<br/>[real_engine.py]"]
  node_results["Shared Result Types<br/>[results.py]"]
  node_swap["Swap and Rollback<br/>[swap.py]"]
  node_registry["Role Registry<br/>[models.yaml]"]
  node_audit_records[("Swap Audit Records")]
end

subgraph group_serving["Runtime Serving"]
  node_runtime["Role Runtime<br/>[runtime.py]"]
  node_active_model["Loaded Active Model<br/>[arch.py]"]
end

node_operator(("Operator"))
node_application(("Application"))

node_operator -->|"runs commands"| node_cli
node_cli -->|"selects backend"| node_engine_contract
node_cli -->|"dispatches operation"| node_commands
node_cli -->|"runs demo"| node_demo
node_demo -->|"executes steps"| node_commands
node_commands -->|"calls engine"| node_engine_contract
node_commands -->|"renders output"| node_render
node_engine_contract -->|"loads backend"| node_real_engine
node_engine_contract -->|"falls back"| node_stub_engine
node_real_engine -->|"resolves role"| node_runtime
node_real_engine -->|"compares models"| node_compare
node_real_engine -->|"applies or rolls back"| node_swap
node_compare -->|"checks signatures"| node_architecture
node_compare -->|"evaluates against"| node_evaluation_data
node_compare -.->|"loads candidates"| node_checkpoints
node_compare -->|"returns metrics"| node_results
node_swap -->|"updates atomically"| node_registry
node_swap -->|"smoke-tests model"| node_compare
node_swap -->|"writes audit"| node_audit_records
node_swap -->|"returns swap status"| node_results
node_runtime -->|"reads role config"| node_registry
node_runtime -->|"loads checkpoint"| node_architecture
node_application -->|"requests active role"| node_runtime
node_runtime -->|"returns loaded model"| node_active_model

click node_cli "https://github.com/aaarya2117/quadrants/blob/main/modelswap/cli.py"
click node_demo "https://github.com/aaarya2117/quadrants/blob/main/modelswap/demo.py"
click node_commands "https://github.com/aaarya2117/quadrants/blob/main/modelswap/commands.py"
click node_render "https://github.com/aaarya2117/quadrants/blob/main/modelswap/render.py"
click node_engine_contract "https://github.com/aaarya2117/quadrants/blob/main/modelswap/engine.py"
click node_stub_engine "https://github.com/aaarya2117/quadrants/blob/main/modelswap/stub_engine.py"
click node_real_engine "https://github.com/aaarya2117/quadrants/blob/main/modelswap/real_engine.py"
click node_compare "https://github.com/aaarya2117/quadrants/blob/main/modelswap/compare.py"
click node_architecture "https://github.com/aaarya2117/quadrants/blob/main/modelswap/arch.py"
click node_evaluation_data "https://github.com/aaarya2117/quadrants/blob/main/data/test.npz"
click node_checkpoints "https://github.com/aaarya2117/quadrants/blob/main/models/model_a.pt"
click node_results "https://github.com/aaarya2117/quadrants/blob/main/modelswap/results.py"
click node_swap "https://github.com/aaarya2117/quadrants/blob/main/modelswap/swap.py"
click node_registry "https://github.com/aaarya2117/quadrants/blob/main/models.yaml"
click node_runtime "https://github.com/aaarya2117/quadrants/blob/main/modelswap/runtime.py"
click node_active_model "https://github.com/aaarya2117/quadrants/blob/main/modelswap/arch.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_demo,node_commands,node_render toneBlue
class node_compare,node_architecture,node_evaluation_data,node_checkpoints toneAmber
class node_engine_contract,node_stub_engine,node_real_engine,node_results,node_swap,node_registry,node_audit_records toneMint
class node_runtime,node_active_model toneRose
class node_operator,node_application toneIndigo
```

## Components

### CLI and Demo

- [CLI](https://github.com/aaarya2117/quadrants/blob/main/modelswap/cli.py): `modelswap/cli.py`
- [Scripted Demo](https://github.com/aaarya2117/quadrants/blob/main/modelswap/demo.py): `modelswap/demo.py`
- [Command Dispatcher](https://github.com/aaarya2117/quadrants/blob/main/modelswap/commands.py): `modelswap/commands.py`
- [Result Rendering](https://github.com/aaarya2117/quadrants/blob/main/modelswap/render.py): `modelswap/render.py`

### Model Evaluation

- [Model Comparison](https://github.com/aaarya2117/quadrants/blob/main/modelswap/compare.py): `modelswap/compare.py`
- [Checkpoint Architecture](https://github.com/aaarya2117/quadrants/blob/main/modelswap/arch.py): `modelswap/arch.py`
- [Evaluation Dataset](https://github.com/aaarya2117/quadrants/blob/main/data/test.npz): `data/test.npz`
- [Model Checkpoints](https://github.com/aaarya2117/quadrants/blob/main/models/model_a.pt): `models/model_a.pt`

### Swap Management

- [Engine Selection](https://github.com/aaarya2117/quadrants/blob/main/modelswap/engine.py): `modelswap/engine.py`
- [Stub Backend](https://github.com/aaarya2117/quadrants/blob/main/modelswap/stub_engine.py): `modelswap/stub_engine.py`
- [Registry Backend](https://github.com/aaarya2117/quadrants/blob/main/modelswap/real_engine.py): `modelswap/real_engine.py`
- [Shared Result Types](https://github.com/aaarya2117/quadrants/blob/main/modelswap/results.py): `modelswap/results.py`
- [Swap and Rollback](https://github.com/aaarya2117/quadrants/blob/main/modelswap/swap.py): `modelswap/swap.py`
- [Role Registry](https://github.com/aaarya2117/quadrants/blob/main/models.yaml): `models.yaml`
- **Swap Audit Records**

### Runtime Serving

- [Role Runtime](https://github.com/aaarya2117/quadrants/blob/main/modelswap/runtime.py): `modelswap/runtime.py`
- [Loaded Active Model](https://github.com/aaarya2117/quadrants/blob/main/modelswap/arch.py): `modelswap/arch.py`

### Other components

- **Operator**
- **Application**

## Connections

- Operator → CLI: runs commands (evidence: `README.md`)
- CLI → Engine Selection: selects backend (evidence: `modelswap/cli.py`)
- CLI → Command Dispatcher: dispatches operation (evidence: `modelswap/cli.py`)
- CLI → Scripted Demo: runs demo (evidence: `modelswap/cli.py`)
- Scripted Demo → Command Dispatcher: executes steps (evidence: `modelswap/demo.py`)
- Command Dispatcher → Engine Selection: calls engine (evidence: `modelswap/commands.py`)
- Command Dispatcher → Result Rendering: renders output (evidence: `modelswap/commands.py`)
- Engine Selection → Registry Backend: loads backend (evidence: `modelswap/engine.py`)
- Engine Selection → Stub Backend: falls back (evidence: `modelswap/engine.py`)
- Registry Backend → Role Runtime: resolves role (evidence: `modelswap/real_engine.py`)
- Registry Backend → Model Comparison: compares models (evidence: `modelswap/real_engine.py`)
- Registry Backend → Swap and Rollback: applies or rolls back (evidence: `modelswap/real_engine.py`)
- Model Comparison → Checkpoint Architecture: checks signatures (evidence: `modelswap/compare.py`)
- Model Comparison → Evaluation Dataset: evaluates against (evidence: `modelswap/compare.py`)
- Model Comparison → Model Checkpoints: loads candidates
- Model Comparison → Shared Result Types: returns metrics (evidence: `modelswap/real_engine.py`)
- Swap and Rollback → Role Registry: updates atomically (evidence: `modelswap/swap.py`)
- Swap and Rollback → Model Comparison: smoke-tests model (evidence: `modelswap/swap.py`)
- Swap and Rollback → Swap Audit Records: writes audit (evidence: `modelswap/swap.py`)
- Swap and Rollback → Shared Result Types: returns swap status (evidence: `modelswap/real_engine.py`)
- Role Runtime → Role Registry: reads role config (evidence: `modelswap/runtime.py`)
- Role Runtime → Checkpoint Architecture: loads checkpoint (evidence: `modelswap/runtime.py`)
- Application → Role Runtime: requests active role (evidence: `README.md`)
- Role Runtime → Loaded Active Model: returns loaded model (evidence: `modelswap/runtime.py`)
