# jeevabharathis/fact-checking-chatbot architecture

> Architecture diagram of the GitHub repository jeevabharathis/fact-checking-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeevabharathis/fact-checking-chatbot
- Repository: https://github.com/jeevabharathis/fact-checking-chatbot

## Overview

##### Project Type and Purpose
- Full-stack fact-checking chatbot
- Provides verified answers on the 2025 India-Pakistan conflict
- Uses a RAG pipeline: retrieval from a curated YAML dataset → generation via an LLM (Ollama/Mistral)

##### File Structure
- frontend/app.py → Streamlit UI for user queries
- backend/main.py → FastAPI service exposing /ask, /health, /reload-data endpoints
- backend/rag_pipeline.py → retrieval (ChromaDB) + generation (Ollama) logic
- backend/data/war_data.yaml → source of truth facts
- cms/cms.py → Streamlit CMS for managing facts
- requirements.txt → Python dependencies

##### Key Architectural Components
a. User & Streamlit Frontend
– Browser or desktop client running Streamlit app (frontend/app.py)
b. CMS Interface (optional)
– Browser → Streamlit CMS (cms/cms.py) → POSTs updates to backend
c. Backend API
– FastAPI (backend/main.py)
– RAG Pipeline (backend/rag_pipeline.py)
– Endpoints: /ask (query), /reload-data (refresh dataset)
d. Data Stores
– war_data.yaml (flat file)
– ChromaDB vector store (built at runtime from YAML)
e. External LLM Service
– Ollama server (Mistral model) with GPU acceleration

##### Patterns & Principles
- Separation of concerns – UI vs. business logic vs. data
- RAG architecture – retrieval component (ChromaDB) + generative model (Ollama)
- External service integration – Ollama as a microservice
- Streamlit apps (frontend & CMS) run separately but share the same backend

## Diagram (Mermaid)

```mermaid
flowchart LR
    subgraph "User & UI"
        direction TB
        U["User Browser"]:::frontend
        FE["Streamlit Frontend"]:::frontend
        CMS["Streamlit CMS"]:::frontend
    end

    subgraph "Backend & Services"
        direction TB
        API["FastAPI Backend"]:::backend
        Pipeline["RAG Pipeline"]:::pipeline
    end

    subgraph "Data Stores"
        direction TB
        YAML["war_data.yaml"]:::datastore
        Chroma[(ChromaDB)]:::datastore
    end

    Ollama((Ollama Server)):::external

    U -->|"HTTP"| FE
    FE -->|"POST /ask"| API
    API -->|"invoke RAG"| Pipeline
    Pipeline -->|"vector retrieval"| Chroma
    Pipeline -->|"LLM inference"| Ollama
    Pipeline -->|"respond with answer"| API
    API -->|"HTTP response"| FE

    CMS -->|"POST /reload-data"| API
    API -->|"reload_data()"| Pipeline
    Pipeline -->|"load facts"| YAML
    Pipeline -->|"rebuild vector store"| Chroma

    click FE "https://github.com/jeevabharathis/fact-checking-chatbot/blob/master/frontend/app.py"
    click CMS "https://github.com/jeevabharathis/fact-checking-chatbot/blob/master/cms/cms.py"
    click API "https://github.com/jeevabharathis/fact-checking-chatbot/blob/master/backend/main.py"
    click Pipeline "https://github.com/jeevabharathis/fact-checking-chatbot/blob/master/backend/rag_pipeline.py"
    click YAML "https://github.com/jeevabharathis/fact-checking-chatbot/blob/master/backend/data/war_data.yaml"
    click U "https://github.com/jeevabharathis/fact-checking-chatbot/blob/master/requirements.txt"

    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px
    classDef pipeline fill:#98fb98,stroke:#000,stroke-width:1px
    classDef datastore fill:#ffa500,stroke:#000,stroke-width:1px
    classDef external fill:#dda0dd,stroke:#000,stroke-width:1px
```
