# norsaje/hr_docs architecture

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

- Interactive diagram: https://gitdiagram.com/norsaje/hr_docs
- Repository: https://github.com/norsaje/hr_docs

## Overview

This service takes applicant document uploads through validation and queued OCR/model extraction, then presents extracted fields and review actions to authenticated operators. The README also describes status polling, later uploads, history, work-queue monitoring, expiring documents, staff administration, email notifications, and private file access. The graph follows explicit calls and documented behavior; several public API and worker details are unsampled, so those links are omitted where caller evidence is unavailable.

Main entry points: [`backend/app/pipeline/run.py`](https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/run.py) (Document pipeline), [`backend/app/pipeline/verify.py`](https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/verify.py) (Field verification), [`web/operator/src/App.tsx`](https://github.com/norsaje/hr_docs/blob/main/web/operator/src/App.tsx) (Operator workspace), [`backend/app/api/operator_extra.py`](https://github.com/norsaje/hr_docs/blob/main/backend/app/api/operator_extra.py) (Extra operator actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Applicant intake"]
  node_applicant_ui["Upload experience<br/>[App.tsx]"]
  node_applicant_api["Applicant API client<br/>[api.ts]"]
  node_public_api["Public endpoints<br/>[public.py]"]
  node_intake_service["Intake service<br/>[service.py]"]
end

subgraph group_review["Operator review"]
  node_operator_ui["Operator workspace<br/>[App.tsx]"]
  node_operator_pages["Review pages"]
  node_operator_api["Operator API client<br/>[api.ts]"]
  node_operator_routes["Operator endpoints<br/>[operator.py]"]
  node_operator_extra["Extra operator actions<br/>[operator_extra.py]"]
  node_oidc["Login and session<br/>[oidc.py]"]
end

subgraph group_processing["Document processing"]
  node_worker["Job worker<br/>[worker.py]"]
  node_pipeline["Document pipeline<br/>[run.py]"]
  node_verification["Field verification<br/>[verify.py]"]
  node_registry["Document registry<br/>[loader.py]"]
  node_rules["Validation rules<br/>[rules.py]"]
  node_checksums["Checksum checks<br/>[checksums.py]"]
  node_mrz["MRZ parsing<br/>[mrz.py]"]
  node_llm["Model gateway<br/>[gateway.py]"]
  node_schema["Extraction schema<br/>[schema_builder.py]"]
  node_ocr["OCR vote<br/>[ocr_vote.py]"]
  node_quality["Image quality<br/>[quality.py]"]
  node_confidence["Field confidence<br/>[confidence.py]"]
end

subgraph group_platform["Persistence and identity"]
  node_audit["Audit trail<br/>[log.py]"]
  node_db[("PostgreSQL")]
  node_storage[("S3 file storage<br/>[s3.py]")]
  node_email["Email notifications<br/>[email.py]"]
  node_messages["User messages<br/>[messages.py]"]
end

node_applicant(("Applicant"))
node_operator(("Operator"))
node_keycloak{{"Keycloak"}}
node_mail{{"Mail service"}}

node_applicant -->|"submits documents"| node_applicant_ui
node_applicant_ui -->|"calls API"| node_applicant_api
node_applicant_api -.->|"sends requests"| node_public_api
node_public_api -.->|"handles intake"| node_intake_service
node_intake_service -->|"stores files"| node_storage
node_intake_service -->|"reads rules"| node_registry
node_operator -->|"reviews cases"| node_operator_ui
node_operator_ui -->|"renders pages"| node_operator_pages
node_operator_ui -->|"checks session"| node_operator_api
node_operator_pages -->|"requests case data"| node_operator_api
node_operator_api -.->|"calls endpoints"| node_operator_routes
node_operator_api -.->|"calls actions"| node_operator_extra
node_operator_routes -->|"records actions"| node_audit
node_operator_extra -->|"records actions"| node_audit
node_operator_extra -->|"sends notices"| node_email
node_operator_extra -->|"reruns parsing"| node_pipeline
node_operator_ui -.->|"checks identity"| node_oidc
node_oidc -->|"authenticates with"| node_keycloak
node_worker -->|"processes files"| node_pipeline
node_pipeline -->|"reads and writes"| node_storage
node_pipeline -->|"extracts fields"| node_llm
node_pipeline -->|"gets OCR text"| node_ocr
node_pipeline -->|"checks image"| node_quality
node_pipeline -->|"verifies extraction"| node_verification
node_pipeline -->|"loads document rules"| node_registry
node_pipeline -->|"colors fields"| node_confidence
node_verification -->|"uses field schema"| node_schema
node_verification -->|"applies checks"| node_rules
node_verification -->|"checks identifiers"| node_checksums
node_verification -->|"checks MRZ"| node_mrz
node_rules -->|"calls checks"| node_checksums
node_llm -->|"builds schema"| node_schema
node_llm -->|"uses registry"| node_registry
node_llm -.->|"calls model service"| node_keycloak
node_worker -->|"leases jobs"| node_db
node_pipeline -->|"writes results"| node_db
node_email -.->|"sends email"| node_mail
node_operator_routes -->|"formats errors"| node_messages

click node_applicant_ui "https://github.com/norsaje/hr_docs/blob/main/web/applicant/src/App.tsx"
click node_applicant_api "https://github.com/norsaje/hr_docs/blob/main/web/applicant/src/api.ts"
click node_public_api "https://github.com/norsaje/hr_docs/blob/main/backend/app/api/public.py"
click node_intake_service "https://github.com/norsaje/hr_docs/blob/main/backend/app/intake/service.py"
click node_operator_ui "https://github.com/norsaje/hr_docs/blob/main/web/operator/src/App.tsx"
click node_operator_pages "https://github.com/norsaje/hr_docs/tree/main/web/operator/src/pages"
click node_operator_api "https://github.com/norsaje/hr_docs/blob/main/web/operator/src/api.ts"
click node_operator_routes "https://github.com/norsaje/hr_docs/blob/main/backend/app/api/operator.py"
click node_operator_extra "https://github.com/norsaje/hr_docs/blob/main/backend/app/api/operator_extra.py"
click node_oidc "https://github.com/norsaje/hr_docs/blob/main/backend/app/auth/oidc.py"
click node_audit "https://github.com/norsaje/hr_docs/blob/main/backend/app/audit/log.py"
click node_worker "https://github.com/norsaje/hr_docs/blob/main/backend/app/queue/worker.py"
click node_pipeline "https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/run.py"
click node_verification "https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/verify.py"
click node_registry "https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/loader.py"
click node_rules "https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/rules.py"
click node_checksums "https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/checksums.py"
click node_mrz "https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/mrz.py"
click node_llm "https://github.com/norsaje/hr_docs/blob/main/backend/app/llm/gateway.py"
click node_schema "https://github.com/norsaje/hr_docs/blob/main/backend/app/llm/schema_builder.py"
click node_ocr "https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/ocr_vote.py"
click node_quality "https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/quality.py"
click node_confidence "https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/confidence.py"
click node_storage "https://github.com/norsaje/hr_docs/blob/main/backend/app/storage/s3.py"
click node_email "https://github.com/norsaje/hr_docs/blob/main/backend/app/notify/email.py"
click node_messages "https://github.com/norsaje/hr_docs/blob/main/backend/app/messages.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_applicant_ui,node_applicant_api,node_public_api,node_intake_service toneBlue
class node_operator_ui,node_operator_pages,node_operator_api,node_operator_routes,node_operator_extra,node_oidc toneAmber
class node_worker,node_pipeline,node_verification,node_registry,node_rules,node_checksums,node_mrz,node_llm,node_schema,node_ocr,node_quality,node_confidence toneMint
class node_audit,node_db,node_storage,node_email,node_messages toneRose
class node_applicant,node_operator,node_keycloak,node_mail toneIndigo
```

## Components

### Applicant intake

- [Upload experience](https://github.com/norsaje/hr_docs/blob/main/web/applicant/src/App.tsx): `web/applicant/src/App.tsx`
- [Applicant API client](https://github.com/norsaje/hr_docs/blob/main/web/applicant/src/api.ts): `web/applicant/src/api.ts`
- [Public endpoints](https://github.com/norsaje/hr_docs/blob/main/backend/app/api/public.py): `backend/app/api/public.py`
- [Intake service](https://github.com/norsaje/hr_docs/blob/main/backend/app/intake/service.py): `backend/app/intake/service.py`

### Operator review

- [Operator workspace](https://github.com/norsaje/hr_docs/blob/main/web/operator/src/App.tsx): `web/operator/src/App.tsx`
- [Review pages](https://github.com/norsaje/hr_docs/tree/main/web/operator/src/pages): `web/operator/src/pages`
- [Operator API client](https://github.com/norsaje/hr_docs/blob/main/web/operator/src/api.ts): `web/operator/src/api.ts`
- [Operator endpoints](https://github.com/norsaje/hr_docs/blob/main/backend/app/api/operator.py): `backend/app/api/operator.py`
- [Extra operator actions](https://github.com/norsaje/hr_docs/blob/main/backend/app/api/operator_extra.py): `backend/app/api/operator_extra.py`
- [Login and session](https://github.com/norsaje/hr_docs/blob/main/backend/app/auth/oidc.py): `backend/app/auth/oidc.py`

### Document processing

- [Job worker](https://github.com/norsaje/hr_docs/blob/main/backend/app/queue/worker.py): `backend/app/queue/worker.py`
- [Document pipeline](https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/run.py): `backend/app/pipeline/run.py`
- [Field verification](https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/verify.py): `backend/app/pipeline/verify.py`
- [Document registry](https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/loader.py): `backend/app/registry/loader.py`
- [Validation rules](https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/rules.py): `backend/app/registry/rules.py`
- [Checksum checks](https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/checksums.py): `backend/app/registry/checksums.py`
- [MRZ parsing](https://github.com/norsaje/hr_docs/blob/main/backend/app/registry/mrz.py): `backend/app/registry/mrz.py`
- [Model gateway](https://github.com/norsaje/hr_docs/blob/main/backend/app/llm/gateway.py): `backend/app/llm/gateway.py`
- [Extraction schema](https://github.com/norsaje/hr_docs/blob/main/backend/app/llm/schema_builder.py): `backend/app/llm/schema_builder.py`
- [OCR vote](https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/ocr_vote.py): `backend/app/pipeline/ocr_vote.py`
- [Image quality](https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/quality.py): `backend/app/pipeline/quality.py`
- [Field confidence](https://github.com/norsaje/hr_docs/blob/main/backend/app/pipeline/confidence.py): `backend/app/pipeline/confidence.py`

### Persistence and identity

- [Audit trail](https://github.com/norsaje/hr_docs/blob/main/backend/app/audit/log.py): `backend/app/audit/log.py`
- **PostgreSQL**
- [S3 file storage](https://github.com/norsaje/hr_docs/blob/main/backend/app/storage/s3.py): `backend/app/storage/s3.py`
- [Email notifications](https://github.com/norsaje/hr_docs/blob/main/backend/app/notify/email.py): `backend/app/notify/email.py`
- [User messages](https://github.com/norsaje/hr_docs/blob/main/backend/app/messages.py): `backend/app/messages.py`

### Other components

- **Applicant**
- **Operator**
- **Keycloak**
- **Mail service**

## Connections

- Applicant → Upload experience: submits documents
- Upload experience → Applicant API client: calls API (evidence: `web/applicant/src/App.tsx`)
- Applicant API client → Public endpoints: sends requests
- Public endpoints → Intake service: handles intake
- Intake service → S3 file storage: stores files (evidence: `backend/app/intake/service.py`)
- Intake service → Document registry: reads rules (evidence: `backend/app/intake/service.py`)
- Operator → Operator workspace: reviews cases
- Operator workspace → Review pages: renders pages (evidence: `web/operator/src/App.tsx`)
- Operator workspace → Operator API client: checks session (evidence: `web/operator/src/App.tsx`)
- Review pages → Operator API client: requests case data (evidence: `web/operator/src/pages/Card.tsx`)
- Operator API client → Operator endpoints: calls endpoints
- Operator API client → Extra operator actions: calls actions
- Operator endpoints → Audit trail: records actions (evidence: `backend/app/api/operator.py`)
- Extra operator actions → Audit trail: records actions (evidence: `backend/app/api/operator_extra.py`)
- Extra operator actions → Email notifications: sends notices (evidence: `backend/app/api/operator_extra.py`)
- Extra operator actions → Document pipeline: reruns parsing (evidence: `backend/app/api/operator_extra.py`)
- Operator workspace → Login and session: checks identity
- Login and session → Keycloak: authenticates with
- Job worker → Document pipeline: processes files (evidence: `backend/app/queue/worker.py`)
- Document pipeline → S3 file storage: reads and writes (evidence: `backend/app/pipeline/run.py`)
- Document pipeline → Model gateway: extracts fields (evidence: `backend/app/pipeline/run.py`)
- Document pipeline → OCR vote: gets OCR text (evidence: `backend/app/pipeline/run.py`)
- Document pipeline → Image quality: checks image (evidence: `backend/app/pipeline/run.py`)
- Document pipeline → Field verification: verifies extraction (evidence: `backend/app/pipeline/run.py`)
- Document pipeline → Document registry: loads document rules (evidence: `backend/app/pipeline/run.py`)
- Document pipeline → Field confidence: colors fields (evidence: `backend/app/pipeline/run.py`)
- Field verification → Extraction schema: uses field schema (evidence: `backend/app/pipeline/verify.py`)
- Field verification → Validation rules: applies checks (evidence: `backend/app/pipeline/verify.py`)
- Field verification → Checksum checks: checks identifiers (evidence: `backend/app/pipeline/verify.py`)
- Field verification → MRZ parsing: checks MRZ (evidence: `backend/app/pipeline/verify.py`)
- Validation rules → Checksum checks: calls checks (evidence: `backend/app/registry/rules.py`)
- Model gateway → Extraction schema: builds schema (evidence: `backend/app/llm/gateway.py`)
- Model gateway → Document registry: uses registry (evidence: `backend/app/llm/gateway.py`)
- Model gateway → Keycloak: calls model service
- Job worker → PostgreSQL: leases jobs (evidence: `backend/app/queue/worker.py`)
- Document pipeline → PostgreSQL: writes results (evidence: `backend/app/pipeline/run.py`)
- Email notifications → Mail service: sends email
- Operator endpoints → User messages: formats errors (evidence: `backend/app/api/operator.py`)
