# airz-raj/by-law architecture

> Architecture diagram of the GitHub repository airz-raj/by-law, 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/airz-raj/by-law
- Repository: https://github.com/airz-raj/by-law

## Overview

Mohlat helps people understand a legal notice, calculate a response deadline, and identify practical next steps. The main workflow runs from browser intake through API routing and document analysis to an evidence-backed report; follow-up features support agreement cross-checks, document-grounded questions, and legal-aid checks. The README also documents briefing sheets and calendar reminders. The graph reflects documented capabilities and indexed references; some frontend and pipeline internals were not excerpted, so uncertain connections are omitted.

Main entry points: [`web/js/main.js`](https://github.com/airz-raj/by-law/blob/main/web/js/main.js) (Browser workflow), [`app/services/pipeline.py`](https://github.com/airz-raj/by-law/blob/main/app/services/pipeline.py) (Analysis pipeline), [`app/api/routes.py`](https://github.com/airz-raj/by-law/blob/main/app/api/routes.py) (API routes), [`web/js/api.js`](https://github.com/airz-raj/by-law/blob/main/web/js/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_app_shell["Browser workflow<br/>[main.js]"]
  node_intake_ui["Notice intake<br/>[intake.js]"]
  node_api_client["API client<br/>[api.js]"]
  node_report_ui["Report display<br/>[report.js]"]
  node_source_view["Source receipts<br/>[source-view.js]"]
end

subgraph group_api["API and services"]
  node_api_app["Application setup<br/>[main.py]"]
  node_routes["API routes<br/>[routes.py]"]
  node_services["Service assembly<br/>[dependencies.py]"]
  node_extract["Document extraction<br/>[extract.py]"]
end

subgraph group_analysis["Notice analysis"]
  node_pipeline["Analysis pipeline<br/>[pipeline.py]"]
  node_gemini["Gemini model adapter<br/>[llm.py]"]
  node_redaction["Identifier masking<br/>[redaction.py]"]
  node_screening["Content screening<br/>[screening.py]"]
  node_evidence["Quote verification<br/>[evidence.py]"]
  node_rulebook["Rule matching<br/>[rulebook.py]"]
  node_deadlines["Deadline calculation<br/>[deadlines.py]"]
end

subgraph group_followup["Follow-up support"]
  node_crosscheck["Agreement cross-check<br/>[crosscheck.js]"]
  node_questions["Document questions<br/>[ask.js]"]
  node_legal_aid["Legal-aid eligibility<br/>[legal_aid.py]"]
  node_briefing["Briefing and calendar<br/>[briefing.js]"]
end

node_person(("Notice recipient"))
node_model_service{{"Gemini service"}}

node_person -->|"submits notice"| node_app_shell
node_app_shell -->|"builds request"| node_intake_ui
node_app_shell -->|"requests decode"| node_api_client
node_api_client -.->|"sends request"| node_api_app
node_api_app -->|"mounts routes"| node_routes
node_routes -->|"gets services"| node_services
node_routes -->|"extracts upload"| node_extract
node_routes -->|"decodes notice"| node_pipeline
node_services -->|"builds adapter"| node_gemini
node_pipeline -->|"masks text"| node_redaction
node_pipeline -->|"screens text"| node_screening
node_pipeline -->|"requests extraction"| node_gemini
node_gemini -->|"calls model"| node_model_service
node_pipeline -->|"verifies quotes"| node_evidence
node_pipeline -->|"matches rules"| node_rulebook
node_pipeline -->|"computes date"| node_deadlines
node_app_shell -->|"renders report"| node_report_ui
node_report_ui -->|"shows receipts"| node_source_view
node_app_shell -->|"renders check"| node_crosscheck
node_app_shell -->|"renders questions"| node_questions
node_crosscheck -->|"sends comparison"| node_api_client
node_questions -->|"sends question"| node_api_client
node_routes -->|"checks eligibility"| node_legal_aid
node_app_shell -->|"renders briefing"| node_briefing

click node_app_shell "https://github.com/airz-raj/by-law/blob/main/web/js/main.js"
click node_intake_ui "https://github.com/airz-raj/by-law/blob/main/web/js/intake.js"
click node_api_client "https://github.com/airz-raj/by-law/blob/main/web/js/api.js"
click node_report_ui "https://github.com/airz-raj/by-law/blob/main/web/js/report.js"
click node_source_view "https://github.com/airz-raj/by-law/blob/main/web/js/source-view.js"
click node_api_app "https://github.com/airz-raj/by-law/blob/main/app/main.py"
click node_routes "https://github.com/airz-raj/by-law/blob/main/app/api/routes.py"
click node_services "https://github.com/airz-raj/by-law/blob/main/app/api/dependencies.py"
click node_extract "https://github.com/airz-raj/by-law/blob/main/app/adapters/extract.py"
click node_pipeline "https://github.com/airz-raj/by-law/blob/main/app/services/pipeline.py"
click node_gemini "https://github.com/airz-raj/by-law/blob/main/app/adapters/llm.py"
click node_redaction "https://github.com/airz-raj/by-law/blob/main/app/core/redaction.py"
click node_screening "https://github.com/airz-raj/by-law/blob/main/app/core/screening.py"
click node_evidence "https://github.com/airz-raj/by-law/blob/main/app/core/evidence.py"
click node_rulebook "https://github.com/airz-raj/by-law/blob/main/app/core/rulebook.py"
click node_deadlines "https://github.com/airz-raj/by-law/blob/main/app/core/deadlines.py"
click node_crosscheck "https://github.com/airz-raj/by-law/blob/main/web/js/crosscheck.js"
click node_questions "https://github.com/airz-raj/by-law/blob/main/web/js/ask.js"
click node_legal_aid "https://github.com/airz-raj/by-law/blob/main/app/core/legal_aid.py"
click node_briefing "https://github.com/airz-raj/by-law/blob/main/web/js/briefing.js"

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_app_shell,node_intake_ui,node_api_client,node_report_ui,node_source_view toneBlue
class node_api_app,node_routes,node_services,node_extract toneAmber
class node_pipeline,node_gemini,node_redaction,node_screening,node_evidence,node_rulebook,node_deadlines toneMint
class node_crosscheck,node_questions,node_legal_aid,node_briefing toneRose
class node_person,node_model_service toneIndigo
```

## Components

### User experience

- [Browser workflow](https://github.com/airz-raj/by-law/blob/main/web/js/main.js): `web/js/main.js`
- [Notice intake](https://github.com/airz-raj/by-law/blob/main/web/js/intake.js): `web/js/intake.js`
- [API client](https://github.com/airz-raj/by-law/blob/main/web/js/api.js): `web/js/api.js`
- [Report display](https://github.com/airz-raj/by-law/blob/main/web/js/report.js): `web/js/report.js`
- [Source receipts](https://github.com/airz-raj/by-law/blob/main/web/js/source-view.js): `web/js/source-view.js`

### API and services

- [Application setup](https://github.com/airz-raj/by-law/blob/main/app/main.py): `app/main.py`
- [API routes](https://github.com/airz-raj/by-law/blob/main/app/api/routes.py): `app/api/routes.py`
- [Service assembly](https://github.com/airz-raj/by-law/blob/main/app/api/dependencies.py): `app/api/dependencies.py`
- [Document extraction](https://github.com/airz-raj/by-law/blob/main/app/adapters/extract.py): `app/adapters/extract.py`

### Notice analysis

- [Analysis pipeline](https://github.com/airz-raj/by-law/blob/main/app/services/pipeline.py): `app/services/pipeline.py`
- [Gemini model adapter](https://github.com/airz-raj/by-law/blob/main/app/adapters/llm.py): `app/adapters/llm.py`
- [Identifier masking](https://github.com/airz-raj/by-law/blob/main/app/core/redaction.py): `app/core/redaction.py`
- [Content screening](https://github.com/airz-raj/by-law/blob/main/app/core/screening.py): `app/core/screening.py`
- [Quote verification](https://github.com/airz-raj/by-law/blob/main/app/core/evidence.py): `app/core/evidence.py`
- [Rule matching](https://github.com/airz-raj/by-law/blob/main/app/core/rulebook.py): `app/core/rulebook.py`
- [Deadline calculation](https://github.com/airz-raj/by-law/blob/main/app/core/deadlines.py): `app/core/deadlines.py`

### Follow-up support

- [Agreement cross-check](https://github.com/airz-raj/by-law/blob/main/web/js/crosscheck.js): `web/js/crosscheck.js`
- [Document questions](https://github.com/airz-raj/by-law/blob/main/web/js/ask.js): `web/js/ask.js`
- [Legal-aid eligibility](https://github.com/airz-raj/by-law/blob/main/app/core/legal_aid.py): `app/core/legal_aid.py`
- [Briefing and calendar](https://github.com/airz-raj/by-law/blob/main/web/js/briefing.js): `web/js/briefing.js`

### Other components

- **Notice recipient**
- **Gemini service**

## Connections

- Notice recipient → Browser workflow: submits notice (evidence: `README.md`)
- Browser workflow → Notice intake: builds request (evidence: `web/js/main.js`)
- Browser workflow → API client: requests decode (evidence: `web/js/main.js`)
- API client → Application setup: sends request
- Application setup → API routes: mounts routes (evidence: `app/main.py`)
- API routes → Service assembly: gets services (evidence: `app/api/dependencies.py`)
- API routes → Document extraction: extracts upload
- API routes → Analysis pipeline: decodes notice (evidence: `app/api/routes.py`)
- Service assembly → Gemini model adapter: builds adapter (evidence: `app/api/dependencies.py`)
- Analysis pipeline → Identifier masking: masks text (evidence: `app/services/pipeline.py`)
- Analysis pipeline → Content screening: screens text (evidence: `app/services/pipeline.py`)
- Analysis pipeline → Gemini model adapter: requests extraction (evidence: `app/services/pipeline.py`)
- Gemini model adapter → Gemini service: calls model (evidence: `app/adapters/llm.py`)
- Analysis pipeline → Quote verification: verifies quotes (evidence: `app/services/pipeline.py`)
- Analysis pipeline → Rule matching: matches rules (evidence: `app/services/pipeline.py`)
- Analysis pipeline → Deadline calculation: computes date (evidence: `app/services/pipeline.py`)
- Browser workflow → Report display: renders report (evidence: `web/js/main.js`)
- Report display → Source receipts: shows receipts (evidence: `web/js/report.js`)
- Browser workflow → Agreement cross-check: renders check (evidence: `web/js/main.js`)
- Browser workflow → Document questions: renders questions (evidence: `web/js/main.js`)
- Agreement cross-check → API client: sends comparison (evidence: `web/js/crosscheck.js`)
- Document questions → API client: sends question (evidence: `web/js/ask.js`)
- API routes → Legal-aid eligibility: checks eligibility (evidence: `app/api/routes.py`)
- Browser workflow → Briefing and calendar: renders briefing (evidence: `web/js/main.js`)
