# mitudrudutta/rehearsal architecture

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

- Interactive diagram: https://gitdiagram.com/mitudrudutta/rehearsal
- Repository: https://github.com/mitudrudutta/rehearsal

## Overview

Rehearsal is a platform for compiling an application into a resettable practice world, rehearsing agents against simulated customers and intentional failures, and judging outcomes from the application’s own database. The principal workflow runs from application import through world build, evaluation episodes, database-backed checks, readiness results, and improvement/held-out comparison. The README documents these product stages; source-index references support several internal links, while unsampled implementation details are represented at their existing directory paths.

Main entry points: [`rehearsal/worker/evaluate.py`](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/worker/evaluate.py) (Evaluation worker), [`rehearsal/agents/episode.py`](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/agents/episode.py) (Agent episode), [`rehearsal/api/app.py`](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/api/app.py) (API and auth), [`rehearsal/compiler/pipeline.py`](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/compiler/pipeline.py) (World compiler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and console"]
  node_console["Web console<br/>[Applications.tsx]"]
  node_sdk["CLI and SDK<br/>[client.py]"]
end

subgraph group_control["Control plane"]
  node_api["API and auth<br/>[app.py]"]
  node_billing["Plans and billing<br/>[billing.py]"]
  node_database[("Control database<br/>[models.py]")]
  node_queue["Job queue<br/>[queue.py]"]
  node_worker["Worker dispatch<br/>[main.py]"]
end

subgraph group_world["World compilation"]
  node_build["World compiler<br/>[pipeline.py]"]
  node_compiler_tools["Discovery and validation"]
  node_sandbox["Sandbox runtime<br/>[runtime.py]"]
  node_seed["Fictional data seeding<br/>[seed.py]"]
  node_app_world["Practice application"]
end

subgraph group_rehearsal["Rehearsal runtime"]
  node_evaluation["Evaluation worker<br/>[evaluate.py]"]
  node_episode["Agent episode<br/>[episode.py]"]
  node_participant["Simulated customer<br/>[participant.py]"]
  node_llm["Model providers<br/>[llm.py]"]
end

subgraph group_results["Verification and improvement"]
  node_oracle["Database oracle<br/>[oracle.py]"]
  node_probes["Read-only probes<br/>[probes.py]"]
  node_improve["Agent improvement<br/>[improve.py]"]
  node_traces["Run traces<br/>[__init__.py]"]
end

node_developer(("Application owner"))
node_provider_service["Model provider services"]

node_developer -->|"manages apps"| node_console
node_developer -->|"starts jobs"| node_sdk
node_console -.->|"uses API"| node_api
node_sdk -.->|"calls API"| node_api
node_api -->|"checks limits"| node_billing
node_api -->|"stores records"| node_database
node_api -->|"enqueues jobs"| node_queue
node_queue -->|"persists jobs"| node_database
node_worker -.->|"claims jobs"| node_queue
node_worker -.->|"dispatches evaluation"| node_evaluation
node_worker -.->|"dispatches builds"| node_build
node_build -->|"uses phases"| node_compiler_tools
node_build -->|"materializes world"| node_sandbox
node_build -->|"seeds data"| node_seed
node_sandbox -->|"runs services"| node_app_world
node_seed -->|"writes fictional data"| node_app_world
node_evaluation -->|"runs episodes"| node_episode
node_evaluation -->|"resets world"| node_sandbox
node_episode -->|"simulates customer"| node_participant
node_episode -->|"requests model calls"| node_llm
node_llm -->|"calls model"| node_provider_service
node_episode -->|"checks outcomes"| node_oracle
node_oracle -->|"reads state"| node_probes
node_probes -->|"queries database"| node_app_world
node_improve -.->|"reads failed jobs"| node_database
node_improve -.->|"proposes version"| node_llm
node_evaluation -->|"feeds failures"| node_improve
node_evaluation -->|"records traces"| node_traces
node_episode -->|"traces steps"| node_traces

click node_console "https://github.com/mitudrudutta/rehearsal/blob/main/web/src/screens/Applications.tsx"
click node_sdk "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/sdk/client.py"
click node_api "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/api/app.py"
click node_billing "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/billing.py"
click node_database "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/db/models.py"
click node_queue "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/db/queue.py"
click node_worker "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/worker/main.py"
click node_build "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/compiler/pipeline.py"
click node_compiler_tools "https://github.com/mitudrudutta/rehearsal/tree/main/rehearsal/compiler"
click node_sandbox "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/runner/runtime.py"
click node_seed "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/runner/seed.py"
click node_evaluation "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/worker/evaluate.py"
click node_episode "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/agents/episode.py"
click node_participant "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/agents/participant.py"
click node_llm "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/agents/llm.py"
click node_oracle "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/evaluator/oracle.py"
click node_probes "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/evaluator/probes.py"
click node_improve "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/worker/improve.py"
click node_traces "https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/telemetry/__init__.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_console,node_sdk toneBlue
class node_api,node_billing,node_database,node_queue,node_worker toneAmber
class node_build,node_compiler_tools,node_sandbox,node_seed,node_app_world toneMint
class node_evaluation,node_episode,node_participant,node_llm toneRose
class node_oracle,node_probes,node_improve,node_traces,node_developer,node_provider_service toneIndigo
```

## Components

### Access and console

- [Web console](https://github.com/mitudrudutta/rehearsal/blob/main/web/src/screens/Applications.tsx): `web/src/screens/Applications.tsx`
- [CLI and SDK](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/sdk/client.py): `rehearsal/sdk/client.py`

### Control plane

- [API and auth](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/api/app.py): `rehearsal/api/app.py`
- [Plans and billing](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/billing.py): `rehearsal/billing.py`
- [Control database](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/db/models.py): `rehearsal/db/models.py`
- [Job queue](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/db/queue.py): `rehearsal/db/queue.py`
- [Worker dispatch](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/worker/main.py): `rehearsal/worker/main.py`

### World compilation

- [World compiler](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/compiler/pipeline.py): `rehearsal/compiler/pipeline.py`
- [Discovery and validation](https://github.com/mitudrudutta/rehearsal/tree/main/rehearsal/compiler): `rehearsal/compiler`
- [Sandbox runtime](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/runner/runtime.py): `rehearsal/runner/runtime.py`
- [Fictional data seeding](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/runner/seed.py): `rehearsal/runner/seed.py`
- **Practice application**

### Rehearsal runtime

- [Evaluation worker](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/worker/evaluate.py): `rehearsal/worker/evaluate.py`
- [Agent episode](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/agents/episode.py): `rehearsal/agents/episode.py`
- [Simulated customer](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/agents/participant.py): `rehearsal/agents/participant.py`
- [Model providers](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/agents/llm.py): `rehearsal/agents/llm.py`

### Verification and improvement

- [Database oracle](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/evaluator/oracle.py): `rehearsal/evaluator/oracle.py`
- [Read-only probes](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/evaluator/probes.py): `rehearsal/evaluator/probes.py`
- [Agent improvement](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/worker/improve.py): `rehearsal/worker/improve.py`
- [Run traces](https://github.com/mitudrudutta/rehearsal/blob/main/rehearsal/telemetry/__init__.py): `rehearsal/telemetry/__init__.py`

### Other components

- **Application owner**
- **Model provider services**

## Connections

- Application owner → Web console: manages apps (evidence: `README.md`)
- Application owner → CLI and SDK: starts jobs (evidence: `README.md`)
- Web console → API and auth: uses API
- CLI and SDK → API and auth: calls API
- API and auth → Plans and billing: checks limits (evidence: `rehearsal/api/app.py`)
- API and auth → Control database: stores records (evidence: `rehearsal/api/app.py`)
- API and auth → Job queue: enqueues jobs (evidence: `rehearsal/api/app.py`)
- Job queue → Control database: persists jobs (evidence: `rehearsal/db/queue.py`)
- Worker dispatch → Job queue: claims jobs (evidence: `rehearsal/worker/main.py`)
- Worker dispatch → Evaluation worker: dispatches evaluation
- Worker dispatch → World compiler: dispatches builds
- World compiler → Discovery and validation: uses phases (evidence: `rehearsal/compiler/pipeline.py`)
- World compiler → Sandbox runtime: materializes world (evidence: `rehearsal/compiler/pipeline.py`)
- World compiler → Fictional data seeding: seeds data (evidence: `rehearsal/compiler/pipeline.py`)
- Sandbox runtime → Practice application: runs services (evidence: `README.md`)
- Fictional data seeding → Practice application: writes fictional data (evidence: `README.md`)
- Evaluation worker → Agent episode: runs episodes (evidence: `rehearsal/worker/evaluate.py`)
- Evaluation worker → Sandbox runtime: resets world (evidence: `rehearsal/worker/evaluate.py`)
- Agent episode → Simulated customer: simulates customer (evidence: `rehearsal/agents/episode.py`)
- Agent episode → Model providers: requests model calls (evidence: `rehearsal/agents/episode.py`)
- Model providers → Model provider services: calls model (evidence: `README.md`)
- Agent episode → Database oracle: checks outcomes (evidence: `rehearsal/agents/episode.py`)
- Database oracle → Read-only probes: reads state (evidence: `rehearsal/evaluator/oracle.py`)
- Read-only probes → Practice application: queries database (evidence: `README.md`)
- Agent improvement → Control database: reads failed jobs
- Agent improvement → Model providers: proposes version
- Evaluation worker → Agent improvement: feeds failures (evidence: `README.md`)
- Evaluation worker → Run traces: records traces (evidence: `rehearsal/worker/evaluate.py`)
- Agent episode → Run traces: traces steps (evidence: `rehearsal/agents/episode.py`)
