# harsh-gogri/compliance-copilot architecture

> Architecture diagram of the GitHub repository harsh-gogri/compliance-copilot, 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/harsh-gogri/compliance-copilot
- Repository: https://github.com/harsh-gogri/compliance-copilot

## Overview

Compliance Copilot audits call-center script lines against RBI material, returning a compliance status, citation, explanation, and—when needed—a rewrite. The main request flow is API routing → sentence-level checking → retrieval and grounded model evaluation; a second API operation compares current and draft results. A separate corpus-preparation flow extracts, chunks, and embeds regulatory text. The README also describes a browser interface and MFI/general plus v1/v2 filtering. The interface-to-API connection is not shown in the sampled source, so it is not asserted here.

Main entry points: [`api/index.py`](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/index.py) (HTTP API), [`api/check_line.py`](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_line.py) (Line Evaluator), [`build_index.py`](https://github.com/harsh-gogri/compliance-copilot/blob/main/build_index.py) (Embedding Indexer), [`api/check_script.py`](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_script.py) (Script Checker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_web["Browser App<br/>[index.html]"]
  node_api["HTTP API<br/>[index.py]"]
end

subgraph group_audit["Script Auditing"]
  node_script_check["Script Checker<br/>[check_script.py]"]
  node_diff["Version Diff<br/>[diff_script.py]"]
  node_line_check["Line Evaluator<br/>[check_line.py]"]
  node_retrieval["Rule Retrieval<br/>[check_line.py]"]
end

subgraph group_knowledge["Regulatory Knowledge"]
  node_pdfs["RBI Documents"]
  node_extract["Text Extraction<br/>[extract_text.py]"]
  node_raw_text["Extracted Text<br/>[raw_text.txt]"]
  node_chunking["Paragraph Chunking"]
  node_chunks["Rule Chunks<br/>[chunks.json]"]
  node_indexing["Embedding Indexer<br/>[build_index.py]"]
  node_vector_index[("Vector Index<br/>[vector_index.json]")]
end

subgraph group_integrations["External Services"]
  node_gemini{{"Gemini Models"}}
end

node_user(("Auditor"))

node_user -->|"uses"| node_web
node_user -->|"submits scripts"| node_api
node_api -->|"routes checks"| node_script_check
node_api -->|"routes comparisons"| node_diff
node_script_check -->|"checks each sentence"| node_line_check
node_diff -->|"checks both versions"| node_script_check
node_line_check -->|"retrieves context"| node_retrieval
node_retrieval -->|"reads rules"| node_vector_index
node_retrieval -->|"embeds query"| node_gemini
node_line_check -->|"requests evaluation"| node_gemini
node_pdfs -->|"provides source text"| node_extract
node_extract -->|"writes"| node_raw_text
node_raw_text -->|"provides text"| node_chunking
node_chunking -->|"writes chunks"| node_chunks
node_chunks -->|"provides chunks"| node_indexing
node_indexing -->|"creates embeddings"| node_gemini
node_indexing -->|"writes"| node_vector_index

click node_web "https://github.com/harsh-gogri/compliance-copilot/blob/main/public/index.html"
click node_api "https://github.com/harsh-gogri/compliance-copilot/blob/main/api/index.py"
click node_script_check "https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_script.py"
click node_diff "https://github.com/harsh-gogri/compliance-copilot/blob/main/api/diff_script.py"
click node_line_check "https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_line.py"
click node_retrieval "https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_line.py"
click node_pdfs "https://github.com/harsh-gogri/compliance-copilot/tree/main/source-docs/v1"
click node_extract "https://github.com/harsh-gogri/compliance-copilot/blob/main/extract_text.py"
click node_raw_text "https://github.com/harsh-gogri/compliance-copilot/blob/main/raw_text.txt"
click node_chunking "https://github.com/harsh-gogri/compliance-copilot/blob/main/chunk_paragraphs.py"
click node_chunks "https://github.com/harsh-gogri/compliance-copilot/blob/main/chunks.json"
click node_indexing "https://github.com/harsh-gogri/compliance-copilot/blob/main/build_index.py"
click node_vector_index "https://github.com/harsh-gogri/compliance-copilot/blob/main/vector_index.json"

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_web,node_api toneBlue
class node_script_check,node_diff,node_line_check,node_retrieval toneAmber
class node_pdfs,node_extract,node_raw_text,node_chunking,node_chunks,node_indexing,node_vector_index toneMint
class node_gemini toneRose
class node_user toneIndigo
```

## Components

### User Interface

- [Browser App](https://github.com/harsh-gogri/compliance-copilot/blob/main/public/index.html): `public/index.html`
- [HTTP API](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/index.py): `api/index.py`

### Script Auditing

- [Script Checker](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_script.py): `api/check_script.py`
- [Version Diff](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/diff_script.py): `api/diff_script.py`
- [Line Evaluator](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_line.py): `api/check_line.py`
- [Rule Retrieval](https://github.com/harsh-gogri/compliance-copilot/blob/main/api/check_line.py): `api/check_line.py`

### Regulatory Knowledge

- [RBI Documents](https://github.com/harsh-gogri/compliance-copilot/tree/main/source-docs/v1): `source-docs/v1`
- [Text Extraction](https://github.com/harsh-gogri/compliance-copilot/blob/main/extract_text.py): `extract_text.py`
- [Extracted Text](https://github.com/harsh-gogri/compliance-copilot/blob/main/raw_text.txt): `raw_text.txt`
- [Paragraph Chunking](https://github.com/harsh-gogri/compliance-copilot/blob/main/chunk_paragraphs.py): `chunk_paragraphs.py`
- [Rule Chunks](https://github.com/harsh-gogri/compliance-copilot/blob/main/chunks.json): `chunks.json`
- [Embedding Indexer](https://github.com/harsh-gogri/compliance-copilot/blob/main/build_index.py): `build_index.py`
- [Vector Index](https://github.com/harsh-gogri/compliance-copilot/blob/main/vector_index.json): `vector_index.json`

### External Services

- **Gemini Models**

### Other components

- **Auditor**

## Connections

- Auditor → Browser App: uses (evidence: `README.md`)
- Auditor → HTTP API: submits scripts (evidence: `api/index.py`)
- HTTP API → Script Checker: routes checks (evidence: `api/index.py`)
- HTTP API → Version Diff: routes comparisons (evidence: `api/index.py`)
- Script Checker → Line Evaluator: checks each sentence (evidence: `api/check_script.py`)
- Version Diff → Script Checker: checks both versions (evidence: `api/diff_script.py`)
- Line Evaluator → Rule Retrieval: retrieves context (evidence: `api/check_line.py`)
- Rule Retrieval → Vector Index: reads rules (evidence: `api/check_line.py`)
- Rule Retrieval → Gemini Models: embeds query (evidence: `api/check_line.py`)
- Line Evaluator → Gemini Models: requests evaluation (evidence: `api/check_line.py`)
- RBI Documents → Text Extraction: provides source text (evidence: `extract_text.py`)
- Text Extraction → Extracted Text: writes (evidence: `extract_text.py`)
- Extracted Text → Paragraph Chunking: provides text (evidence: `chunk_paragraphs.py`)
- Paragraph Chunking → Rule Chunks: writes chunks (evidence: `chunk_paragraphs.py`)
- Rule Chunks → Embedding Indexer: provides chunks (evidence: `build_index.py`)
- Embedding Indexer → Gemini Models: creates embeddings (evidence: `build_index.py`)
- Embedding Indexer → Vector Index: writes (evidence: `build_index.py`)
