# brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system architecture

> Architecture diagram of the GitHub repository brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system
- Repository: https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system

## Overview

#### Purpose and Entry Points
This is a hybrid misinformation-detection application. It accepts free-form text, extracts verifiable claims, classifies them quickly, and conditionally escalates uncertain claims to retrieval-augmented LLM verification. The FastAPI service starts at `app/main.py`; the browser UI is served from `app/static/index.html` and calls the API through `app/static/app.js`.

#### API and Application Boundary
`app/main.py` owns HTTP integration, exposing analysis, knowledge-base mutation, and health endpoints. It converts request payloads into application models from `app/models.py`, invokes the orchestration pipeline, and returns structured reports. Static frontend assets remain a separate presentation layer under `app/static/`.

#### Multi-Agent Orchestration Pipeline
`app/agents/pipeline.py` is the primary control-flow coordinator. It implements the staged agent flow:
1. extract one or more claims from submitted text;
2. classify each claim;
3. route based on classifier confidence;
4. retrieve evidence and verify when escalation is needed;
5. assemble a transparent report with verdicts, confidence, rationale, and evidence.
This pipeline is the principal boundary between API delivery and decision logic.

#### Fast Classification and Confidence Routing
`app/services/classifier.py` provides the fast-path `true`/`false`/`uncertain` prediction and confidence interface. It supports a production model integration point while retaining heuristic fallback behavior. Configuration in `app/config.py` supplies the confidence threshold (default documented as 0.78), which determines whether a result is accepted directly or sent through RAG verification.

#### Evidence Retrieval / Knowledge Base
`app/services/retriever.py` encapsulates semantic retrieval against a FAISS-backed curated evidence store. Claims are embedded and used to fetch top matching evidence snippets for the verifier. `scripts/build_kb.py` is the offline knowledge-base construction entry point; the API’s KB-add route provides a runtime mutation path. The FAISS index and its source corpus form a material local persistence boundary, though generated artifacts are not represented in the supplied tree.

#### LLM Verification Boundary
`app/services/verifier.py` consumes a claim plus retrieved evidence and produces a grounded verdict and rationale. It can use OpenAI when enabled through `OPENAI_API_KEY`, `OPENAI_MODEL`, and `USE_OPENAI`; OpenAI is therefore an optional external inference dependency. Retrieval evidence is passed into this stage to constrain reasoning and support source-backed reporting.

#### Models, Runtime, and Deployment Shape
`app/models.py` defines shared request/report contracts across HTTP, pipeline, and services. The runtime is Python with FastAPI and Uvicorn (`uvicorn app.main:app`), plus FAISS for local vector search and optional transformer/OpenAI model inference. `scripts/train_classifier.py` provides the model-training/export path for replacing the classifier fallback with a fine-tuned transformer checkpoint.

Main entry points: [`app/main.py`](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/main.py) (FastAPI service), [`app/services/retriever.py`](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/retriever.py) (Evidence retriever), [`app/agents/pipeline.py`](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/agents/pipeline.py) (Analysis pipeline), [`app/services/classifier.py`](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/classifier.py) (Fast classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_browser["Browser UI<br/>frontend<br/>[index.html]"]
  node_frontend_js["API client<br/>browser script<br/>[app.js]"]
end

subgraph group_runtime["API Runtime"]
  node_api["FastAPI service<br/>HTTP API<br/>[main.py]"]
  node_contracts["Shared contracts<br/>application models<br/>[models.py]"]
  node_config["Runtime configuration<br/>configuration module<br/>[config.py]"]
end

subgraph group_decision["Decision Pipeline"]
  node_pipeline["Analysis pipeline<br/>orchestrator<br/>[pipeline.py]"]
  node_claim_extraction["Claim extraction<br/>pipeline stage"]
  node_classifier["Fast classifier<br/>classification service<br/>[classifier.py]"]
  node_confidence_router{{"Confidence routing<br/>pipeline stage"}}
  node_verifier["Grounded verifier<br/>verification service<br/>[verifier.py]"]
end

subgraph group_knowledge["Knowledge &amp; Model Lifecycle"]
  node_retriever["Evidence retriever<br/>retrieval service<br/>[retriever.py]"]
  node_faiss_store[("Curated evidence store<br/>FAISS index and corpus")]
  node_kb_builder["KB builder<br/>offline ingestion<br/>[build_kb.py]"]
  node_model_training["Classifier training<br/>offline training"]
  node_classifier_model[("Classifier model<br/>model checkpoint")]
end

node_openai(("OpenAI inference<br/>optional external LLM"))

node_browser -->|"loads"| node_frontend_js
node_frontend_js -->|"API requests"| node_api
node_api -->|"parses and returns"| node_contracts
node_api -->|"submits text"| node_pipeline
node_api -->|"KB-add route"| node_retriever
node_pipeline -->|"extracts claims"| node_claim_extraction
node_claim_extraction -->|"per claim"| node_classifier
node_classifier -->|"label + confidence"| node_confidence_router
node_config -.->|"threshold"| node_confidence_router
node_confidence_router -->|"accept fast verdict"| node_pipeline
node_confidence_router -->|"escalate"| node_retriever
node_retriever -->|"semantic search"| node_faiss_store
node_retriever -->|"evidence snippets"| node_verifier
node_verifier -->|"grounded verdict"| node_pipeline
node_verifier -.->|"optional inference"| node_openai
node_kb_builder -->|"builds"| node_faiss_store
node_model_training -->|"exports"| node_classifier_model
node_classifier -.->|"uses when available"| node_classifier_model

click node_browser "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/static/index.html"
click node_frontend_js "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/static/app.js"
click node_api "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/main.py"
click node_contracts "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/models.py"
click node_pipeline "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/agents/pipeline.py"
click node_classifier "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/classifier.py"
click node_retriever "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/retriever.py"
click node_verifier "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/verifier.py"
click node_config "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/config.py"
click node_kb_builder "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/scripts/build_kb.py"
click node_model_training "https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/scripts/train_classifier.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_browser,node_frontend_js toneBlue
class node_api,node_contracts,node_config toneAmber
class node_pipeline,node_claim_extraction,node_classifier,node_confidence_router,node_verifier toneMint
class node_retriever,node_faiss_store,node_kb_builder,node_model_training,node_classifier_model toneRose
class node_openai toneNeutral
```

## Components

### Presentation

- [Browser UI](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/static/index.html): frontend · `app/static/index.html`
- [API client](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/static/app.js): browser script · `app/static/app.js`

### API Runtime

- [FastAPI service](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/main.py): HTTP API · Serves analysis, KB mutation, and health endpoints. · `app/main.py`
- [Shared contracts](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/models.py): application models · Request and report models shared across layers. · `app/models.py`
- [Runtime configuration](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/config.py): configuration module · Supplies the confidence threshold and integration settings. · `app/config.py`

### Decision Pipeline

- [Analysis pipeline](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/agents/pipeline.py): orchestrator · Coordinates claim-level staged analysis and report assembly. · `app/agents/pipeline.py`
- **Claim extraction**: pipeline stage
- [Fast classifier](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/classifier.py): classification service · Returns true, false, or uncertain with confidence. · `app/services/classifier.py`
- **Confidence routing**: pipeline stage · Accepts confident classifications or escalates uncertain claims.
- [Grounded verifier](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/verifier.py): verification service · Produces a verdict and rationale from claim evidence. · `app/services/verifier.py`

### Knowledge & Model Lifecycle

- [Evidence retriever](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/app/services/retriever.py): retrieval service · Embeds claims and fetches relevant evidence. · `app/services/retriever.py`
- **Curated evidence store**: FAISS index and corpus · Local persistence for searchable evidence.
- [KB builder](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/scripts/build_kb.py): offline ingestion · Builds the local evidence index from source corpus. · `scripts/build_kb.py`
- [Classifier training](https://github.com/brownie799/hybrid-retrieval-augmented-multi-agent-misinformation-detection-system/blob/main/scripts/train_classifier.py): offline training · Exports a fine-tuned classifier checkpoint. · `scripts/train_classifier.py`
- **Classifier model**: model checkpoint · Production model integration point with heuristic fallback.

### Other components

- **OpenAI inference**: optional external LLM · Enabled by runtime environment settings.

## Connections

- Browser UI → API client: loads
- API client → FastAPI service: API requests
- FastAPI service → Shared contracts: parses and returns
- FastAPI service → Analysis pipeline: submits text
- FastAPI service → Evidence retriever: KB-add route
- Analysis pipeline → Claim extraction: extracts claims
- Claim extraction → Fast classifier: per claim
- Fast classifier → Confidence routing: label + confidence
- Runtime configuration → Confidence routing: threshold
- Confidence routing → Analysis pipeline: accept fast verdict
- Confidence routing → Evidence retriever: escalate
- Evidence retriever → Curated evidence store: semantic search
- Evidence retriever → Grounded verifier: evidence snippets
- Grounded verifier → Analysis pipeline: grounded verdict
- Grounded verifier → OpenAI inference: optional inference
- KB builder → Curated evidence store: builds
- Classifier training → Classifier model: exports
- Fast classifier → Classifier model: uses when available
