# karthik1319/the-courtroom architecture

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

- Interactive diagram: https://gitdiagram.com/karthik1319/the-courtroom
- Repository: https://github.com/karthik1319/the-courtroom

## Overview

The Courtroom takes a Python file and runs it through a prosecutor, defense, and judge. The prosecutor analyzes the code, searches Tavily for vulnerability precedent, and returns findings with an exploit; the defense generates a patch and verification script, then the sandbox executes that script; the judge uses the transcript and actual sandbox result to produce a verdict. The README also describes live Nebius model and sandbox services. Evidence comes from the README and sampled source; edges to external services are documented or visible in the client calls.

Main entry points: [`main.py`](https://github.com/karthik1319/the-courtroom/blob/main/main.py) (Trial runner), [`config.py`](https://github.com/karthik1319/the-courtroom/blob/main/config.py) (Credentials and model config), [`agents/prosecutor.py`](https://github.com/karthik1319/the-courtroom/blob/main/agents/prosecutor.py) (Vulnerability analysis), [`agents/defense.py`](https://github.com/karthik1319/the-courtroom/blob/main/agents/defense.py) (Patch and retest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trial["Trial workflow"]
  node_entry["Trial runner<br/>[main.py]"]
  node_prosecutor["Vulnerability analysis<br/>[prosecutor.py]"]
  node_search["Precedent search<br/>[search.py]"]
  node_defense["Patch and retest<br/>[defense.py]"]
  node_sandbox["Code execution<br/>[sandbox.py]"]
  node_judge["Verdict<br/>[judge.py]"]
end

subgraph group_integrations["External services"]
  node_nebius_models{{"Nebius model API"}}
  node_nebius_sandbox{{"Nebius sandbox service"}}
  node_tavily{{"Tavily search API"}}
end

subgraph group_runtime["Runtime support"]
  node_config["Credentials and model config<br/>[config.py]"]
  node_terminal["Transcript output<br/>[main.py]"]
end

node_user(("Code auditor user"))

node_user -->|"submits file"| node_entry
node_entry -->|"analyzes code"| node_prosecutor
node_prosecutor -->|"searches precedent"| node_search
node_search -->|"queries"| node_tavily
node_prosecutor -->|"requests analysis"| node_nebius_models
node_entry -->|"requests patch"| node_defense
node_defense -->|"runs test"| node_sandbox
node_sandbox -->|"executes remotely"| node_nebius_sandbox
node_defense -->|"requests patch"| node_nebius_models
node_entry -->|"requests verdict"| node_judge
node_judge -->|"requests ruling"| node_nebius_models
node_entry -->|"prints transcript"| node_terminal
node_prosecutor -->|"gets model client"| node_config
node_defense -->|"gets model client"| node_config
node_judge -->|"gets model client"| node_config
node_search -->|"reads API key"| node_config
node_sandbox -->|"reads credentials"| node_config

click node_entry "https://github.com/karthik1319/the-courtroom/blob/main/main.py"
click node_prosecutor "https://github.com/karthik1319/the-courtroom/blob/main/agents/prosecutor.py"
click node_search "https://github.com/karthik1319/the-courtroom/blob/main/tools/search.py"
click node_defense "https://github.com/karthik1319/the-courtroom/blob/main/agents/defense.py"
click node_sandbox "https://github.com/karthik1319/the-courtroom/blob/main/tools/sandbox.py"
click node_judge "https://github.com/karthik1319/the-courtroom/blob/main/agents/judge.py"
click node_config "https://github.com/karthik1319/the-courtroom/blob/main/config.py"
click node_terminal "https://github.com/karthik1319/the-courtroom/blob/main/main.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_entry,node_prosecutor,node_search,node_defense,node_sandbox,node_judge,node_user toneBlue
class node_nebius_models,node_nebius_sandbox,node_tavily toneAmber
class node_config,node_terminal toneMint
```

## Components

### Trial workflow

- [Trial runner](https://github.com/karthik1319/the-courtroom/blob/main/main.py): `main.py`
- [Vulnerability analysis](https://github.com/karthik1319/the-courtroom/blob/main/agents/prosecutor.py): `agents/prosecutor.py`
- [Precedent search](https://github.com/karthik1319/the-courtroom/blob/main/tools/search.py): `tools/search.py`
- [Patch and retest](https://github.com/karthik1319/the-courtroom/blob/main/agents/defense.py): `agents/defense.py`
- [Code execution](https://github.com/karthik1319/the-courtroom/blob/main/tools/sandbox.py): `tools/sandbox.py`
- [Verdict](https://github.com/karthik1319/the-courtroom/blob/main/agents/judge.py): `agents/judge.py`

### External services

- **Nebius model API**
- **Nebius sandbox service**
- **Tavily search API**

### Runtime support

- [Credentials and model config](https://github.com/karthik1319/the-courtroom/blob/main/config.py): `config.py`
- [Transcript output](https://github.com/karthik1319/the-courtroom/blob/main/main.py): `main.py`

### Other components

- **Code auditor user**

## Connections

- Code auditor user → Trial runner: submits file (evidence: `README.md`)
- Trial runner → Vulnerability analysis: analyzes code (evidence: `main.py`)
- Vulnerability analysis → Precedent search: searches precedent (evidence: `agents/prosecutor.py`)
- Precedent search → Tavily search API: queries (evidence: `tools/search.py`)
- Vulnerability analysis → Nebius model API: requests analysis (evidence: `agents/prosecutor.py`)
- Trial runner → Patch and retest: requests patch (evidence: `main.py`)
- Patch and retest → Code execution: runs test (evidence: `agents/defense.py`)
- Code execution → Nebius sandbox service: executes remotely (evidence: `tools/sandbox.py`)
- Patch and retest → Nebius model API: requests patch (evidence: `agents/defense.py`)
- Trial runner → Verdict: requests verdict (evidence: `main.py`)
- Verdict → Nebius model API: requests ruling (evidence: `agents/judge.py`)
- Trial runner → Transcript output: prints transcript (evidence: `main.py`)
- Vulnerability analysis → Credentials and model config: gets model client (evidence: `agents/prosecutor.py`)
- Patch and retest → Credentials and model config: gets model client (evidence: `agents/defense.py`)
- Verdict → Credentials and model config: gets model client (evidence: `agents/judge.py`)
- Precedent search → Credentials and model config: reads API key (evidence: `tools/search.py`)
- Code execution → Credentials and model config: reads credentials (evidence: `tools/sandbox.py`)
