# sodium16/slmforge architecture

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

- Interactive diagram: https://gitdiagram.com/sodium16/slmforge
- Repository: https://github.com/sodium16/slmforge

## Overview

SLMForge is a demo application that turns a natural-language request into a task-specific small-language-model build. The intended path runs from request analysis and dataset preparation through model selection, baseline, training, evaluation, and deployment; README status notes that only the early stages are implemented, while later stages honestly return 501. The dashboard and API initiate work, with queued jobs handled by a worker. Relationships for unsampled routes and later-stage implementations are shown only where the README documents them; the graph does not imply those stages are complete.

Main entry points: [`src/slmforge/pipeline/orchestrator.py`](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/orchestrator.py) (Stage orchestrator), [`src/slmforge/main.py`](https://github.com/sodium16/slmforge/blob/main/src/slmforge/main.py) (FastAPI service), [`web/src/api.ts`](https://github.com/sodium16/slmforge/blob/main/web/src/api.ts) (Typed API client), [`web/src/App.tsx`](https://github.com/sodium16/slmforge/blob/main/web/src/App.tsx) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Dashboard<br/>[App.tsx]"]
  node_project_views["Project views<br/>[ProjectDetail.tsx]"]
  node_dataset_panel["Dataset review<br/>[DatasetPanel.tsx]"]
  node_api_client["Typed API client<br/>[api.ts]"]
end

subgraph group_service["API and workflow"]
  node_api_service["FastAPI service<br/>[main.py]"]
  node_project_routes["Project and stage routes<br/>[projects.py]"]
  node_stage_routes["Stage routes<br/>[stages.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_orchestrator["Stage orchestrator<br/>[orchestrator.py]"]
end

subgraph group_pipeline["Build stages"]
  node_analyzer["Request analysis<br/>[analyzer.py]"]
  node_dataset_curator["Dataset curation<br/>[datasets.py]"]
  node_model_selection["Model selection<br/>[planner.py]"]
  node_baseline["Baseline evaluation<br/>[baseline.py]"]
  node_training_plan["Training plan<br/>[planner.py]"]
  node_trainer["Fine-tuning<br/>[trainer.py]"]
  node_evaluation["Model evaluation<br/>[evaluator.py]"]
  node_deployment["Endpoint deployment<br/>[deployer.py]"]
end

subgraph group_execution["Jobs and sandbox"]
  node_job_queue["Job queue<br/>[queue.py]"]
  node_worker["Background worker<br/>[worker.py]"]
  node_job_handlers["Job handlers<br/>[handlers.py]"]
  node_sandbox["Sandbox runtime<br/>[base.py]"]
end

subgraph group_connectors["Persistence and integrations"]
  node_database[("Project database<br/>[db.py]")]
  node_data_connectors["Hub and data tools<br/>[hf_cli.py]"]
  node_planner_llm["Planner LLM<br/>[llm.py]"]
end

node_user(("Build requester"))
node_huggingface["Hugging Face"]
node_callable_endpoint(("Callable endpoint"))

node_user -->|"describes need"| node_dashboard
node_dashboard -->|"opens project"| node_project_views
node_project_views -->|"shows curation"| node_dataset_panel
node_dashboard -->|"requests data"| node_api_client
node_project_views -->|"requests project data"| node_api_client
node_dataset_panel -->|"approves dataset"| node_api_client
node_api_client -->|"sends HTTP requests"| node_api_service
node_api_service -->|"mounts API"| node_project_routes
node_api_service -->|"mounts API"| node_stage_routes
node_api_service -->|"mounts API"| node_auth_routes
node_project_routes -.->|"persists projects"| node_database
node_stage_routes -.->|"runs stages"| node_orchestrator
node_orchestrator -->|"records runs and events"| node_database
node_orchestrator -.->|"runs stage"| node_analyzer
node_orchestrator -.->|"runs stage"| node_dataset_curator
node_orchestrator -.->|"runs stage"| node_model_selection
node_orchestrator -.->|"runs stage"| node_baseline
node_orchestrator -.->|"runs stage"| node_training_plan
node_orchestrator -.->|"runs stage"| node_trainer
node_orchestrator -.->|"runs stage"| node_evaluation
node_orchestrator -.->|"runs stage"| node_deployment
node_analyzer -.->|"consults planner"| node_planner_llm
node_dataset_curator -->|"profiles and fetches data"| node_data_connectors
node_data_connectors -.->|"queries Hub"| node_huggingface
node_api_service -.->|"queues long work"| node_job_queue
node_worker -->|"claims jobs"| node_job_queue
node_worker -->|"dispatches jobs"| node_job_handlers
node_job_handlers -->|"runs stage"| node_orchestrator
node_job_handlers -.->|"resolves sandbox"| node_sandbox
node_deployment -.->|"publishes endpoint"| node_callable_endpoint
node_auth_routes -.->|"signs in"| node_huggingface

click node_dashboard "https://github.com/sodium16/slmforge/blob/main/web/src/App.tsx"
click node_project_views "https://github.com/sodium16/slmforge/blob/main/web/src/components/ProjectDetail.tsx"
click node_dataset_panel "https://github.com/sodium16/slmforge/blob/main/web/src/components/DatasetPanel.tsx"
click node_api_client "https://github.com/sodium16/slmforge/blob/main/web/src/api.ts"
click node_api_service "https://github.com/sodium16/slmforge/blob/main/src/slmforge/main.py"
click node_project_routes "https://github.com/sodium16/slmforge/blob/main/src/slmforge/api/routes/projects.py"
click node_stage_routes "https://github.com/sodium16/slmforge/blob/main/src/slmforge/api/routes/stages.py"
click node_auth_routes "https://github.com/sodium16/slmforge/blob/main/src/slmforge/api/routes/auth.py"
click node_orchestrator "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/orchestrator.py"
click node_analyzer "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/analyzer.py"
click node_dataset_curator "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/datasets.py"
click node_model_selection "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/planner.py"
click node_baseline "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/baseline.py"
click node_training_plan "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/planner.py"
click node_trainer "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/trainer.py"
click node_evaluation "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/evaluator.py"
click node_deployment "https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/deployer.py"
click node_job_queue "https://github.com/sodium16/slmforge/blob/main/src/slmforge/jobs/queue.py"
click node_worker "https://github.com/sodium16/slmforge/blob/main/src/slmforge/jobs/worker.py"
click node_job_handlers "https://github.com/sodium16/slmforge/blob/main/src/slmforge/jobs/handlers.py"
click node_sandbox "https://github.com/sodium16/slmforge/blob/main/src/slmforge/sandbox/base.py"
click node_database "https://github.com/sodium16/slmforge/blob/main/src/slmforge/db.py"
click node_data_connectors "https://github.com/sodium16/slmforge/blob/main/src/slmforge/integrations/hf_cli.py"
click node_planner_llm "https://github.com/sodium16/slmforge/blob/main/src/slmforge/integrations/llm.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_dashboard,node_project_views,node_dataset_panel,node_api_client toneBlue
class node_api_service,node_project_routes,node_stage_routes,node_auth_routes,node_orchestrator toneAmber
class node_analyzer,node_dataset_curator,node_model_selection,node_baseline,node_training_plan,node_trainer,node_evaluation,node_deployment,node_user toneMint
class node_job_queue,node_worker,node_job_handlers,node_sandbox toneRose
class node_database,node_data_connectors,node_planner_llm,node_huggingface,node_callable_endpoint toneIndigo
```

## Components

### User experience

- [Dashboard](https://github.com/sodium16/slmforge/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Project views](https://github.com/sodium16/slmforge/blob/main/web/src/components/ProjectDetail.tsx): `web/src/components/ProjectDetail.tsx`
- [Dataset review](https://github.com/sodium16/slmforge/blob/main/web/src/components/DatasetPanel.tsx): `web/src/components/DatasetPanel.tsx`
- [Typed API client](https://github.com/sodium16/slmforge/blob/main/web/src/api.ts): `web/src/api.ts`

### API and workflow

- [FastAPI service](https://github.com/sodium16/slmforge/blob/main/src/slmforge/main.py): `src/slmforge/main.py`
- [Project and stage routes](https://github.com/sodium16/slmforge/blob/main/src/slmforge/api/routes/projects.py): `src/slmforge/api/routes/projects.py`
- [Stage routes](https://github.com/sodium16/slmforge/blob/main/src/slmforge/api/routes/stages.py): `src/slmforge/api/routes/stages.py`
- [Authentication routes](https://github.com/sodium16/slmforge/blob/main/src/slmforge/api/routes/auth.py): `src/slmforge/api/routes/auth.py`
- [Stage orchestrator](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/orchestrator.py): `src/slmforge/pipeline/orchestrator.py`

### Build stages

- [Request analysis](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/analyzer.py): `src/slmforge/pipeline/analyzer.py`
- [Dataset curation](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/datasets.py): `src/slmforge/pipeline/datasets.py`
- [Model selection](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/planner.py): `src/slmforge/pipeline/planner.py`
- [Baseline evaluation](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/baseline.py): `src/slmforge/pipeline/baseline.py`
- [Training plan](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/planner.py): `src/slmforge/pipeline/planner.py`
- [Fine-tuning](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/trainer.py): `src/slmforge/pipeline/trainer.py`
- [Model evaluation](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/evaluator.py): `src/slmforge/pipeline/evaluator.py`
- [Endpoint deployment](https://github.com/sodium16/slmforge/blob/main/src/slmforge/pipeline/deployer.py): `src/slmforge/pipeline/deployer.py`

### Jobs and sandbox

- [Job queue](https://github.com/sodium16/slmforge/blob/main/src/slmforge/jobs/queue.py): `src/slmforge/jobs/queue.py`
- [Background worker](https://github.com/sodium16/slmforge/blob/main/src/slmforge/jobs/worker.py): `src/slmforge/jobs/worker.py`
- [Job handlers](https://github.com/sodium16/slmforge/blob/main/src/slmforge/jobs/handlers.py): `src/slmforge/jobs/handlers.py`
- [Sandbox runtime](https://github.com/sodium16/slmforge/blob/main/src/slmforge/sandbox/base.py): `src/slmforge/sandbox/base.py`

### Persistence and integrations

- [Project database](https://github.com/sodium16/slmforge/blob/main/src/slmforge/db.py): `src/slmforge/db.py`
- [Hub and data tools](https://github.com/sodium16/slmforge/blob/main/src/slmforge/integrations/hf_cli.py): `src/slmforge/integrations/hf_cli.py`
- [Planner LLM](https://github.com/sodium16/slmforge/blob/main/src/slmforge/integrations/llm.py): `src/slmforge/integrations/llm.py`

### Other components

- **Build requester**
- **Hugging Face**
- **Callable endpoint**

## Connections

- Build requester → Dashboard: describes need (evidence: `README.md`)
- Dashboard → Project views: opens project (evidence: `web/src/App.tsx`)
- Project views → Dataset review: shows curation (evidence: `web/src/components/ProjectDetail.tsx`)
- Dashboard → Typed API client: requests data (evidence: `web/src/App.tsx`)
- Project views → Typed API client: requests project data (evidence: `web/src/components/ProjectDetail.tsx`)
- Dataset review → Typed API client: approves dataset (evidence: `web/src/components/DatasetPanel.tsx`)
- Typed API client → FastAPI service: sends HTTP requests (evidence: `README.md`)
- FastAPI service → Project and stage routes: mounts API (evidence: `src/slmforge/main.py`)
- FastAPI service → Stage routes: mounts API (evidence: `src/slmforge/main.py`)
- FastAPI service → Authentication routes: mounts API (evidence: `src/slmforge/main.py`)
- Project and stage routes → Project database: persists projects
- Stage routes → Stage orchestrator: runs stages
- Stage orchestrator → Project database: records runs and events (evidence: `src/slmforge/pipeline/orchestrator.py`)
- Stage orchestrator → Request analysis: runs stage
- Stage orchestrator → Dataset curation: runs stage
- Stage orchestrator → Model selection: runs stage
- Stage orchestrator → Baseline evaluation: runs stage
- Stage orchestrator → Training plan: runs stage
- Stage orchestrator → Fine-tuning: runs stage
- Stage orchestrator → Model evaluation: runs stage
- Stage orchestrator → Endpoint deployment: runs stage
- Request analysis → Planner LLM: consults planner (evidence: `README.md`)
- Dataset curation → Hub and data tools: profiles and fetches data (evidence: `src/slmforge/pipeline/datasets.py`)
- Hub and data tools → Hugging Face: queries Hub (evidence: `README.md`)
- FastAPI service → Job queue: queues long work (evidence: `README.md`)
- Background worker → Job queue: claims jobs (evidence: `src/slmforge/jobs/worker.py`)
- Background worker → Job handlers: dispatches jobs (evidence: `src/slmforge/jobs/worker.py`)
- Job handlers → Stage orchestrator: runs stage (evidence: `src/slmforge/jobs/handlers.py`)
- Job handlers → Sandbox runtime: resolves sandbox (evidence: `src/slmforge/jobs/handlers.py`)
- Endpoint deployment → Callable endpoint: publishes endpoint (evidence: `README.md`)
- Authentication routes → Hugging Face: signs in (evidence: `README.md`)
