# ishaan-bhalla/cmsxharvey architecture

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

- Interactive diagram: https://gitdiagram.com/ishaan-bhalla/cmsxharvey
- Repository: https://github.com/ishaan-bhalla/cmsxharvey

## Overview

Pleading-to-Proof is a legal-evidence analysis application: litigators select witness statements, submit an allegation analysis, review job progress, then inspect evidence, gaps, contradictions, and case risk. The README documents background processing, chunk retrieval, model classification, quote verification, case-law retrieval, human review, snapshots, and graph visualization. The source excerpts establish several backend calls and frontend state transitions; links for unsampled subsystems are included only where README workflow descriptions support them.

Main entry points: [`backend/services/pleading_generator.py`](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/pleading_generator.py) (Allegation analysis), [`backend/main.py`](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/main.py) (Backend API), [`src/lib/analysis-store.ts`](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/lib/analysis-store.ts) (Analysis state), [`backend/services/report_generator.py`](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/report_generator.py) (Analysis orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Analysis entry"]
  node_api["Backend API<br/>[main.py]"]
end

subgraph group_backend["Analysis services"]
  node_pdf["PDF parsing<br/>[document_parser.py]"]
  node_analysis["Analysis orchestration"]
  node_pleading["Allegation analysis"]
  node_allegations["Allegation extraction"]
  node_classification["Evidence classification"]
  node_chunking["Statement chunking<br/>[text_chunker.py]"]
  node_memos["Risk memo<br/>[memo_generator.py]"]
end

subgraph group_integrations["Models and graph"]
  node_claude["Claude API<br/>[claude_client.py]"]
  node_perplexity["Case-law search"]
  node_neo4j[("Witness allegation graph<br/>[neo4j_client.py]")]
end

subgraph group_state["Persistence and review"]
  node_storage[("Jobs, reviews, snapshots<br/>[storage.py]")]
  node_changes["Snapshot comparison<br/>[change_detector.py]"]
end

subgraph group_frontend["Evidence views"]
  node_web["Analysis submission<br/>[index.tsx]"]
  node_api_client["Frontend API client<br/>[api.ts]"]
  node_transform["Result transformation<br/>[transform.ts]"]
  node_store["Analysis state<br/>[analysis-store.ts]"]
  node_board["Evidence board<br/>[board.tsx]"]
  node_matrix["Evidence matrix"]
  node_graph_view["Relationship graph view<br/>[graph.tsx]"]
  node_report["Gaps and risk report<br/>[report.tsx]"]
  node_statement["Statement evidence"]
end

node_litigator(("Litigator"))

node_litigator -->|"selects witnesses"| node_web
node_web -->|"submits and polls"| node_api_client
node_api_client -->|"calls analysis API"| node_api
node_api -->|"runs analysis"| node_analysis
node_api -->|"queues pleading job"| node_pleading
node_analysis -->|"parses statements"| node_pdf
node_analysis -->|"extracts allegations"| node_allegations
node_analysis -->|"classifies evidence"| node_classification
node_pleading -->|"retrieves chunks"| node_chunking
node_pleading -->|"uses parsed statements"| node_pdf
node_pleading -->|"requests verdicts"| node_claude
node_pleading -->|"retrieves authorities"| node_perplexity
node_pleading -->|"builds relationship graph"| node_neo4j
node_api -->|"persists review and snapshots"| node_storage
node_api -->|"compares snapshots"| node_changes
node_api_client -->|"transforms result"| node_transform
node_web -->|"sets analysis"| node_store
node_transform -->|"shapes result"| node_store
node_store -->|"supplies analysis"| node_board
node_store -->|"supplies analysis"| node_matrix
node_store -->|"supplies analysis"| node_report
node_neo4j -->|"feeds visualization"| node_graph_view
node_statement -.->|"loads evidence data"| node_api_client

click node_api "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/main.py"
click node_pdf "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/document_parser.py"
click node_analysis "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/report_generator.py"
click node_pleading "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/pleading_generator.py"
click node_allegations "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/allegation_extractor.py"
click node_classification "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/evidence_classifier.py"
click node_chunking "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/utils/text_chunker.py"
click node_memos "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/memo_generator.py"
click node_claude "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/clients/claude_client.py"
click node_perplexity "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/clients/perplexity_client.py"
click node_neo4j "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/clients/neo4j_client.py"
click node_storage "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/storage.py"
click node_changes "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/change_detector.py"
click node_web "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/index.tsx"
click node_api_client "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/lib/api.ts"
click node_transform "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/lib/transform.ts"
click node_store "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/lib/analysis-store.ts"
click node_board "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/board.tsx"
click node_matrix "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/evidence-matrix.tsx"
click node_graph_view "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/graph.tsx"
click node_report "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/report.tsx"
click node_statement "https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/statement.%24statementId.tsx"

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_api toneBlue
class node_pdf,node_analysis,node_pleading,node_allegations,node_classification,node_chunking,node_memos toneAmber
class node_claude,node_perplexity,node_neo4j toneMint
class node_storage,node_changes toneRose
class node_web,node_api_client,node_transform,node_store,node_board,node_matrix,node_graph_view,node_report,node_statement,node_litigator toneIndigo
```

## Components

### Analysis entry

- [Backend API](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/main.py): `backend/main.py`

### Analysis services

- [PDF parsing](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/document_parser.py): `backend/services/document_parser.py`
- [Analysis orchestration](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/report_generator.py): `backend/services/report_generator.py`
- [Allegation analysis](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/pleading_generator.py): `backend/services/pleading_generator.py`
- [Allegation extraction](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/allegation_extractor.py): `backend/services/allegation_extractor.py`
- [Evidence classification](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/evidence_classifier.py): `backend/services/evidence_classifier.py`
- [Statement chunking](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/utils/text_chunker.py): `backend/utils/text_chunker.py`
- [Risk memo](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/memo_generator.py): `backend/services/memo_generator.py`

### Models and graph

- [Claude API](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/clients/claude_client.py): `backend/clients/claude_client.py`
- [Case-law search](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/clients/perplexity_client.py): `backend/clients/perplexity_client.py`
- [Witness allegation graph](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/clients/neo4j_client.py): `backend/clients/neo4j_client.py`

### Persistence and review

- [Jobs, reviews, snapshots](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/storage.py): `backend/services/storage.py`
- [Snapshot comparison](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/backend/services/change_detector.py): `backend/services/change_detector.py`

### Evidence views

- [Analysis submission](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [Frontend API client](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Result transformation](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/lib/transform.ts): `src/lib/transform.ts`
- [Analysis state](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/lib/analysis-store.ts): `src/lib/analysis-store.ts`
- [Evidence board](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/board.tsx): `src/routes/board.tsx`
- [Evidence matrix](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/evidence-matrix.tsx): `src/routes/evidence-matrix.tsx`
- [Relationship graph view](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/graph.tsx): `src/routes/graph.tsx`
- [Gaps and risk report](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/report.tsx): `src/routes/report.tsx`
- [Statement evidence](https://github.com/ishaan-bhalla/cmsxharvey/blob/main/src/routes/statement.%24statementId.tsx): `src/routes/statement.$statementId.tsx`

### Other components

- **Litigator**

## Connections

- Litigator → Analysis submission: selects witnesses
- Analysis submission → Frontend API client: submits and polls (evidence: `src/routes/index.tsx`)
- Frontend API client → Backend API: calls analysis API
- Backend API → Analysis orchestration: runs analysis (evidence: `backend/main.py`)
- Backend API → Allegation analysis: queues pleading job (evidence: `backend/main.py`)
- Analysis orchestration → PDF parsing: parses statements (evidence: `backend/services/report_generator.py`)
- Analysis orchestration → Allegation extraction: extracts allegations (evidence: `backend/services/report_generator.py`)
- Analysis orchestration → Evidence classification: classifies evidence (evidence: `backend/services/report_generator.py`)
- Allegation analysis → Statement chunking: retrieves chunks (evidence: `backend/services/pleading_generator.py`)
- Allegation analysis → PDF parsing: uses parsed statements (evidence: `backend/services/pleading_generator.py`)
- Allegation analysis → Claude API: requests verdicts (evidence: `backend/services/pleading_generator.py`)
- Allegation analysis → Case-law search: retrieves authorities (evidence: `backend/services/pleading_generator.py`)
- Allegation analysis → Witness allegation graph: builds relationship graph (evidence: `backend/main.py`)
- Backend API → Jobs, reviews, snapshots: persists review and snapshots (evidence: `backend/main.py`)
- Backend API → Snapshot comparison: compares snapshots (evidence: `backend/main.py`)
- Frontend API client → Result transformation: transforms result (evidence: `src/lib/api.ts`)
- Analysis submission → Analysis state: sets analysis (evidence: `src/routes/index.tsx`)
- Result transformation → Analysis state: shapes result (evidence: `src/lib/transform.ts`)
- Analysis state → Evidence board: supplies analysis (evidence: `src/routes/board.tsx`)
- Analysis state → Evidence matrix: supplies analysis (evidence: `src/routes/evidence-matrix.tsx`)
- Analysis state → Gaps and risk report: supplies analysis (evidence: `src/routes/report.tsx`)
- Witness allegation graph → Relationship graph view: feeds visualization
- Statement evidence → Frontend API client: loads evidence data
