# viday-8/u-fir architecture

> Architecture diagram of the GitHub repository viday-8/u-fir, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/viday-8/u-fir
- Repository: https://github.com/viday-8/u-fir

## Overview

Anveshana is an evidence-first case intelligence workspace for Prohibition & Excise officers. Officers authenticate, upload case files, and review extracted, source-linked facts; they can then search cases, inspect briefs and evidence, review identity links, and manage case work. The product also provides drafting, Copilot, hotspot and network analysis, audit, and governance views. The excerpts show ingestion and several core services; route wiring is supported by the indexed references to the read backend entry point, while some capability details come from the README rather than sampled implementation.

Main entry points: [`backend/app/main.py`](https://github.com/viday-8/u-fir/blob/main/backend/app/main.py) (HTTP API), [`backend/app/services/ingest.py`](https://github.com/viday-8/u-fir/blob/main/backend/app/services/ingest.py) (Document ingestion), [`frontend/src/App.tsx`](https://github.com/viday-8/u-fir/blob/main/frontend/src/App.tsx) (Workspace router), [`frontend/src/api.ts`](https://github.com/viday-8/u-fir/blob/main/frontend/src/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Officer workspace"]
  node_app["Workspace router<br/>[App.tsx]"]
  node_shell["Navigation shell<br/>[Shell.tsx]"]
  node_intake_ui["File intake<br/>[Intake.tsx]"]
  node_cockpit["Case cockpit<br/>[Cockpit.tsx]"]
  node_search_ui["Case search<br/>[SearchPage.tsx]"]
  node_review_ui["Identity review<br/>[Relationships.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_case["Case evidence"]
  node_ingest["Document ingestion<br/>[ingest.py]"]
  node_ocr["OCR<br/>[ocr.py]"]
  node_extract["Fact extraction<br/>[extract.py]"]
  node_drafts["Document studio<br/>[drafts.py]"]
  node_legal["Legal suggestions<br/>[legal.py]"]
  node_management["Case administration<br/>[management.py]"]
end

subgraph group_intelligence["Case intelligence"]
  node_resolve["Identity resolution<br/>[resolve.py]"]
  node_search["Text and name search<br/>[search.py]"]
  node_profile["Case profiles<br/>[profile.py]"]
  node_brief["Brief and timeline<br/>[brief.py]"]
  node_graph["Investigation network<br/>[graph.py]"]
  node_copilot["Role-aware Copilot<br/>[copilot.py]"]
  node_analytics["Analytics and governance<br/>[analytics.py]"]
  node_normalise["Name normalisation<br/>[normalise.py]"]
end

subgraph group_platform["Access and records"]
  node_api["HTTP API<br/>[main.py]"]
  node_audit["Audit ledger<br/>[audit.py]"]
  node_access["District access control<br/>[access.py]"]
  node_security["Authentication<br/>[security.py]"]
  node_models[("Case records<br/>[models.py]")]
  node_database[("Database sessions<br/>[db.py]")]
end

node_officer(("Officer"))

node_officer -->|"uses"| node_app
node_app -->|"frames views"| node_shell
node_app -->|"routes to"| node_intake_ui
node_app -->|"routes to"| node_cockpit
node_app -->|"routes to"| node_search_ui
node_app -->|"routes to"| node_review_ui
node_intake_ui -->|"submits files"| node_api_client
node_cockpit -->|"loads case"| node_api_client
node_search_ui -->|"queries"| node_api_client
node_review_ui -->|"reviews links"| node_api_client
node_api_client -->|"requests"| node_api
node_api -->|"enforces scope"| node_access
node_access -->|"reads token"| node_security
node_api -->|"routes ingestion"| node_ingest
node_ingest -->|"reads scans"| node_ocr
node_ingest -->|"processes facts"| node_extract
node_ingest -->|"indexes pages"| node_search
node_ingest -->|"refreshes identities"| node_resolve
node_ingest -->|"logs extraction"| node_audit
node_api -->|"routes search"| node_search
node_search -->|"normalises names"| node_normalise
node_api -->|"routes case brief"| node_brief
node_api -->|"routes profiles"| node_profile
node_profile -->|"normalises fields"| node_normalise
node_api -->|"routes network"| node_graph
node_graph -->|"uses candidates"| node_resolve
node_graph -->|"uses profiles"| node_profile
node_api -->|"routes questions"| node_copilot
node_copilot -->|"uses brief"| node_brief
node_copilot -->|"retrieves evidence"| node_search
node_copilot -->|"normalises queries"| node_normalise
node_api -->|"routes drafting"| node_drafts
node_drafts -->|"gets suggestions"| node_legal
node_drafts -->|"uses case brief"| node_brief
node_api -->|"routes analytics"| node_analytics
node_api -->|"routes administration"| node_management
node_management -->|"records actions"| node_audit
node_ingest -->|"stores documents"| node_models
node_access -->|"scopes cases"| node_models
node_models -->|"uses sessions"| node_database

click node_app "https://github.com/viday-8/u-fir/blob/main/frontend/src/App.tsx"
click node_shell "https://github.com/viday-8/u-fir/blob/main/frontend/src/Shell.tsx"
click node_intake_ui "https://github.com/viday-8/u-fir/blob/main/frontend/src/Intake.tsx"
click node_cockpit "https://github.com/viday-8/u-fir/blob/main/frontend/src/Cockpit.tsx"
click node_search_ui "https://github.com/viday-8/u-fir/blob/main/frontend/src/SearchPage.tsx"
click node_review_ui "https://github.com/viday-8/u-fir/blob/main/frontend/src/Relationships.tsx"
click node_api_client "https://github.com/viday-8/u-fir/blob/main/frontend/src/api.ts"
click node_api "https://github.com/viday-8/u-fir/blob/main/backend/app/main.py"
click node_ingest "https://github.com/viday-8/u-fir/blob/main/backend/app/services/ingest.py"
click node_ocr "https://github.com/viday-8/u-fir/blob/main/backend/app/services/ocr.py"
click node_extract "https://github.com/viday-8/u-fir/blob/main/backend/app/services/extract.py"
click node_resolve "https://github.com/viday-8/u-fir/blob/main/backend/app/services/resolve.py"
click node_search "https://github.com/viday-8/u-fir/blob/main/backend/app/services/search.py"
click node_profile "https://github.com/viday-8/u-fir/blob/main/backend/app/services/profile.py"
click node_brief "https://github.com/viday-8/u-fir/blob/main/backend/app/services/brief.py"
click node_graph "https://github.com/viday-8/u-fir/blob/main/backend/app/services/graph.py"
click node_copilot "https://github.com/viday-8/u-fir/blob/main/backend/app/services/copilot.py"
click node_drafts "https://github.com/viday-8/u-fir/blob/main/backend/app/services/drafts.py"
click node_legal "https://github.com/viday-8/u-fir/blob/main/backend/app/services/legal.py"
click node_analytics "https://github.com/viday-8/u-fir/blob/main/backend/app/services/analytics.py"
click node_management "https://github.com/viday-8/u-fir/blob/main/backend/app/management.py"
click node_audit "https://github.com/viday-8/u-fir/blob/main/backend/app/audit.py"
click node_access "https://github.com/viday-8/u-fir/blob/main/backend/app/access.py"
click node_security "https://github.com/viday-8/u-fir/blob/main/backend/app/security.py"
click node_models "https://github.com/viday-8/u-fir/blob/main/backend/app/models.py"
click node_database "https://github.com/viday-8/u-fir/blob/main/backend/app/db.py"
click node_normalise "https://github.com/viday-8/u-fir/blob/main/backend/app/services/normalise.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_app,node_shell,node_intake_ui,node_cockpit,node_search_ui,node_review_ui,node_api_client toneBlue
class node_ingest,node_ocr,node_extract,node_drafts,node_legal,node_management toneAmber
class node_resolve,node_search,node_profile,node_brief,node_graph,node_copilot,node_analytics,node_normalise toneMint
class node_api,node_audit,node_access,node_security,node_models,node_database toneRose
class node_officer toneIndigo
```

## Components

### Officer workspace

- [Workspace router](https://github.com/viday-8/u-fir/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Navigation shell](https://github.com/viday-8/u-fir/blob/main/frontend/src/Shell.tsx): `frontend/src/Shell.tsx`
- [File intake](https://github.com/viday-8/u-fir/blob/main/frontend/src/Intake.tsx): `frontend/src/Intake.tsx`
- [Case cockpit](https://github.com/viday-8/u-fir/blob/main/frontend/src/Cockpit.tsx): `frontend/src/Cockpit.tsx`
- [Case search](https://github.com/viday-8/u-fir/blob/main/frontend/src/SearchPage.tsx): `frontend/src/SearchPage.tsx`
- [Identity review](https://github.com/viday-8/u-fir/blob/main/frontend/src/Relationships.tsx): `frontend/src/Relationships.tsx`
- [API client](https://github.com/viday-8/u-fir/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### Case evidence

- [Document ingestion](https://github.com/viday-8/u-fir/blob/main/backend/app/services/ingest.py): `backend/app/services/ingest.py`
- [OCR](https://github.com/viday-8/u-fir/blob/main/backend/app/services/ocr.py): `backend/app/services/ocr.py`
- [Fact extraction](https://github.com/viday-8/u-fir/blob/main/backend/app/services/extract.py): `backend/app/services/extract.py`
- [Document studio](https://github.com/viday-8/u-fir/blob/main/backend/app/services/drafts.py): `backend/app/services/drafts.py`
- [Legal suggestions](https://github.com/viday-8/u-fir/blob/main/backend/app/services/legal.py): `backend/app/services/legal.py`
- [Case administration](https://github.com/viday-8/u-fir/blob/main/backend/app/management.py): `backend/app/management.py`

### Case intelligence

- [Identity resolution](https://github.com/viday-8/u-fir/blob/main/backend/app/services/resolve.py): `backend/app/services/resolve.py`
- [Text and name search](https://github.com/viday-8/u-fir/blob/main/backend/app/services/search.py): `backend/app/services/search.py`
- [Case profiles](https://github.com/viday-8/u-fir/blob/main/backend/app/services/profile.py): `backend/app/services/profile.py`
- [Brief and timeline](https://github.com/viday-8/u-fir/blob/main/backend/app/services/brief.py): `backend/app/services/brief.py`
- [Investigation network](https://github.com/viday-8/u-fir/blob/main/backend/app/services/graph.py): `backend/app/services/graph.py`
- [Role-aware Copilot](https://github.com/viday-8/u-fir/blob/main/backend/app/services/copilot.py): `backend/app/services/copilot.py`
- [Analytics and governance](https://github.com/viday-8/u-fir/blob/main/backend/app/services/analytics.py): `backend/app/services/analytics.py`
- [Name normalisation](https://github.com/viday-8/u-fir/blob/main/backend/app/services/normalise.py): `backend/app/services/normalise.py`

### Access and records

- [HTTP API](https://github.com/viday-8/u-fir/blob/main/backend/app/main.py): `backend/app/main.py`
- [Audit ledger](https://github.com/viday-8/u-fir/blob/main/backend/app/audit.py): `backend/app/audit.py`
- [District access control](https://github.com/viday-8/u-fir/blob/main/backend/app/access.py): `backend/app/access.py`
- [Authentication](https://github.com/viday-8/u-fir/blob/main/backend/app/security.py): `backend/app/security.py`
- [Case records](https://github.com/viday-8/u-fir/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database sessions](https://github.com/viday-8/u-fir/blob/main/backend/app/db.py): `backend/app/db.py`

### Other components

- **Officer**

## Connections

- Officer → Workspace router: uses (evidence: `README.md`)
- Workspace router → Navigation shell: frames views (evidence: `frontend/src/App.tsx`)
- Workspace router → File intake: routes to (evidence: `frontend/src/App.tsx`)
- Workspace router → Case cockpit: routes to (evidence: `frontend/src/App.tsx`)
- Workspace router → Case search: routes to (evidence: `frontend/src/App.tsx`)
- Workspace router → Identity review: routes to (evidence: `frontend/src/App.tsx`)
- File intake → API client: submits files (evidence: `frontend/src/Intake.tsx`)
- Case cockpit → API client: loads case (evidence: `frontend/src/Cockpit.tsx`)
- Case search → API client: queries (evidence: `frontend/src/SearchPage.tsx`)
- Identity review → API client: reviews links (evidence: `frontend/src/Relationships.tsx`)
- API client → HTTP API: requests (evidence: `frontend/src/api.ts`)
- HTTP API → District access control: enforces scope (evidence: `backend/app/main.py`)
- District access control → Authentication: reads token (evidence: `backend/app/access.py`)
- HTTP API → Document ingestion: routes ingestion (evidence: `backend/app/main.py`)
- Document ingestion → OCR: reads scans (evidence: `backend/app/services/ingest.py`)
- Document ingestion → Fact extraction: processes facts (evidence: `backend/app/services/ingest.py`)
- Document ingestion → Text and name search: indexes pages (evidence: `backend/app/services/ingest.py`)
- Document ingestion → Identity resolution: refreshes identities (evidence: `backend/app/services/ingest.py`)
- Document ingestion → Audit ledger: logs extraction (evidence: `backend/app/services/ingest.py`)
- HTTP API → Text and name search: routes search (evidence: `backend/app/main.py`)
- Text and name search → Name normalisation: normalises names (evidence: `backend/app/services/search.py`)
- HTTP API → Brief and timeline: routes case brief (evidence: `backend/app/main.py`)
- HTTP API → Case profiles: routes profiles (evidence: `backend/app/main.py`)
- Case profiles → Name normalisation: normalises fields (evidence: `backend/app/services/profile.py`)
- HTTP API → Investigation network: routes network (evidence: `backend/app/main.py`)
- Investigation network → Identity resolution: uses candidates (evidence: `backend/app/services/graph.py`)
- Investigation network → Case profiles: uses profiles (evidence: `backend/app/services/graph.py`)
- HTTP API → Role-aware Copilot: routes questions (evidence: `backend/app/main.py`)
- Role-aware Copilot → Brief and timeline: uses brief (evidence: `backend/app/services/copilot.py`)
- Role-aware Copilot → Text and name search: retrieves evidence (evidence: `backend/app/services/copilot.py`)
- Role-aware Copilot → Name normalisation: normalises queries (evidence: `backend/app/services/copilot.py`)
- HTTP API → Document studio: routes drafting (evidence: `backend/app/main.py`)
- Document studio → Legal suggestions: gets suggestions (evidence: `backend/app/services/drafts.py`)
- Document studio → Brief and timeline: uses case brief (evidence: `backend/app/services/drafts.py`)
- HTTP API → Analytics and governance: routes analytics (evidence: `backend/app/main.py`)
- HTTP API → Case administration: routes administration (evidence: `backend/app/main.py`)
- Case administration → Audit ledger: records actions (evidence: `backend/app/management.py`)
- Document ingestion → Case records: stores documents (evidence: `backend/app/services/ingest.py`)
- District access control → Case records: scopes cases (evidence: `backend/app/access.py`)
- Case records → Database sessions: uses sessions (evidence: `backend/app/models.py`)
