# ivanmiao/hackthelaw architecture

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

- Interactive diagram: https://gitdiagram.com/ivanmiao/hackthelaw
- Repository: https://github.com/ivanmiao/hackthelaw

## Overview

Domino is a French civil-procedure analysis product: lawyers select or provide a matter, review source-grounded facts and legal qualifications, and inspect procedural consequence chains. The backend ingests documents, retrieves supporting material, runs extraction and qualification agents, then applies the analysis engine. The frontend also supports case integrations, lawyer review, and voice interaction. Several routes and voice internals are unsampled, so those links are omitted where the available evidence does not establish runtime calls.

Main entry points: [`web/server/pipeline.ts`](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/pipeline.ts) (Matter pipeline), [`web/src/App.tsx`](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/App.tsx) (Case workspace), [`web/src/engine/chains.ts`](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/chains.ts) (Consequence chains), [`web/server/integrations/api.ts`](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/api.ts) (Firm API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Case workspace"]
  node_workspace["Case workspace<br/>[App.tsx]"]
  node_case_catalog["Case catalog<br/>[catalog.ts]"]
  node_case_documents["Case documents<br/>[documents.ts]"]
  node_review_state["Review state<br/>[reviewStorage.ts]"]
  node_locale["Localization<br/>[translate.ts]"]
end

subgraph group_analysis["Legal analysis"]
  node_analysis_engine["Consequence chains<br/>[chains.ts]"]
  node_deadline_rules["Deadline rules<br/>[dates.ts]"]
  node_additional_chains["Additional chains"]
end

subgraph group_backend["Matter processing"]
  node_matter_pipeline["Matter pipeline<br/>[pipeline.ts]"]
  node_document_ingestion["Document ingestion<br/>[ingest.ts]"]
  node_retrieval["Evidence retrieval<br/>[retrieval.ts]"]
  node_case_extraction["Fact extraction<br/>[extract.ts]"]
  node_fact_qualification["Fact qualification<br/>[qualify.ts]"]
  node_prompts["Agent prompts<br/>[prompts.ts]"]
  node_llm_providers["AI provider client<br/>[providers.ts]"]
  node_law_library["Legal library<br/>[library.ts]"]
end

subgraph group_integrations["Firm integrations"]
  node_integration_api["Firm API<br/>[api.ts]"]
  node_integration_contracts["Integration contracts<br/>[contracts.ts]"]
  node_integration_providers["Integration providers<br/>[providers.ts]"]
  node_integration_store[("Integration database<br/>[sqlite.ts]")]
end

subgraph group_voice["Voice interaction"]
  node_voice_ui["Voice panel<br/>[VoicePanel.tsx]"]
  node_voice_client["Voice client<br/>[client.ts]"]
  node_voice_server["Voice server<br/>[voice-api.ts]"]
end

node_lawyer(("Lawyer"))
node_local_storage[("Browser storage")]

node_lawyer -->|"uses"| node_workspace
node_workspace -->|"selects cases"| node_case_catalog
node_workspace -->|"saves reviews"| node_review_state
node_review_state -->|"reads and writes"| node_local_storage
node_workspace -->|"runs analysis"| node_analysis_engine
node_analysis_engine -->|"computes deadlines"| node_deadline_rules
node_analysis_engine -->|"derives chains"| node_additional_chains
node_workspace -->|"translates interface"| node_locale
node_case_catalog -->|"loads documents"| node_case_documents
node_matter_pipeline -->|"ingests documents"| node_document_ingestion
node_matter_pipeline -->|"loads library"| node_law_library
node_matter_pipeline -->|"builds index"| node_retrieval
node_matter_pipeline -->|"extracts facts"| node_case_extraction
node_matter_pipeline -->|"qualifies facts"| node_fact_qualification
node_matter_pipeline -->|"analyses bundle"| node_analysis_engine
node_matter_pipeline -->|"creates client"| node_llm_providers
node_document_ingestion -->|"extracts document text"| node_llm_providers
node_document_ingestion -->|"uses prompts"| node_prompts
node_retrieval -.->|"embeds evidence"| node_llm_providers
node_case_extraction -.->|"uses prompts"| node_prompts
node_fact_qualification -.->|"uses prompts"| node_prompts
node_integration_api -->|"validates payloads"| node_integration_contracts
node_integration_api -->|"uses providers"| node_integration_providers
node_integration_api -->|"persists integration data"| node_integration_store
node_lawyer -->|"uses voice"| node_voice_ui
node_voice_ui -.->|"voice requests"| node_voice_client
node_voice_client -.->|"connects to voice service"| node_voice_server

click node_workspace "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/App.tsx"
click node_case_catalog "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/data/catalog.ts"
click node_case_documents "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/data/documents.ts"
click node_review_state "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/reviewStorage.ts"
click node_locale "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/i18n/translate.ts"
click node_analysis_engine "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/chains.ts"
click node_deadline_rules "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/dates.ts"
click node_additional_chains "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/additionalChains.ts"
click node_matter_pipeline "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/pipeline.ts"
click node_document_ingestion "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/ingest.ts"
click node_retrieval "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/retrieval.ts"
click node_case_extraction "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/agents/extract.ts"
click node_fact_qualification "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/agents/qualify.ts"
click node_prompts "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/agents/prompts.ts"
click node_llm_providers "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/providers.ts"
click node_law_library "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/library.ts"
click node_integration_api "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/api.ts"
click node_integration_contracts "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/contracts.ts"
click node_integration_providers "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/providers.ts"
click node_integration_store "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/sqlite.ts"
click node_voice_ui "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/components/VoicePanel.tsx"
click node_voice_client "https://github.com/ivanmiao/hackthelaw/blob/main/web/src/voice/client.ts"
click node_voice_server "https://github.com/ivanmiao/hackthelaw/blob/main/web/server/voice-api.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_workspace,node_case_catalog,node_case_documents,node_review_state,node_locale toneBlue
class node_analysis_engine,node_deadline_rules,node_additional_chains,node_local_storage toneAmber
class node_matter_pipeline,node_document_ingestion,node_retrieval,node_case_extraction,node_fact_qualification,node_prompts,node_llm_providers,node_law_library toneMint
class node_integration_api,node_integration_contracts,node_integration_providers,node_integration_store toneRose
class node_voice_ui,node_voice_client,node_voice_server,node_lawyer toneIndigo
```

## Components

### Case workspace

- [Case workspace](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Case catalog](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/data/catalog.ts): `web/src/data/catalog.ts`
- [Case documents](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/data/documents.ts): `web/src/data/documents.ts`
- [Review state](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/reviewStorage.ts): `web/src/engine/reviewStorage.ts`
- [Localization](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/i18n/translate.ts): `web/src/i18n/translate.ts`

### Legal analysis

- [Consequence chains](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/chains.ts): `web/src/engine/chains.ts`
- [Deadline rules](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/dates.ts): `web/src/engine/dates.ts`
- [Additional chains](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/engine/additionalChains.ts): `web/src/engine/additionalChains.ts`

### Matter processing

- [Matter pipeline](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/pipeline.ts): `web/server/pipeline.ts`
- [Document ingestion](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/ingest.ts): `web/server/ingest.ts`
- [Evidence retrieval](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/retrieval.ts): `web/server/retrieval.ts`
- [Fact extraction](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/agents/extract.ts): `web/server/agents/extract.ts`
- [Fact qualification](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/agents/qualify.ts): `web/server/agents/qualify.ts`
- [Agent prompts](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/agents/prompts.ts): `web/server/agents/prompts.ts`
- [AI provider client](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/providers.ts): `web/server/providers.ts`
- [Legal library](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/library.ts): `web/server/library.ts`

### Firm integrations

- [Firm API](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/api.ts): `web/server/integrations/api.ts`
- [Integration contracts](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/contracts.ts): `web/server/integrations/contracts.ts`
- [Integration providers](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/providers.ts): `web/server/integrations/providers.ts`
- [Integration database](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/integrations/sqlite.ts): `web/server/integrations/sqlite.ts`

### Voice interaction

- [Voice panel](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/components/VoicePanel.tsx): `web/src/components/VoicePanel.tsx`
- [Voice client](https://github.com/ivanmiao/hackthelaw/blob/main/web/src/voice/client.ts): `web/src/voice/client.ts`
- [Voice server](https://github.com/ivanmiao/hackthelaw/blob/main/web/server/voice-api.ts): `web/server/voice-api.ts`

### Other components

- **Lawyer**
- **Browser storage**

## Connections

- Lawyer → Case workspace: uses
- Case workspace → Case catalog: selects cases (evidence: `web/src/App.tsx`)
- Case workspace → Review state: saves reviews (evidence: `web/src/App.tsx`)
- Review state → Browser storage: reads and writes
- Case workspace → Consequence chains: runs analysis (evidence: `web/src/App.tsx`)
- Consequence chains → Deadline rules: computes deadlines (evidence: `web/src/engine/chains.ts`)
- Consequence chains → Additional chains: derives chains (evidence: `web/src/engine/chains.ts`)
- Case workspace → Localization: translates interface
- Case catalog → Case documents: loads documents (evidence: `web/src/data/catalog.ts`)
- Matter pipeline → Document ingestion: ingests documents (evidence: `web/server/pipeline.ts`)
- Matter pipeline → Legal library: loads library (evidence: `web/server/pipeline.ts`)
- Matter pipeline → Evidence retrieval: builds index (evidence: `web/server/pipeline.ts`)
- Matter pipeline → Fact extraction: extracts facts (evidence: `web/server/pipeline.ts`)
- Matter pipeline → Fact qualification: qualifies facts (evidence: `web/server/pipeline.ts`)
- Matter pipeline → Consequence chains: analyses bundle (evidence: `web/server/pipeline.ts`)
- Matter pipeline → AI provider client: creates client (evidence: `web/server/pipeline.ts`)
- Document ingestion → AI provider client: extracts document text (evidence: `web/server/ingest.ts`)
- Document ingestion → Agent prompts: uses prompts (evidence: `web/server/ingest.ts`)
- Evidence retrieval → AI provider client: embeds evidence (evidence: `web/server/retrieval.ts`)
- Fact extraction → Agent prompts: uses prompts (evidence: `web/server/agents/extract.ts`)
- Fact qualification → Agent prompts: uses prompts (evidence: `web/server/agents/qualify.ts`)
- Firm API → Integration contracts: validates payloads (evidence: `web/server/integrations/api.ts`)
- Firm API → Integration providers: uses providers (evidence: `web/server/integrations/api.ts`)
- Firm API → Integration database: persists integration data (evidence: `web/server/integrations/api.ts`)
- Lawyer → Voice panel: uses voice
- Voice panel → Voice client: voice requests
- Voice client → Voice server: connects to voice service
