# sanidhyagupta-web/pr-review architecture

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

- Interactive diagram: https://gitdiagram.com/sanidhyagupta-web/pr-review
- Repository: https://github.com/sanidhyagupta-web/pr-review

## Overview

HealthCare is a medical-document ingestion and retrieval application. Users upload records through the UI or bulk API; accepted files are registered, stored, queued, parsed/OCR-processed, transformed through later worker stages, and indexed for retrieval. Search applies privacy and access controls, combines vector and keyword results, reranks them, and generates cited answers. The excerpts establish upload, parsing, embedding, and search behavior; later ingestion stages and some worker wiring are represented only where the source index identifies their modules, so their connections are omitted when not evidenced.

Main entry points: [`ui/search_page.py`](https://github.com/sanidhyagupta-web/pr-review/blob/main/ui/search_page.py) (Medical record search), [`app/main.py`](https://github.com/sanidhyagupta-web/pr-review/blob/main/app/main.py) (Ingestion API), [`workers/parser_worker.py`](https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/parser_worker.py) (Parse and OCR), [`ingestion/registry.py`](https://github.com/sanidhyagupta-web/pr-review/blob/main/ingestion/registry.py) (Document registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Document ingestion"]
  node_upload_ui["Upload UI<br/>[upload_page.py]"]
  node_ingest_api["Ingestion API<br/>[main.py]"]
  node_validation["File validation<br/>[validator.py]"]
end

subgraph group_workers["Processing workers"]
  node_parser_worker["Parse and OCR<br/>[parser_worker.py]"]
  node_parsers["Format parsers"]
  node_ocr["OCR processing"]
  node_markdown_worker["Markdown conversion<br/>[markdown_worker.py]"]
  node_chunk_worker["Chunking<br/>[chunking_worker.py]"]
  node_pii_worker["PII processing<br/>[pii_worker.py]"]
  node_embedding_worker["Embedding and indexing"]
end

subgraph group_search["Search and answers"]
  node_embeddings["Embedding model<br/>[embeddings.py]"]
  node_vector_index[("Vector index<br/>[chroma_store.py]")]
  node_keyword_index[("Keyword index")]
  node_search_ui["Medical record search<br/>[search_page.py]"]
  node_reranker["Result reranking<br/>[reranker.py]"]
  node_answer_model["Answer generation<br/>[claude_client.py]"]
end

subgraph group_security["Privacy and audit"]
  node_privacy["Privacy controls<br/>[guardrails.py]"]
  node_access["Role filtering<br/>[access_control.py]"]
  node_audit["Audit logging<br/>[audit_logger.py]"]
end

subgraph group_platform["State and infrastructure"]
  node_raw_store[("Encrypted file store<br/>[s3_client.py]")]
  node_registry[("Document registry<br/>[registry.py]")]
  node_status_flow["Document lifecycle<br/>[state_machine.py]"]
  node_queues["Work queues<br/>[queue_client.py]"]
end

node_clinician(("User"))

node_clinician -.->|"uploads records"| node_upload_ui
node_upload_ui -.->|"submits files"| node_ingest_api
node_clinician -->|"submits batch"| node_ingest_api
node_ingest_api -->|"validates files"| node_validation
node_ingest_api -->|"stores originals"| node_raw_store
node_ingest_api -->|"registers documents"| node_registry
node_ingest_api -->|"enqueues parsing"| node_queues
node_ingest_api -->|"records events"| node_audit
node_registry -->|"checks transitions"| node_status_flow
node_parser_worker -->|"downloads and stores"| node_raw_store
node_parser_worker -->|"parses documents"| node_parsers
node_parser_worker -->|"runs OCR"| node_ocr
node_parser_worker -->|"updates status"| node_registry
node_parser_worker -->|"enqueues markdown"| node_queues
node_embedding_worker -->|"creates vectors"| node_embeddings
node_embedding_worker -->|"upserts chunks"| node_vector_index
node_embedding_worker -->|"updates status"| node_registry
node_search_ui -->|"checks queries"| node_privacy
node_search_ui -->|"filters results"| node_access
node_search_ui -->|"embeds query"| node_embeddings
node_search_ui -->|"retrieves vectors"| node_vector_index
node_search_ui -->|"retrieves keywords"| node_keyword_index
node_search_ui -.->|"reranks results"| node_reranker
node_search_ui -.->|"generates answer"| node_answer_model
node_search_ui -->|"sanitizes answer"| node_privacy
node_search_ui -->|"logs searches"| node_audit

click node_upload_ui "https://github.com/sanidhyagupta-web/pr-review/blob/main/ui/upload_page.py"
click node_ingest_api "https://github.com/sanidhyagupta-web/pr-review/blob/main/app/main.py"
click node_validation "https://github.com/sanidhyagupta-web/pr-review/blob/main/ingestion/validator.py"
click node_raw_store "https://github.com/sanidhyagupta-web/pr-review/blob/main/storage/s3_client.py"
click node_registry "https://github.com/sanidhyagupta-web/pr-review/blob/main/ingestion/registry.py"
click node_status_flow "https://github.com/sanidhyagupta-web/pr-review/blob/main/ingestion/state_machine.py"
click node_queues "https://github.com/sanidhyagupta-web/pr-review/blob/main/queues/queue_client.py"
click node_parser_worker "https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/parser_worker.py"
click node_parsers "https://github.com/sanidhyagupta-web/pr-review/tree/main/ingestion/parsers"
click node_ocr "https://github.com/sanidhyagupta-web/pr-review/tree/main/ingestion/ocr"
click node_markdown_worker "https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/markdown_worker.py"
click node_chunk_worker "https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/chunking_worker.py"
click node_pii_worker "https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/pii_worker.py"
click node_embedding_worker "https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/embedding_worker.py"
click node_embeddings "https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/embeddings.py"
click node_vector_index "https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/chroma_store.py"
click node_keyword_index "https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/opensearch_index.py"
click node_search_ui "https://github.com/sanidhyagupta-web/pr-review/blob/main/ui/search_page.py"
click node_reranker "https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/reranker.py"
click node_answer_model "https://github.com/sanidhyagupta-web/pr-review/blob/main/llm/claude_client.py"
click node_privacy "https://github.com/sanidhyagupta-web/pr-review/blob/main/security/guardrails.py"
click node_access "https://github.com/sanidhyagupta-web/pr-review/blob/main/security/access_control.py"
click node_audit "https://github.com/sanidhyagupta-web/pr-review/blob/main/security/audit_logger.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_upload_ui,node_ingest_api,node_validation,node_clinician toneBlue
class node_parser_worker,node_parsers,node_ocr,node_markdown_worker,node_chunk_worker,node_pii_worker,node_embedding_worker toneAmber
class node_embeddings,node_vector_index,node_keyword_index,node_search_ui,node_reranker,node_answer_model toneMint
class node_privacy,node_access,node_audit toneRose
class node_raw_store,node_registry,node_status_flow,node_queues toneIndigo
```

## Components

### Document ingestion

- [Upload UI](https://github.com/sanidhyagupta-web/pr-review/blob/main/ui/upload_page.py): `ui/upload_page.py`
- [Ingestion API](https://github.com/sanidhyagupta-web/pr-review/blob/main/app/main.py): `app/main.py`
- [File validation](https://github.com/sanidhyagupta-web/pr-review/blob/main/ingestion/validator.py): `ingestion/validator.py`

### Processing workers

- [Parse and OCR](https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/parser_worker.py): `workers/parser_worker.py`
- [Format parsers](https://github.com/sanidhyagupta-web/pr-review/tree/main/ingestion/parsers): `ingestion/parsers`
- [OCR processing](https://github.com/sanidhyagupta-web/pr-review/tree/main/ingestion/ocr): `ingestion/ocr`
- [Markdown conversion](https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/markdown_worker.py): `workers/markdown_worker.py`
- [Chunking](https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/chunking_worker.py): `workers/chunking_worker.py`
- [PII processing](https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/pii_worker.py): `workers/pii_worker.py`
- [Embedding and indexing](https://github.com/sanidhyagupta-web/pr-review/blob/main/workers/embedding_worker.py): `workers/embedding_worker.py`

### Search and answers

- [Embedding model](https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/embeddings.py): `indexing/embeddings.py`
- [Vector index](https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/chroma_store.py): `indexing/chroma_store.py`
- [Keyword index](https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/opensearch_index.py): `indexing/opensearch_index.py`
- [Medical record search](https://github.com/sanidhyagupta-web/pr-review/blob/main/ui/search_page.py): `ui/search_page.py`
- [Result reranking](https://github.com/sanidhyagupta-web/pr-review/blob/main/indexing/reranker.py): `indexing/reranker.py`
- [Answer generation](https://github.com/sanidhyagupta-web/pr-review/blob/main/llm/claude_client.py): `llm/claude_client.py`

### Privacy and audit

- [Privacy controls](https://github.com/sanidhyagupta-web/pr-review/blob/main/security/guardrails.py): `security/guardrails.py`
- [Role filtering](https://github.com/sanidhyagupta-web/pr-review/blob/main/security/access_control.py): `security/access_control.py`
- [Audit logging](https://github.com/sanidhyagupta-web/pr-review/blob/main/security/audit_logger.py): `security/audit_logger.py`

### State and infrastructure

- [Encrypted file store](https://github.com/sanidhyagupta-web/pr-review/blob/main/storage/s3_client.py): `storage/s3_client.py`
- [Document registry](https://github.com/sanidhyagupta-web/pr-review/blob/main/ingestion/registry.py): `ingestion/registry.py`
- [Document lifecycle](https://github.com/sanidhyagupta-web/pr-review/blob/main/ingestion/state_machine.py): `ingestion/state_machine.py`
- [Work queues](https://github.com/sanidhyagupta-web/pr-review/blob/main/queues/queue_client.py): `queues/queue_client.py`

### Other components

- **User**

## Connections

- User → Upload UI: uploads records
- Upload UI → Ingestion API: submits files
- User → Ingestion API: submits batch (evidence: `app/main.py`)
- Ingestion API → File validation: validates files (evidence: `app/main.py`)
- Ingestion API → Encrypted file store: stores originals (evidence: `app/main.py`)
- Ingestion API → Document registry: registers documents (evidence: `app/main.py`)
- Ingestion API → Work queues: enqueues parsing (evidence: `app/main.py`)
- Ingestion API → Audit logging: records events (evidence: `app/main.py`)
- Document registry → Document lifecycle: checks transitions (evidence: `ingestion/registry.py`)
- Parse and OCR → Encrypted file store: downloads and stores (evidence: `workers/parser_worker.py`)
- Parse and OCR → Format parsers: parses documents (evidence: `workers/parser_worker.py`)
- Parse and OCR → OCR processing: runs OCR (evidence: `workers/parser_worker.py`)
- Parse and OCR → Document registry: updates status (evidence: `workers/parser_worker.py`)
- Parse and OCR → Work queues: enqueues markdown (evidence: `workers/parser_worker.py`)
- Embedding and indexing → Embedding model: creates vectors (evidence: `workers/embedding_worker.py`)
- Embedding and indexing → Vector index: upserts chunks (evidence: `workers/embedding_worker.py`)
- Embedding and indexing → Document registry: updates status (evidence: `workers/embedding_worker.py`)
- Medical record search → Privacy controls: checks queries (evidence: `ui/search_page.py`)
- Medical record search → Role filtering: filters results (evidence: `ui/search_page.py`)
- Medical record search → Embedding model: embeds query (evidence: `ui/search_page.py`)
- Medical record search → Vector index: retrieves vectors (evidence: `ui/search_page.py`)
- Medical record search → Keyword index: retrieves keywords (evidence: `ui/search_page.py`)
- Medical record search → Result reranking: reranks results (evidence: `ui/search_page.py`)
- Medical record search → Answer generation: generates answer (evidence: `ui/search_page.py`)
- Medical record search → Privacy controls: sanitizes answer (evidence: `ui/search_page.py`)
- Medical record search → Audit logging: logs searches (evidence: `ui/search_page.py`)
