# ayush1216/understudy architecture

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

- Interactive diagram: https://gitdiagram.com/ayush1216/understudy
- Repository: https://github.com/ayush1216/understudy

## Overview

Understudy turns a goal into a reviewed, typed capability by having an LLM operate a real UI once, then replays that artifact deterministically with typed inputs and no model. The graph follows discovery and replay through the shared browser surface, and includes capability validation, evidence, policy, catalog, and human takeover. The README documents these product branches; source excerpts and the SOURCE INDEX support the cited internal links. Some subsystem internals were not sampled, so their links are limited to documented or indexed relationships.

Main entry points: [`src/understudy/surface/web/surface.py`](https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/surface.py) (Web surface), [`src/understudy/discover/loop.py`](https://github.com/ayush1216/understudy/blob/main/src/understudy/discover/loop.py) (LLM discovery), [`src/understudy/cli.py`](https://github.com/ayush1216/understudy/blob/main/src/understudy/cli.py) (CLI entry), [`src/understudy/replay/executor.py`](https://github.com/ayush1216/understudy/blob/main/src/understudy/replay/executor.py) (Deterministic replay)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Run workflows"]
  node_cli["CLI entry<br/>[cli.py]"]
  node_discovery["LLM discovery<br/>[loop.py]"]
  node_recorder["Artifact recorder<br/>[recorder.py]"]
  node_replay["Deterministic replay<br/>[executor.py]"]
end

subgraph group_surface["Browser surface"]
  node_surface["Web surface<br/>[surface.py]"]
  node_perception["UI perception<br/>[perception.py]"]
  node_resolver["Target resolver<br/>[resolver.py]"]
  node_session["Browser session<br/>[session.py]"]
  node_protocol["Surface protocol<br/>[protocol.py]"]
end

subgraph group_contracts["Capability contracts"]
  node_schema["Typed capability schema<br/>[capability.py]"]
  node_lint["Artifact linting<br/>[lint.py]"]
  node_catalog[("Capability catalog<br/>[catalog.py]")]
end

subgraph group_operations["Operations and oversight"]
  node_policy["Risk and policy<br/>[engine.py]"]
  node_evidence[("Run evidence<br/>[store.py]")]
  node_console["Operator console<br/>[app.py]"]
  node_interventions["Human interventions<br/>[interventions.py]"]
  node_runs["Run coordination<br/>[runs.py]"]
end

subgraph group_demo["Demo target app"]
  node_targetapp["Legacy target UI<br/>[app.py]"]
  node_data[("Member data<br/>[data.py]")]
  node_tenantviews["Tenant UI views<br/>[render_alpha.py]"]
  node_faults["Fault injection<br/>[faults.py]"]
end

node_operator(("Operator or agent"))
node_model["Chat model API"]

node_operator -->|"invokes"| node_cli
node_cli -->|"starts discovery"| node_discovery
node_discovery -->|"requests turns"| node_model
node_discovery -->|"records trace"| node_recorder
node_recorder -->|"builds artifact"| node_schema
node_cli -->|"starts replay"| node_replay
node_catalog -->|"loads capability"| node_schema
node_catalog -->|"validates artifact"| node_lint
node_replay -->|"executes steps"| node_schema
node_discovery -->|"operates through"| node_surface
node_replay -->|"operates through"| node_surface
node_surface -->|"uses browser"| node_session
node_surface -->|"observes UI"| node_perception
node_surface -->|"resolves targets"| node_resolver
node_resolver -->|"uses observations"| node_perception
node_surface -->|"implements seam"| node_protocol
node_discovery -->|"gates actions"| node_policy
node_replay -->|"checks policy"| node_policy
node_discovery -->|"writes run evidence"| node_evidence
node_replay -->|"writes run evidence"| node_evidence
node_cli -->|"manages artifacts"| node_catalog
node_cli -->|"mounts console"| node_console
node_console -->|"accesses live runs"| node_runs
node_console -->|"routes interventions"| node_interventions
node_runs -->|"owns session"| node_session
node_runs -->|"exposes evidence"| node_evidence
node_interventions -->|"resolves takeover"| node_runs
node_surface -.->|"drives UI"| node_targetapp
node_targetapp -->|"reads and mutates"| node_data
node_targetapp -->|"renders tenant pages"| node_tenantviews
node_targetapp -->|"injects demo faults"| node_faults

click node_cli "https://github.com/ayush1216/understudy/blob/main/src/understudy/cli.py"
click node_discovery "https://github.com/ayush1216/understudy/blob/main/src/understudy/discover/loop.py"
click node_recorder "https://github.com/ayush1216/understudy/blob/main/src/understudy/discover/recorder.py"
click node_replay "https://github.com/ayush1216/understudy/blob/main/src/understudy/replay/executor.py"
click node_targetapp "https://github.com/ayush1216/understudy/blob/main/target_app/app.py"
click node_data "https://github.com/ayush1216/understudy/blob/main/target_app/data.py"
click node_tenantviews "https://github.com/ayush1216/understudy/blob/main/target_app/render_alpha.py"
click node_faults "https://github.com/ayush1216/understudy/blob/main/target_app/faults.py"
click node_surface "https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/surface.py"
click node_perception "https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/perception.py"
click node_resolver "https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/resolver.py"
click node_session "https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/session.py"
click node_protocol "https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/protocol.py"
click node_schema "https://github.com/ayush1216/understudy/blob/main/src/understudy/schema/capability.py"
click node_lint "https://github.com/ayush1216/understudy/blob/main/src/understudy/schema/lint.py"
click node_catalog "https://github.com/ayush1216/understudy/blob/main/src/understudy/catalog/catalog.py"
click node_policy "https://github.com/ayush1216/understudy/blob/main/src/understudy/policy/engine.py"
click node_evidence "https://github.com/ayush1216/understudy/blob/main/src/understudy/evidence/store.py"
click node_console "https://github.com/ayush1216/understudy/blob/main/src/understudy/console/app.py"
click node_interventions "https://github.com/ayush1216/understudy/blob/main/src/understudy/console/interventions.py"
click node_runs "https://github.com/ayush1216/understudy/blob/main/src/understudy/runs.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_discovery,node_recorder,node_replay toneBlue
class node_surface,node_perception,node_resolver,node_session,node_protocol toneAmber
class node_schema,node_lint,node_catalog,node_model toneMint
class node_policy,node_evidence,node_console,node_interventions,node_runs toneRose
class node_targetapp,node_data,node_tenantviews,node_faults,node_operator toneIndigo
```

## Components

### Run workflows

- [CLI entry](https://github.com/ayush1216/understudy/blob/main/src/understudy/cli.py): `src/understudy/cli.py`
- [LLM discovery](https://github.com/ayush1216/understudy/blob/main/src/understudy/discover/loop.py): `src/understudy/discover/loop.py`
- [Artifact recorder](https://github.com/ayush1216/understudy/blob/main/src/understudy/discover/recorder.py): `src/understudy/discover/recorder.py`
- [Deterministic replay](https://github.com/ayush1216/understudy/blob/main/src/understudy/replay/executor.py): `src/understudy/replay/executor.py`

### Browser surface

- [Web surface](https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/surface.py): `src/understudy/surface/web/surface.py`
- [UI perception](https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/perception.py): `src/understudy/surface/web/perception.py`
- [Target resolver](https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/resolver.py): `src/understudy/surface/web/resolver.py`
- [Browser session](https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/web/session.py): `src/understudy/surface/web/session.py`
- [Surface protocol](https://github.com/ayush1216/understudy/blob/main/src/understudy/surface/protocol.py): `src/understudy/surface/protocol.py`

### Capability contracts

- [Typed capability schema](https://github.com/ayush1216/understudy/blob/main/src/understudy/schema/capability.py): `src/understudy/schema/capability.py`
- [Artifact linting](https://github.com/ayush1216/understudy/blob/main/src/understudy/schema/lint.py): `src/understudy/schema/lint.py`
- [Capability catalog](https://github.com/ayush1216/understudy/blob/main/src/understudy/catalog/catalog.py): `src/understudy/catalog/catalog.py`

### Operations and oversight

- [Risk and policy](https://github.com/ayush1216/understudy/blob/main/src/understudy/policy/engine.py): `src/understudy/policy/engine.py`
- [Run evidence](https://github.com/ayush1216/understudy/blob/main/src/understudy/evidence/store.py): `src/understudy/evidence/store.py`
- [Operator console](https://github.com/ayush1216/understudy/blob/main/src/understudy/console/app.py): `src/understudy/console/app.py`
- [Human interventions](https://github.com/ayush1216/understudy/blob/main/src/understudy/console/interventions.py): `src/understudy/console/interventions.py`
- [Run coordination](https://github.com/ayush1216/understudy/blob/main/src/understudy/runs.py): `src/understudy/runs.py`

### Demo target app

- [Legacy target UI](https://github.com/ayush1216/understudy/blob/main/target_app/app.py): `target_app/app.py`
- [Member data](https://github.com/ayush1216/understudy/blob/main/target_app/data.py): `target_app/data.py`
- [Tenant UI views](https://github.com/ayush1216/understudy/blob/main/target_app/render_alpha.py): `target_app/render_alpha.py`
- [Fault injection](https://github.com/ayush1216/understudy/blob/main/target_app/faults.py): `target_app/faults.py`

### Other components

- **Operator or agent**
- **Chat model API**

## Connections

- Operator or agent → CLI entry: invokes (evidence: `README.md`)
- CLI entry → LLM discovery: starts discovery (evidence: `src/understudy/cli.py`)
- LLM discovery → Chat model API: requests turns (evidence: `src/understudy/discover/loop.py`)
- LLM discovery → Artifact recorder: records trace (evidence: `src/understudy/discover/loop.py`)
- Artifact recorder → Typed capability schema: builds artifact (evidence: `src/understudy/discover/recorder.py`)
- CLI entry → Deterministic replay: starts replay (evidence: `src/understudy/cli.py`)
- Capability catalog → Typed capability schema: loads capability (evidence: `src/understudy/catalog/catalog.py`)
- Capability catalog → Artifact linting: validates artifact (evidence: `src/understudy/schema/lint.py`)
- Deterministic replay → Typed capability schema: executes steps (evidence: `src/understudy/replay/executor.py`)
- LLM discovery → Web surface: operates through (evidence: `src/understudy/discover/loop.py`)
- Deterministic replay → Web surface: operates through (evidence: `src/understudy/replay/executor.py`)
- Web surface → Browser session: uses browser (evidence: `src/understudy/surface/web/surface.py`)
- Web surface → UI perception: observes UI (evidence: `src/understudy/surface/web/surface.py`)
- Web surface → Target resolver: resolves targets (evidence: `src/understudy/surface/web/surface.py`)
- Target resolver → UI perception: uses observations (evidence: `src/understudy/surface/web/resolver.py`)
- Web surface → Surface protocol: implements seam (evidence: `src/understudy/surface/web/surface.py`)
- LLM discovery → Risk and policy: gates actions (evidence: `src/understudy/discover/loop.py`)
- Deterministic replay → Risk and policy: checks policy (evidence: `src/understudy/replay/executor.py`)
- LLM discovery → Run evidence: writes run evidence (evidence: `src/understudy/discover/loop.py`)
- Deterministic replay → Run evidence: writes run evidence (evidence: `src/understudy/replay/executor.py`)
- CLI entry → Capability catalog: manages artifacts (evidence: `src/understudy/cli.py`)
- CLI entry → Operator console: mounts console (evidence: `src/understudy/cli.py`)
- Operator console → Run coordination: accesses live runs (evidence: `src/understudy/console/app.py`)
- Operator console → Human interventions: routes interventions (evidence: `src/understudy/console/app.py`)
- Run coordination → Browser session: owns session (evidence: `src/understudy/runs.py`)
- Run coordination → Run evidence: exposes evidence (evidence: `src/understudy/runs.py`)
- Human interventions → Run coordination: resolves takeover (evidence: `src/understudy/console/interventions.py`)
- Web surface → Legacy target UI: drives UI
- Legacy target UI → Member data: reads and mutates (evidence: `target_app/app.py`)
- Legacy target UI → Tenant UI views: renders tenant pages (evidence: `target_app/app.py`)
- Legacy target UI → Fault injection: injects demo faults (evidence: `target_app/app.py`)
