# sahiljain6/promptlab architecture

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

- Interactive diagram: https://gitdiagram.com/sahiljain6/promptlab
- Repository: https://github.com/sahiljain6/promptlab

## Overview

PromptLab is a Streamlit research app for comparing code-generation models across prompt techniques. Users submit a coding request or choose a preset; the app builds one shared task specification, runs provider/technique trials, evaluates generated solutions, scores and ranks results, then presents outputs and experiment history. Major supporting capabilities include emergency Gemini fallback, configurable scoring, safe evaluation modes, and SQLite-backed history and usage quotas. The graph follows the documented workflow and indexed references; where excerpts do not expose a call directly, relationships are documented or omitted.

Main entry points: [`app.py`](https://github.com/sahiljain6/promptlab/blob/main/app.py) (Streamlit app), [`promptlab/provider.py`](https://github.com/sahiljain6/promptlab/blob/main/promptlab/provider.py) (Model provider client), [`promptlab/pipeline.py`](https://github.com/sahiljain6/promptlab/blob/main/promptlab/pipeline.py) (Trial orchestration), [`promptlab/tasks.py`](https://github.com/sahiljain6/promptlab/blob/main/promptlab/tasks.py) (Task specification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["App interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_generation["Task and generation"]
  node_tasks["Task specification<br/>[tasks.py]"]
  node_prompts["Prompt techniques<br/>[prompts.py]"]
  node_pipeline["Trial orchestration<br/>[pipeline.py]"]
  node_provider["Model provider client<br/>[provider.py]"]
end

subgraph group_evaluation["Evaluation and ranking"]
  node_sandbox["Solution evaluation<br/>[sandbox.py]"]
  node_scoring["Scoring and ranking<br/>[scoring.py]"]
end

subgraph group_persistence["History and quota"]
  node_history[("Experiment history<br/>[storage.py]")]
end

node_user(("Researcher"))
node_groq["Groq API"]
node_ollama["Ollama API"]
node_gemini["Gemini backup"]

node_user -->|"submits task"| node_app
node_app -->|"requests specification"| node_tasks
node_tasks -->|"requests generation"| node_provider
node_app -->|"configures models"| node_provider
node_app -->|"starts comparison"| node_pipeline
node_pipeline -->|"builds prompts"| node_prompts
node_pipeline -->|"generates solutions"| node_provider
node_provider -->|"calls API"| node_groq
node_provider -->|"calls API"| node_ollama
node_provider -.->|"fallback calls"| node_gemini
node_pipeline -->|"evaluates solutions"| node_sandbox
node_pipeline -->|"annotates trials"| node_scoring
node_app -->|"ranks results"| node_scoring
node_app -->|"saves and reads"| node_history
node_app -->|"shows results"| node_user

click node_app "https://github.com/sahiljain6/promptlab/blob/main/app.py"
click node_tasks "https://github.com/sahiljain6/promptlab/blob/main/promptlab/tasks.py"
click node_prompts "https://github.com/sahiljain6/promptlab/blob/main/promptlab/prompts.py"
click node_pipeline "https://github.com/sahiljain6/promptlab/blob/main/promptlab/pipeline.py"
click node_provider "https://github.com/sahiljain6/promptlab/blob/main/promptlab/provider.py"
click node_sandbox "https://github.com/sahiljain6/promptlab/blob/main/promptlab/sandbox.py"
click node_scoring "https://github.com/sahiljain6/promptlab/blob/main/promptlab/scoring.py"
click node_history "https://github.com/sahiljain6/promptlab/blob/main/promptlab/storage.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 toneBlue
class node_tasks,node_prompts,node_pipeline,node_provider toneAmber
class node_sandbox,node_scoring,node_groq,node_ollama toneMint
class node_history toneRose
class node_user,node_gemini toneIndigo
```

## Components

### App interface

- [Streamlit app](https://github.com/sahiljain6/promptlab/blob/main/app.py): `app.py`

### Task and generation

- [Task specification](https://github.com/sahiljain6/promptlab/blob/main/promptlab/tasks.py): `promptlab/tasks.py`
- [Prompt techniques](https://github.com/sahiljain6/promptlab/blob/main/promptlab/prompts.py): `promptlab/prompts.py`
- [Trial orchestration](https://github.com/sahiljain6/promptlab/blob/main/promptlab/pipeline.py): `promptlab/pipeline.py`
- [Model provider client](https://github.com/sahiljain6/promptlab/blob/main/promptlab/provider.py): `promptlab/provider.py`

### Evaluation and ranking

- [Solution evaluation](https://github.com/sahiljain6/promptlab/blob/main/promptlab/sandbox.py): `promptlab/sandbox.py`
- [Scoring and ranking](https://github.com/sahiljain6/promptlab/blob/main/promptlab/scoring.py): `promptlab/scoring.py`

### History and quota

- [Experiment history](https://github.com/sahiljain6/promptlab/blob/main/promptlab/storage.py): `promptlab/storage.py`

### Other components

- **Researcher**
- **Groq API**
- **Ollama API**
- **Gemini backup**

## Connections

- Researcher → Streamlit app: submits task (evidence: `README.md`)
- Streamlit app → Task specification: requests specification (evidence: `README.md`)
- Task specification → Model provider client: requests generation (evidence: `promptlab/tasks.py`)
- Streamlit app → Model provider client: configures models (evidence: `README.md`)
- Streamlit app → Trial orchestration: starts comparison (evidence: `app.py`)
- Trial orchestration → Prompt techniques: builds prompts (evidence: `promptlab/pipeline.py`)
- Trial orchestration → Model provider client: generates solutions (evidence: `README.md`)
- Model provider client → Groq API: calls API (evidence: `promptlab/provider.py`)
- Model provider client → Ollama API: calls API (evidence: `README.md`)
- Model provider client → Gemini backup: fallback calls (evidence: `README.md`)
- Trial orchestration → Solution evaluation: evaluates solutions (evidence: `README.md`)
- Trial orchestration → Scoring and ranking: annotates trials (evidence: `promptlab/pipeline.py`)
- Streamlit app → Scoring and ranking: ranks results (evidence: `app.py`)
- Streamlit app → Experiment history: saves and reads (evidence: `README.md`)
- Streamlit app → Researcher: shows results (evidence: `README.md`)
