# anshikaaggarwal/crashtest-ai architecture

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

- Interactive diagram: https://gitdiagram.com/anshikaaggarwal/crashtest-ai
- Repository: https://github.com/anshikaaggarwal/crashtest-ai

## Overview

CrashTest lets an engineer submit an agent prompt and scenario, run autonomous inbox or adversarial leak tests, and inspect a judge-scored, auditable verdict. Its main execution route coordinates scenario validation, an agent or attacker loop, and judging; a suite runner applies that process across scenarios for reports. Separate product branches cover live voice testing, threat modeling, and voice-authored scenarios. Edges reflect the sampled calls and index references; some browser-to-route connections are not shown in the excerpts and are left unasserted.

Main entry points: [`app/api/crash/route.ts`](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/crash/route.ts) (Crash API), [`app/Dashboard.tsx`](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/Dashboard.tsx) (Dashboard), [`lib/suite.ts`](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/suite.ts) (Batch Runner), [`lib/secrets.ts`](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/secrets.ts) (Canary Scanner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Testing Interface"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_crashrunner["Crash Runner<br/>[CrashRunner.tsx]"]
  node_livecall["Live Call UI<br/>[LiveCall.tsx]"]
  node_composer["Scenario Composer"]
  node_threatmodel["Threat Model UI<br/>[ThreatModel.tsx]"]
end

subgraph group_execution["Test Execution"]
  node_crashapi["Crash API<br/>[route.ts]"]
  node_liveapi["Live API<br/>[route.ts]"]
  node_suiteapi["Suite API<br/>[route.ts]"]
  node_draftapi["Draft API<br/>[route.ts]"]
  node_agent["Autonomous Agent<br/>[agent.ts]"]
  node_attacker["Red-Team Loop<br/>[attacker.ts]"]
  node_liveengine["Live Test Engine<br/>[live.ts]"]
  node_tools["Fake Tools<br/>[tools.ts]"]
end

subgraph group_assurance["Scenarios &amp; Verdicts"]
  node_scenarios["Scenario Library<br/>[scenarios.ts]"]
  node_draft["Draft Validation<br/>[scenarioDraft.ts]"]
  node_secrets["Canary Scanner<br/>[secrets.ts]"]
  node_judge["Safety Judge<br/>[judge.ts]"]
  node_events["Event Types<br/>[events.ts]"]
end

subgraph group_insights["Reports &amp; Voice"]
  node_suite["Batch Runner<br/>[suite.ts]"]
  node_report["Report Builder<br/>[report.ts]"]
  node_reportapi["Report API<br/>[route.ts]"]
  node_suiteview["Suite Report UI<br/>[SuiteReport.tsx]"]
  node_threats["Threat Catalog<br/>[threats.ts]"]
  node_speech["Browser Speech<br/>[speech.ts]"]
  node_ttsapi["TTS API<br/>[route.ts]"]
  node_maya["Maya TTS Client<br/>[maya.ts]"]
end

node_engineer(("Engineer"))

node_engineer -->|"uses"| node_dashboard
node_dashboard -->|"opens"| node_crashrunner
node_dashboard -->|"opens"| node_livecall
node_dashboard -->|"opens"| node_composer
node_dashboard -->|"opens"| node_threatmodel
node_dashboard -->|"opens"| node_suiteview
node_crashapi -->|"selects"| node_scenarios
node_crashapi -->|"validates"| node_draft
node_crashapi -->|"runs"| node_agent
node_crashapi -->|"runs"| node_attacker
node_crashapi -->|"scores"| node_judge
node_agent -->|"invokes"| node_tools
node_attacker -->|"invokes"| node_tools
node_attacker -->|"scans replies"| node_secrets
node_judge -->|"caps ratings"| node_secrets
node_crashapi -->|"streams"| node_events
node_liveapi -->|"runs"| node_liveengine
node_liveapi -->|"scores"| node_judge
node_liveapi -->|"checks leaks"| node_secrets
node_liveengine -->|"uses"| node_scenarios
node_liveengine -->|"uses"| node_tools
node_liveengine -->|"checks leaks"| node_secrets
node_suiteapi -->|"runs"| node_suite
node_suite -->|"selects"| node_scenarios
node_suite -->|"runs"| node_agent
node_suite -->|"runs"| node_attacker
node_suite -->|"scores"| node_judge
node_reportapi -->|"builds"| node_report
node_report -->|"summarizes"| node_suite
node_draftapi -->|"creates drafts"| node_draft
node_draft -->|"checks canaries"| node_secrets
node_threatmodel -->|"shows threats"| node_threats
node_threatmodel -->|"browses"| node_scenarios
node_livecall -->|"uses speech"| node_speech
node_ttsapi -->|"requests speech"| node_maya
node_speech -->|"requests readback"| node_ttsapi

click node_dashboard "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/Dashboard.tsx"
click node_crashrunner "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/CrashRunner.tsx"
click node_livecall "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/LiveCall.tsx"
click node_composer "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/ScenarioComposer.tsx"
click node_threatmodel "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/ThreatModel.tsx"
click node_crashapi "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/crash/route.ts"
click node_liveapi "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/live/route.ts"
click node_suiteapi "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/suite/route.ts"
click node_draftapi "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/scenario/draft/route.ts"
click node_agent "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/agent.ts"
click node_attacker "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/attacker.ts"
click node_liveengine "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/live.ts"
click node_tools "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/tools.ts"
click node_scenarios "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/scenarios.ts"
click node_draft "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/scenarioDraft.ts"
click node_secrets "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/secrets.ts"
click node_judge "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/judge.ts"
click node_events "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/events.ts"
click node_suite "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/suite.ts"
click node_report "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/report.ts"
click node_reportapi "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/report/route.ts"
click node_suiteview "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/SuiteReport.tsx"
click node_threats "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/threats.ts"
click node_speech "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/speech.ts"
click node_ttsapi "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/tts/route.ts"
click node_maya "https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/maya.ts"

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_crashrunner,node_livecall,node_composer,node_threatmodel toneBlue
class node_crashapi,node_liveapi,node_suiteapi,node_draftapi,node_agent,node_attacker,node_liveengine,node_tools toneAmber
class node_scenarios,node_draft,node_secrets,node_judge,node_events toneMint
class node_suite,node_report,node_reportapi,node_suiteview,node_threats,node_speech,node_ttsapi,node_maya toneRose
class node_engineer toneIndigo
```

## Components

### Testing Interface

- [Dashboard](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/Dashboard.tsx): `app/Dashboard.tsx`
- [Crash Runner](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/CrashRunner.tsx): `app/CrashRunner.tsx`
- [Live Call UI](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/LiveCall.tsx): `app/LiveCall.tsx`
- [Scenario Composer](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/ScenarioComposer.tsx): `app/ScenarioComposer.tsx`
- [Threat Model UI](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/ThreatModel.tsx): `app/ThreatModel.tsx`

### Test Execution

- [Crash API](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/crash/route.ts): `app/api/crash/route.ts`
- [Live API](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/live/route.ts): `app/api/live/route.ts`
- [Suite API](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/suite/route.ts): `app/api/suite/route.ts`
- [Draft API](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/scenario/draft/route.ts): `app/api/scenario/draft/route.ts`
- [Autonomous Agent](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/agent.ts): `lib/agent.ts`
- [Red-Team Loop](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/attacker.ts): `lib/attacker.ts`
- [Live Test Engine](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/live.ts): `lib/live.ts`
- [Fake Tools](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/tools.ts): `lib/tools.ts`

### Scenarios & Verdicts

- [Scenario Library](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/scenarios.ts): `lib/scenarios.ts`
- [Draft Validation](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/scenarioDraft.ts): `lib/scenarioDraft.ts`
- [Canary Scanner](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/secrets.ts): `lib/secrets.ts`
- [Safety Judge](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/judge.ts): `lib/judge.ts`
- [Event Types](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/events.ts): `lib/events.ts`

### Reports & Voice

- [Batch Runner](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/suite.ts): `lib/suite.ts`
- [Report Builder](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/report.ts): `lib/report.ts`
- [Report API](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/report/route.ts): `app/api/report/route.ts`
- [Suite Report UI](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/SuiteReport.tsx): `app/SuiteReport.tsx`
- [Threat Catalog](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/threats.ts): `lib/threats.ts`
- [Browser Speech](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/speech.ts): `lib/speech.ts`
- [TTS API](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/app/api/tts/route.ts): `app/api/tts/route.ts`
- [Maya TTS Client](https://github.com/anshikaaggarwal/crashtest-ai/blob/main/lib/maya.ts): `lib/maya.ts`

### Other components

- **Engineer**

## Connections

- Engineer → Dashboard: uses (evidence: `README.md`)
- Dashboard → Crash Runner: opens (evidence: `app/Dashboard.tsx`)
- Dashboard → Live Call UI: opens (evidence: `app/Dashboard.tsx`)
- Dashboard → Scenario Composer: opens (evidence: `app/Dashboard.tsx`)
- Dashboard → Threat Model UI: opens (evidence: `app/Dashboard.tsx`)
- Dashboard → Suite Report UI: opens (evidence: `app/Dashboard.tsx`)
- Crash API → Scenario Library: selects (evidence: `app/api/crash/route.ts`)
- Crash API → Draft Validation: validates (evidence: `app/api/crash/route.ts`)
- Crash API → Autonomous Agent: runs (evidence: `app/api/crash/route.ts`)
- Crash API → Red-Team Loop: runs (evidence: `app/api/crash/route.ts`)
- Crash API → Safety Judge: scores (evidence: `app/api/crash/route.ts`)
- Autonomous Agent → Fake Tools: invokes (evidence: `lib/agent.ts`)
- Red-Team Loop → Fake Tools: invokes (evidence: `lib/attacker.ts`)
- Red-Team Loop → Canary Scanner: scans replies (evidence: `lib/attacker.ts`)
- Safety Judge → Canary Scanner: caps ratings (evidence: `lib/judge.ts`)
- Crash API → Event Types: streams (evidence: `app/api/crash/route.ts`)
- Live API → Live Test Engine: runs (evidence: `app/api/live/route.ts`)
- Live API → Safety Judge: scores (evidence: `app/api/live/route.ts`)
- Live API → Canary Scanner: checks leaks (evidence: `app/api/live/route.ts`)
- Live Test Engine → Scenario Library: uses (evidence: `lib/live.ts`)
- Live Test Engine → Fake Tools: uses (evidence: `lib/live.ts`)
- Live Test Engine → Canary Scanner: checks leaks (evidence: `lib/live.ts`)
- Suite API → Batch Runner: runs (evidence: `app/api/suite/route.ts`)
- Batch Runner → Scenario Library: selects (evidence: `lib/suite.ts`)
- Batch Runner → Autonomous Agent: runs (evidence: `lib/suite.ts`)
- Batch Runner → Red-Team Loop: runs (evidence: `lib/suite.ts`)
- Batch Runner → Safety Judge: scores (evidence: `lib/suite.ts`)
- Report API → Report Builder: builds (evidence: `app/api/report/route.ts`)
- Report Builder → Batch Runner: summarizes (evidence: `lib/report.ts`)
- Draft API → Draft Validation: creates drafts (evidence: `app/api/scenario/draft/route.ts`)
- Draft Validation → Canary Scanner: checks canaries (evidence: `lib/scenarioDraft.ts`)
- Threat Model UI → Threat Catalog: shows threats (evidence: `app/ThreatModel.tsx`)
- Threat Model UI → Scenario Library: browses (evidence: `app/ThreatModel.tsx`)
- Live Call UI → Browser Speech: uses speech (evidence: `app/LiveCall.tsx`)
- TTS API → Maya TTS Client: requests speech (evidence: `app/api/tts/route.ts`)
- Browser Speech → TTS API: requests readback (evidence: `README.md`)
