# kbcodes17-stack/reglens architecture

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

- Interactive diagram: https://gitdiagram.com/kbcodes17-stack/reglens
- Repository: https://github.com/kbcodes17-stack/reglens

## Overview

RegLens is a regulatory-change and compliance copilot. Its primary workflow takes an officer from uploading a circular through extraction, verification, control mapping and risk/action analysis to reviewing findings; decisions are recorded in an audit trail. The graph also preserves the documented amendment comparison, register management, dashboard/briefing and authentication areas. Edges reflect the README pipeline and source-index references; unsampled route details and relationships are omitted rather than inferred.

Main entry points: [`backend/main.py`](https://github.com/kbcodes17-stack/reglens/blob/master/backend/main.py) (HTTP API), [`backend/mapping.py`](https://github.com/kbcodes17-stack/reglens/blob/master/backend/mapping.py) (Control mapping), [`backend/llm.py`](https://github.com/kbcodes17-stack/reglens/blob/master/backend/llm.py) (LLM gateway), [`frontend/src/api.ts`](https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["User workspace"]
  node_app["Workspace navigation<br/>[App.tsx]"]
  node_review["Review queue<br/>[Review.tsx]"]
  node_upload["Circular upload<br/>[UploadFlow.tsx]"]
  node_api["API client<br/>[api.ts]"]
  node_amendments["Amendment review<br/>[Amendments.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_analysis["Circular analysis"]
  node_pdf["PDF ingestion<br/>[ingest.py]"]
  node_extract["Obligation extraction<br/>[extract.py]"]
  node_verify["Quote verification<br/>[verify.py]"]
  node_mapping["Control mapping<br/>[mapping.py]"]
  node_embeddings["Embedding service<br/>[embed.py]"]
  node_severity["Severity analysis<br/>[severity.py]"]
  node_gap["Gap analysis<br/>[gaps.py]"]
  node_actions["Action drafting<br/>[actions.py]"]
  node_llm["LLM gateway<br/>[llm.py]"]
  node_amendment_diff["Amendment diff<br/>[diff.py]"]
end

subgraph group_compliance["Compliance operations"]
  node_briefing["Briefing and priority<br/>[briefing.py]"]
  node_registers["Policy and control registers<br/>[registers.py]"]
  node_audit["Audit trail<br/>[audit.py]"]
end

subgraph group_platform["Identity and persistence"]
  node_auth["Authentication<br/>[auth.py]"]
  node_api_server["HTTP API<br/>[main.py]"]
  node_models[("Relational data model<br/>[models.py]")]
end

node_officer(("Officer"))
node_gemini{{"Gemini service"}}
node_groq{{"Groq service"}}

node_officer -->|"uses"| node_app
node_app -->|"routes to"| node_review
node_review -->|"opens for upload"| node_upload
node_review -->|"requests findings"| node_api
node_upload -->|"submits circular"| node_api
node_api -->|"calls API"| node_api_server
node_api_server -->|"authenticates"| node_auth
node_api_server -->|"ingests PDF"| node_pdf
node_api_server -->|"extracts obligations"| node_extract
node_extract -->|"reads page text"| node_pdf
node_api_server -->|"verifies quotes"| node_verify
node_api_server -->|"maps obligations"| node_mapping
node_mapping -->|"computes similarity"| node_embeddings
node_mapping -->|"assesses severity"| node_severity
node_mapping -->|"analyses gaps"| node_gap
node_api_server -->|"drafts actions"| node_actions
node_extract -->|"requests extraction"| node_llm
node_mapping -->|"requests mapping"| node_llm
node_actions -->|"drafts tasks"| node_llm
node_llm -->|"calls provider"| node_gemini
node_llm -->|"falls back"| node_groq
node_api_server -->|"reads and writes"| node_models
node_api_server -->|"manages registers"| node_registers
node_api_server -->|"records decisions"| node_audit
node_api_server -->|"builds briefings"| node_briefing
node_review -->|"opens comparison"| node_amendments
node_amendments -->|"requests comparisons"| node_api
node_api_server -->|"compares versions"| node_amendment_diff
node_dashboard -->|"loads dashboard"| node_api
node_app -->|"routes to"| node_dashboard
node_api_server -->|"persists audit data"| node_models
node_auth -->|"loads user"| node_models
node_mapping -->|"uses controls"| node_registers

click node_app "https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/App.tsx"
click node_review "https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/pages/Review.tsx"
click node_upload "https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/UploadFlow.tsx"
click node_api "https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/api.ts"
click node_amendments "https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/pages/Amendments.tsx"
click node_dashboard "https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/pages/Dashboard.tsx"
click node_pdf "https://github.com/kbcodes17-stack/reglens/blob/master/backend/ingest.py"
click node_extract "https://github.com/kbcodes17-stack/reglens/blob/master/backend/extract.py"
click node_verify "https://github.com/kbcodes17-stack/reglens/blob/master/backend/verify.py"
click node_mapping "https://github.com/kbcodes17-stack/reglens/blob/master/backend/mapping.py"
click node_embeddings "https://github.com/kbcodes17-stack/reglens/blob/master/backend/embed.py"
click node_severity "https://github.com/kbcodes17-stack/reglens/blob/master/backend/severity.py"
click node_gap "https://github.com/kbcodes17-stack/reglens/blob/master/backend/gaps.py"
click node_actions "https://github.com/kbcodes17-stack/reglens/blob/master/backend/actions.py"
click node_llm "https://github.com/kbcodes17-stack/reglens/blob/master/backend/llm.py"
click node_amendment_diff "https://github.com/kbcodes17-stack/reglens/blob/master/backend/diff.py"
click node_briefing "https://github.com/kbcodes17-stack/reglens/blob/master/backend/briefing.py"
click node_registers "https://github.com/kbcodes17-stack/reglens/blob/master/backend/registers.py"
click node_audit "https://github.com/kbcodes17-stack/reglens/blob/master/backend/audit.py"
click node_auth "https://github.com/kbcodes17-stack/reglens/blob/master/backend/auth.py"
click node_api_server "https://github.com/kbcodes17-stack/reglens/blob/master/backend/main.py"
click node_models "https://github.com/kbcodes17-stack/reglens/blob/master/backend/models.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_review,node_upload,node_api,node_amendments,node_dashboard toneBlue
class node_pdf,node_extract,node_verify,node_mapping,node_embeddings,node_severity,node_gap,node_actions,node_llm,node_amendment_diff toneAmber
class node_briefing,node_registers,node_audit toneMint
class node_auth,node_api_server,node_models toneRose
class node_officer,node_gemini,node_groq toneIndigo
```

## Components

### User workspace

- [Workspace navigation](https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Review queue](https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/pages/Review.tsx): `frontend/src/pages/Review.tsx`
- [Circular upload](https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/UploadFlow.tsx): `frontend/src/UploadFlow.tsx`
- [API client](https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/api.ts): `frontend/src/api.ts`
- [Amendment review](https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/pages/Amendments.tsx): `frontend/src/pages/Amendments.tsx`
- [Dashboard](https://github.com/kbcodes17-stack/reglens/blob/master/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`

### Circular analysis

- [PDF ingestion](https://github.com/kbcodes17-stack/reglens/blob/master/backend/ingest.py): `backend/ingest.py`
- [Obligation extraction](https://github.com/kbcodes17-stack/reglens/blob/master/backend/extract.py): `backend/extract.py`
- [Quote verification](https://github.com/kbcodes17-stack/reglens/blob/master/backend/verify.py): `backend/verify.py`
- [Control mapping](https://github.com/kbcodes17-stack/reglens/blob/master/backend/mapping.py): `backend/mapping.py`
- [Embedding service](https://github.com/kbcodes17-stack/reglens/blob/master/backend/embed.py): `backend/embed.py`
- [Severity analysis](https://github.com/kbcodes17-stack/reglens/blob/master/backend/severity.py): `backend/severity.py`
- [Gap analysis](https://github.com/kbcodes17-stack/reglens/blob/master/backend/gaps.py): `backend/gaps.py`
- [Action drafting](https://github.com/kbcodes17-stack/reglens/blob/master/backend/actions.py): `backend/actions.py`
- [LLM gateway](https://github.com/kbcodes17-stack/reglens/blob/master/backend/llm.py): `backend/llm.py`
- [Amendment diff](https://github.com/kbcodes17-stack/reglens/blob/master/backend/diff.py): `backend/diff.py`

### Compliance operations

- [Briefing and priority](https://github.com/kbcodes17-stack/reglens/blob/master/backend/briefing.py): `backend/briefing.py`
- [Policy and control registers](https://github.com/kbcodes17-stack/reglens/blob/master/backend/registers.py): `backend/registers.py`
- [Audit trail](https://github.com/kbcodes17-stack/reglens/blob/master/backend/audit.py): `backend/audit.py`

### Identity and persistence

- [Authentication](https://github.com/kbcodes17-stack/reglens/blob/master/backend/auth.py): `backend/auth.py`
- [HTTP API](https://github.com/kbcodes17-stack/reglens/blob/master/backend/main.py): `backend/main.py`
- [Relational data model](https://github.com/kbcodes17-stack/reglens/blob/master/backend/models.py): `backend/models.py`

### Other components

- **Officer**
- **Gemini service**
- **Groq service**

## Connections

- Officer → Workspace navigation: uses (evidence: `frontend/src/App.tsx`)
- Workspace navigation → Review queue: routes to (evidence: `frontend/src/App.tsx`)
- Review queue → Circular upload: opens for upload (evidence: `frontend/src/pages/Review.tsx`)
- Review queue → API client: requests findings (evidence: `frontend/src/pages/Review.tsx`)
- Circular upload → API client: submits circular (evidence: `frontend/src/UploadFlow.tsx`)
- API client → HTTP API: calls API (evidence: `frontend/src/api.ts`)
- HTTP API → Authentication: authenticates (evidence: `backend/main.py`)
- HTTP API → PDF ingestion: ingests PDF (evidence: `backend/main.py`)
- HTTP API → Obligation extraction: extracts obligations (evidence: `backend/main.py`)
- Obligation extraction → PDF ingestion: reads page text (evidence: `backend/extract.py`)
- HTTP API → Quote verification: verifies quotes (evidence: `backend/main.py`)
- HTTP API → Control mapping: maps obligations (evidence: `backend/main.py`)
- Control mapping → Embedding service: computes similarity (evidence: `backend/mapping.py`)
- Control mapping → Severity analysis: assesses severity (evidence: `backend/mapping.py`)
- Control mapping → Gap analysis: analyses gaps (evidence: `backend/mapping.py`)
- HTTP API → Action drafting: drafts actions (evidence: `backend/main.py`)
- Obligation extraction → LLM gateway: requests extraction (evidence: `backend/extract.py`)
- Control mapping → LLM gateway: requests mapping (evidence: `backend/mapping.py`)
- Action drafting → LLM gateway: drafts tasks (evidence: `backend/actions.py`)
- LLM gateway → Gemini service: calls provider (evidence: `backend/llm.py`)
- LLM gateway → Groq service: falls back (evidence: `backend/llm.py`)
- HTTP API → Relational data model: reads and writes (evidence: `backend/main.py`)
- HTTP API → Policy and control registers: manages registers (evidence: `backend/main.py`)
- HTTP API → Audit trail: records decisions (evidence: `backend/main.py`)
- HTTP API → Briefing and priority: builds briefings (evidence: `backend/main.py`)
- Review queue → Amendment review: opens comparison (evidence: `frontend/src/App.tsx`)
- Amendment review → API client: requests comparisons (evidence: `frontend/src/pages/Amendments.tsx`)
- HTTP API → Amendment diff: compares versions (evidence: `backend/main.py`)
- Dashboard → API client: loads dashboard (evidence: `frontend/src/pages/Dashboard.tsx`)
- Workspace navigation → Dashboard: routes to (evidence: `frontend/src/App.tsx`)
- HTTP API → Relational data model: persists audit data (evidence: `backend/main.py`)
- Authentication → Relational data model: loads user (evidence: `backend/auth.py`)
- Control mapping → Policy and control registers: uses controls (evidence: `backend/mapping.py`)
