# abhay056/halaudit-real-time-llm-fact-checker architecture

> Architecture diagram of the GitHub repository abhay056/halaudit-real-time-llm-fact-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhay056/halaudit-real-time-llm-fact-checker
- Repository: https://github.com/abhay056/halaudit-real-time-llm-fact-checker

## Overview

HalAudit accepts text or a prompt, decomposes responses into claims, retrieves corpus evidence, and labels claims with NLI to produce a cited trust report. The API also supports corpus ingestion, audit history and statistics; a dashboard presents audit, history and analytics views. Async jobs use Redis and an ARQ worker, while SQLite persists reports. The pipeline and core-stage links are visible in excerpts; several endpoint and dashboard interactions are documented but not fully shown in source excerpts.

Main entry points: [`app/api/v1/router.py`](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/api/v1/router.py) (REST endpoints), [`app/core/pipeline.py`](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/pipeline.py) (Audit orchestrator), [`app/core/rag_retriever.py`](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/rag_retriever.py) (Evidence retrieval), [`app/main.py`](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and presentation"]
  node_app["FastAPI app<br/>[main.py]"]
  node_routes["REST endpoints<br/>[router.py]"]
  node_middleware["Rate limiting<br/>[middleware.py]"]
  node_dashboard["Web dashboard"]
end

subgraph group_audit["Audit pipeline"]
  node_pipeline["Audit orchestrator<br/>[pipeline.py]"]
  node_extract["Claim extraction<br/>[claim_extractor.py]"]
  node_nli["NLI scoring<br/>[nli_scorer.py]"]
  node_report["Audit report model<br/>[schemas.py]"]
end

subgraph group_corpus["Evidence corpus"]
  node_retriever["Evidence retrieval<br/>[rag_retriever.py]"]
  node_vector[("ChromaDB corpus<br/>[rag_retriever.py]")]
  node_seed["Seed documents<br/>[seed_data.py]"]
  node_loader["Corpus loader<br/>[loader.py]"]
end

subgraph group_async["Async processing"]
  node_redis[("Redis client<br/>[redis_client.py]")]
  node_worker["ARQ worker<br/>[worker.py]"]
  node_tasks["Audit jobs<br/>[tasks.py]"]
end

subgraph group_persistence["Audit persistence"]
  node_sqlite[("Audit log store<br/>[audit_store.py]")]
end

node_user(("LLM user"))

node_user -->|"submits audit"| node_routes
node_app -->|"mounts routes"| node_routes
node_app -->|"installs middleware"| node_middleware
node_app -->|"serves dashboard"| node_dashboard
node_routes -->|"runs audit"| node_pipeline
node_pipeline -->|"extracts claims"| node_extract
node_pipeline -->|"retrieves evidence"| node_retriever
node_pipeline -->|"scores claims"| node_nli
node_pipeline -->|"builds report"| node_report
node_retriever -->|"queries corpus"| node_vector
node_retriever -->|"ingests documents"| node_vector
node_app -->|"loads corpus"| node_loader
node_loader -->|"reads seed data"| node_seed
node_loader -->|"ingests seed"| node_retriever
node_routes -->|"ingests documents"| node_retriever
node_routes -->|"reads audit data"| node_sqlite
node_routes -->|"checks job results"| node_redis
node_middleware -->|"checks rate limits"| node_redis
node_routes -.->|"enqueues jobs"| node_worker
node_worker -->|"registers jobs"| node_tasks
node_tasks -->|"runs audit"| node_pipeline
node_tasks -->|"saves report"| node_sqlite
node_tasks -->|"stores result"| node_redis
node_routes -.->|"returns report"| node_report

click node_app "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/main.py"
click node_routes "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/api/v1/router.py"
click node_middleware "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/api/middleware.py"
click node_dashboard "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/tree/main/dashboard"
click node_pipeline "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/pipeline.py"
click node_extract "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/claim_extractor.py"
click node_retriever "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/rag_retriever.py"
click node_vector "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/rag_retriever.py"
click node_nli "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/nli_scorer.py"
click node_report "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/models/schemas.py"
click node_seed "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/corpus/seed_data.py"
click node_loader "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/corpus/loader.py"
click node_sqlite "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/db/audit_store.py"
click node_redis "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/db/redis_client.py"
click node_worker "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/queue/worker.py"
click node_tasks "https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/queue/tasks.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_routes,node_middleware,node_dashboard,node_user toneBlue
class node_pipeline,node_extract,node_nli,node_report toneAmber
class node_retriever,node_vector,node_seed,node_loader toneMint
class node_redis,node_worker,node_tasks toneRose
class node_sqlite toneIndigo
```

## Components

### API and presentation

- [FastAPI app](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/main.py): `app/main.py`
- [REST endpoints](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/api/v1/router.py): `app/api/v1/router.py`
- [Rate limiting](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/api/middleware.py): `app/api/middleware.py`
- [Web dashboard](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/tree/main/dashboard): `dashboard`

### Audit pipeline

- [Audit orchestrator](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/pipeline.py): `app/core/pipeline.py`
- [Claim extraction](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/claim_extractor.py): `app/core/claim_extractor.py`
- [NLI scoring](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/nli_scorer.py): `app/core/nli_scorer.py`
- [Audit report model](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/models/schemas.py): `app/models/schemas.py`

### Evidence corpus

- [Evidence retrieval](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/rag_retriever.py): `app/core/rag_retriever.py`
- [ChromaDB corpus](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/core/rag_retriever.py): `app/core/rag_retriever.py`
- [Seed documents](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/corpus/seed_data.py): `app/corpus/seed_data.py`
- [Corpus loader](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/corpus/loader.py): `app/corpus/loader.py`

### Async processing

- [Redis client](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/db/redis_client.py): `app/db/redis_client.py`
- [ARQ worker](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/queue/worker.py): `app/queue/worker.py`
- [Audit jobs](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/queue/tasks.py): `app/queue/tasks.py`

### Audit persistence

- [Audit log store](https://github.com/abhay056/halaudit-real-time-llm-fact-checker/blob/main/app/db/audit_store.py): `app/db/audit_store.py`

### Other components

- **LLM user**

## Connections

- LLM user → REST endpoints: submits audit (evidence: `README.md`)
- FastAPI app → REST endpoints: mounts routes (evidence: `app/main.py`)
- FastAPI app → Rate limiting: installs middleware (evidence: `app/main.py`)
- FastAPI app → Web dashboard: serves dashboard (evidence: `app/main.py`)
- REST endpoints → Audit orchestrator: runs audit (evidence: `app/api/v1/router.py`)
- Audit orchestrator → Claim extraction: extracts claims (evidence: `app/core/pipeline.py`)
- Audit orchestrator → Evidence retrieval: retrieves evidence (evidence: `app/core/pipeline.py`)
- Audit orchestrator → NLI scoring: scores claims (evidence: `app/core/pipeline.py`)
- Audit orchestrator → Audit report model: builds report (evidence: `app/core/pipeline.py`)
- Evidence retrieval → ChromaDB corpus: queries corpus (evidence: `app/core/rag_retriever.py`)
- Evidence retrieval → ChromaDB corpus: ingests documents (evidence: `app/core/rag_retriever.py`)
- FastAPI app → Corpus loader: loads corpus (evidence: `app/main.py`)
- Corpus loader → Seed documents: reads seed data (evidence: `app/corpus/loader.py`)
- Corpus loader → Evidence retrieval: ingests seed (evidence: `app/corpus/loader.py`)
- REST endpoints → Evidence retrieval: ingests documents (evidence: `app/api/v1/router.py`)
- REST endpoints → Audit log store: reads audit data (evidence: `app/api/v1/router.py`)
- REST endpoints → Redis client: checks job results (evidence: `app/api/v1/router.py`)
- Rate limiting → Redis client: checks rate limits (evidence: `app/api/middleware.py`)
- REST endpoints → ARQ worker: enqueues jobs
- ARQ worker → Audit jobs: registers jobs (evidence: `app/queue/worker.py`)
- Audit jobs → Audit orchestrator: runs audit (evidence: `app/queue/tasks.py`)
- Audit jobs → Audit log store: saves report (evidence: `app/queue/tasks.py`)
- Audit jobs → Redis client: stores result (evidence: `app/queue/tasks.py`)
- REST endpoints → Audit report model: returns report (evidence: `README.md`)
