# fudandisc/j1bench architecture

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

- Interactive diagram: https://gitdiagram.com/fudandisc/j1bench
- Repository: https://github.com/fudandisc/j1bench

## Overview

J1-Bench is an interactive legal-agent benchmark. Its runtime selects a scenario, constructs scenario-specific participants from case data, and runs legal dialogues; model engines provide language-model responses. The README also documents J1-Eval as a separate holistic evaluation capability, but its implementation is not present in the supplied tree. Scenario excerpts show consultation and dialogue logging; other scenario implementations and most agent modules were not inspected, so their internal call paths are not inferred.

Main entry points: [`src/run.py`](https://github.com/fudandisc/j1bench/blob/main/src/run.py) (Scenario Runner), [`src/scenario/KQ.py`](https://github.com/fudandisc/j1bench/blob/main/src/scenario/KQ.py) (Legal Consultation), [`src/agents/base_agent.py`](https://github.com/fudandisc/j1bench/blob/main/src/agents/base_agent.py) (Agent Memory), [`src/scenario/LC.py`](https://github.com/fudandisc/j1bench/blob/main/src/scenario/LC.py) (Legal Consultation LC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime Selection"]
  node_runner["Scenario Runner<br/>[run.py]"]
  node_options["Runtime Options<br/>[options.py]"]
  node_registry["Class Registry<br/>[register.py]"]
  node_case_utils["Case Utilities<br/>[utils_func.py]"]
end

subgraph group_scenarios["Legal Environments"]
  node_civil_dialogue["Civil Dialogue<br/>[CD.py]"]
  node_civil_prediction["Civil Prediction<br/>[CI.py]"]
  node_criminal_dialogue["Criminal Dialogue<br/>[CR.py]"]
  node_document_generation["Document Generation<br/>[DD.py]"]
  node_legal_consultation["Legal Consultation<br/>[KQ.py]"]
  node_legal_consultation_lc["Legal Consultation LC<br/>[LC.py]"]
end

subgraph group_participants["Legal Participants"]
  node_agent_base["Agent Memory<br/>[base_agent.py]"]
  node_public_agents["Public Agents"]
  node_trainee_kq["KQ Trainee<br/>[trainee_KQ.py]"]
  node_trainee_lc["LC Trainee<br/>[trainee_LC.py]"]
  node_court_judge_ci["Civil Judge<br/>[judge_CI.py]"]
  node_court_judge_cr["Criminal Judge<br/>[judge_CR.py]"]
  node_plaintiff["Civil Plaintiff<br/>[plaintiff_CI.py]"]
  node_defendant["Civil Defendant<br/>[defendant_CI.py]"]
  node_lawyer_cd["Civil Lawyer<br/>[lawyer_CD.py]"]
  node_lawyer_dd["Document Lawyer<br/>[lawyer_DD.py]"]
  node_specific_characters["Scenario Characters"]
  node_other_agents["Other Legal Roles"]
end

subgraph group_models["Model Engines"]
  node_engine_base["Engine Interface<br/>[base_engine.py]"]
  node_model_adapters["Model Adapters"]
end

subgraph group_evaluation["Benchmark Evaluation"]
  node_j1_eval["J1-Eval"]
  node_j1_dataset["J1-Eval Dataset"]
end

node_user(("Benchmark User"))

node_user -->|"runs"| node_runner
node_runner -->|"parses options"| node_options
node_runner -->|"selects scenario"| node_registry
node_runner -.->|"runs selected"| node_civil_dialogue
node_runner -.->|"runs selected"| node_civil_prediction
node_runner -.->|"runs selected"| node_criminal_dialogue
node_runner -.->|"runs selected"| node_document_generation
node_runner -.->|"runs selected"| node_legal_consultation
node_runner -.->|"runs selected"| node_legal_consultation_lc
node_options -->|"resolves classes"| node_registry
node_options -->|"configures scenario"| node_legal_consultation
node_legal_consultation -->|"loads cases"| node_case_utils
node_legal_consultation_lc -->|"loads cases"| node_case_utils
node_legal_consultation_lc -->|"requests completion"| node_case_utils
node_legal_consultation -.->|"constructs participants"| node_public_agents
node_legal_consultation -.->|"constructs participants"| node_trainee_kq
node_legal_consultation_lc -.->|"constructs participants"| node_public_agents
node_legal_consultation_lc -.->|"constructs participants"| node_trainee_lc
node_lawyer_dd -->|"selects engine"| node_registry
node_court_judge_ci -->|"extends"| node_agent_base
node_court_judge_cr -->|"extends"| node_agent_base
node_public_agents -->|"extends"| node_agent_base
node_trainee_kq -->|"extends"| node_agent_base
node_trainee_lc -->|"extends"| node_agent_base
node_engine_base -->|"registers interface"| node_registry
node_agent_base -.->|"uses engine"| node_engine_base
node_model_adapters -.->|"implements interface"| node_engine_base
node_legal_consultation -->|"followed by evaluation"| node_j1_eval
node_j1_dataset -->|"evaluated by"| node_j1_eval

click node_runner "https://github.com/fudandisc/j1bench/blob/main/src/run.py"
click node_options "https://github.com/fudandisc/j1bench/blob/main/src/utils/options.py"
click node_registry "https://github.com/fudandisc/j1bench/blob/main/src/utils/register.py"
click node_case_utils "https://github.com/fudandisc/j1bench/blob/main/src/utils/utils_func.py"
click node_civil_dialogue "https://github.com/fudandisc/j1bench/blob/main/src/scenario/CD.py"
click node_civil_prediction "https://github.com/fudandisc/j1bench/blob/main/src/scenario/CI.py"
click node_criminal_dialogue "https://github.com/fudandisc/j1bench/blob/main/src/scenario/CR.py"
click node_document_generation "https://github.com/fudandisc/j1bench/blob/main/src/scenario/DD.py"
click node_legal_consultation "https://github.com/fudandisc/j1bench/blob/main/src/scenario/KQ.py"
click node_legal_consultation_lc "https://github.com/fudandisc/j1bench/blob/main/src/scenario/LC.py"
click node_agent_base "https://github.com/fudandisc/j1bench/blob/main/src/agents/base_agent.py"
click node_public_agents "https://github.com/fudandisc/j1bench/blob/main/src/agents/general_public_KQ.py"
click node_trainee_kq "https://github.com/fudandisc/j1bench/blob/main/src/agents/trainee_KQ.py"
click node_trainee_lc "https://github.com/fudandisc/j1bench/blob/main/src/agents/trainee_LC.py"
click node_court_judge_ci "https://github.com/fudandisc/j1bench/blob/main/src/agents/judge_CI.py"
click node_court_judge_cr "https://github.com/fudandisc/j1bench/blob/main/src/agents/judge_CR.py"
click node_plaintiff "https://github.com/fudandisc/j1bench/blob/main/src/agents/plaintiff_CI.py"
click node_defendant "https://github.com/fudandisc/j1bench/blob/main/src/agents/defendant_CI.py"
click node_lawyer_cd "https://github.com/fudandisc/j1bench/blob/main/src/agents/lawyer_CD.py"
click node_lawyer_dd "https://github.com/fudandisc/j1bench/blob/main/src/agents/lawyer_DD.py"
click node_specific_characters "https://github.com/fudandisc/j1bench/blob/main/src/agents/specific_character_CD.py"
click node_other_agents "https://github.com/fudandisc/j1bench/tree/main/src/agents"
click node_engine_base "https://github.com/fudandisc/j1bench/blob/main/src/engine/base_engine.py"
click node_model_adapters "https://github.com/fudandisc/j1bench/tree/main/src/engine"

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_runner,node_options,node_registry,node_case_utils,node_user toneBlue
class node_civil_dialogue,node_civil_prediction,node_criminal_dialogue,node_document_generation,node_legal_consultation,node_legal_consultation_lc toneAmber
class node_agent_base,node_public_agents,node_trainee_kq,node_trainee_lc,node_court_judge_ci,node_court_judge_cr,node_plaintiff,node_defendant,node_lawyer_cd,node_lawyer_dd,node_specific_characters,node_other_agents toneMint
class node_engine_base,node_model_adapters toneRose
class node_j1_eval,node_j1_dataset toneIndigo
```

## Components

### Runtime Selection

- [Scenario Runner](https://github.com/fudandisc/j1bench/blob/main/src/run.py): `src/run.py`
- [Runtime Options](https://github.com/fudandisc/j1bench/blob/main/src/utils/options.py): `src/utils/options.py`
- [Class Registry](https://github.com/fudandisc/j1bench/blob/main/src/utils/register.py): `src/utils/register.py`
- [Case Utilities](https://github.com/fudandisc/j1bench/blob/main/src/utils/utils_func.py): `src/utils/utils_func.py`

### Legal Environments

- [Civil Dialogue](https://github.com/fudandisc/j1bench/blob/main/src/scenario/CD.py): `src/scenario/CD.py`
- [Civil Prediction](https://github.com/fudandisc/j1bench/blob/main/src/scenario/CI.py): `src/scenario/CI.py`
- [Criminal Dialogue](https://github.com/fudandisc/j1bench/blob/main/src/scenario/CR.py): `src/scenario/CR.py`
- [Document Generation](https://github.com/fudandisc/j1bench/blob/main/src/scenario/DD.py): `src/scenario/DD.py`
- [Legal Consultation](https://github.com/fudandisc/j1bench/blob/main/src/scenario/KQ.py): `src/scenario/KQ.py`
- [Legal Consultation LC](https://github.com/fudandisc/j1bench/blob/main/src/scenario/LC.py): `src/scenario/LC.py`

### Legal Participants

- [Agent Memory](https://github.com/fudandisc/j1bench/blob/main/src/agents/base_agent.py): `src/agents/base_agent.py`
- [Public Agents](https://github.com/fudandisc/j1bench/blob/main/src/agents/general_public_KQ.py): `src/agents/general_public_KQ.py`
- [KQ Trainee](https://github.com/fudandisc/j1bench/blob/main/src/agents/trainee_KQ.py): `src/agents/trainee_KQ.py`
- [LC Trainee](https://github.com/fudandisc/j1bench/blob/main/src/agents/trainee_LC.py): `src/agents/trainee_LC.py`
- [Civil Judge](https://github.com/fudandisc/j1bench/blob/main/src/agents/judge_CI.py): `src/agents/judge_CI.py`
- [Criminal Judge](https://github.com/fudandisc/j1bench/blob/main/src/agents/judge_CR.py): `src/agents/judge_CR.py`
- [Civil Plaintiff](https://github.com/fudandisc/j1bench/blob/main/src/agents/plaintiff_CI.py): `src/agents/plaintiff_CI.py`
- [Civil Defendant](https://github.com/fudandisc/j1bench/blob/main/src/agents/defendant_CI.py): `src/agents/defendant_CI.py`
- [Civil Lawyer](https://github.com/fudandisc/j1bench/blob/main/src/agents/lawyer_CD.py): `src/agents/lawyer_CD.py`
- [Document Lawyer](https://github.com/fudandisc/j1bench/blob/main/src/agents/lawyer_DD.py): `src/agents/lawyer_DD.py`
- [Scenario Characters](https://github.com/fudandisc/j1bench/blob/main/src/agents/specific_character_CD.py): `src/agents/specific_character_CD.py`
- [Other Legal Roles](https://github.com/fudandisc/j1bench/tree/main/src/agents): `src/agents`

### Model Engines

- [Engine Interface](https://github.com/fudandisc/j1bench/blob/main/src/engine/base_engine.py): `src/engine/base_engine.py`
- [Model Adapters](https://github.com/fudandisc/j1bench/tree/main/src/engine): `src/engine`

### Benchmark Evaluation

- **J1-Eval**
- **J1-Eval Dataset**

### Other components

- **Benchmark User**

## Connections

- Benchmark User → Scenario Runner: runs (evidence: `README.md`)
- Scenario Runner → Runtime Options: parses options (evidence: `src/run.py`)
- Scenario Runner → Class Registry: selects scenario (evidence: `src/run.py`)
- Scenario Runner → Civil Dialogue: runs selected
- Scenario Runner → Civil Prediction: runs selected
- Scenario Runner → Criminal Dialogue: runs selected
- Scenario Runner → Document Generation: runs selected
- Scenario Runner → Legal Consultation: runs selected
- Scenario Runner → Legal Consultation LC: runs selected
- Runtime Options → Class Registry: resolves classes (evidence: `src/utils/options.py`)
- Runtime Options → Legal Consultation: configures scenario (evidence: `src/utils/options.py`)
- Legal Consultation → Case Utilities: loads cases (evidence: `src/scenario/KQ.py`)
- Legal Consultation LC → Case Utilities: loads cases (evidence: `src/scenario/LC.py`)
- Legal Consultation LC → Case Utilities: requests completion (evidence: `src/scenario/LC.py`)
- Legal Consultation → Public Agents: constructs participants
- Legal Consultation → KQ Trainee: constructs participants
- Legal Consultation LC → Public Agents: constructs participants
- Legal Consultation LC → LC Trainee: constructs participants
- Document Lawyer → Class Registry: selects engine (evidence: `src/agents/lawyer_DD.py`)
- Civil Judge → Agent Memory: extends (evidence: `src/agents/judge_CI.py`)
- Criminal Judge → Agent Memory: extends (evidence: `src/agents/judge_CR.py`)
- Public Agents → Agent Memory: extends (evidence: `src/agents/general_public_KQ.py`)
- KQ Trainee → Agent Memory: extends (evidence: `src/agents/trainee_KQ.py`)
- LC Trainee → Agent Memory: extends (evidence: `src/agents/trainee_LC.py`)
- Engine Interface → Class Registry: registers interface (evidence: `src/engine/base_engine.py`)
- Agent Memory → Engine Interface: uses engine
- Model Adapters → Engine Interface: implements interface (evidence: `src/engine/lawllm.py`)
- Legal Consultation → J1-Eval: followed by evaluation (evidence: `README.md`)
- J1-Eval Dataset → J1-Eval: evaluated by (evidence: `README.md`)
