# jogirohithkumar/factforge architecture

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

- Interactive diagram: https://gitdiagram.com/jogirohithkumar/factforge
- Repository: https://github.com/jogirohithkumar/factforge

## Overview

FactForge is a full-stack news-verification application. Users submit text or a URL through the Next.js interface; the API validates input, optionally extracts article text, runs model inference, persists a verdict, and returns it for display. The history endpoint supplies persisted results to the case-log sidebar. The README also documents an offline data-preparation and model-training workflow. Relationships involving unsampled frontend components are shown only where documented; the implementation of those component interactions was not excerpted.

Main entry points: [`backend/app/api/routes/predict.py`](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/api/routes/predict.py) (Prediction endpoints), [`backend/app/main.py`](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/main.py) (FastAPI application), [`frontend/app/page.tsx`](https://github.com/jogirohithkumar/factforge/blob/main/frontend/app/page.tsx) (FactForge interface), [`frontend/lib/api.ts`](https://github.com/jogirohithkumar/factforge/blob/main/frontend/lib/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_frontend["FactForge interface<br/>[page.tsx]"]
  node_analyzer["Analyzer form<br/>[AnalyzerCard.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_result["Verdict panel<br/>[ResultPanel.tsx]"]
  node_dial["Verdict dial<br/>[VerdictDial.tsx]"]
  node_history_ui["History sidebar<br/>[HistorySidebar.tsx]"]
end

subgraph group_api["API and validation"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_settings["Application settings<br/>[config.py]"]
  node_schemas["Request and response schemas<br/>[prediction.py]"]
  node_predict_route["Prediction endpoints<br/>[predict.py]"]
  node_history_route["History endpoint<br/>[history.py]"]
end

subgraph group_analysis["Analysis services"]
  node_scraper["URL extraction<br/>[scraper.py]"]
  node_inference["Model inference<br/>[ml_service.py]"]
  node_model_artifacts["Model artifacts"]
end

subgraph group_storage["Persistence"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_verification[("Verification records<br/>[models.py]")]
end

subgraph group_training["Model training"]
  node_data_prep["Data preparation"]
  node_demo_data["Demo data generation"]
  node_training_pipeline["Model training<br/>[model_training.py]"]
  node_demo_training["Demo model training"]
end

node_user(("User"))

node_user -->|"submits check"| node_frontend
node_frontend -.->|"offers analysis"| node_analyzer
node_analyzer -.->|"requests analysis"| node_api_client
node_api_client -->|"POSTs text or URL"| node_predict_route
node_api_client -->|"fetches history"| node_history_route
node_api_app -->|"registers routes"| node_predict_route
node_api_app -->|"registers routes"| node_history_route
node_api_app -->|"initializes database"| node_db_session
node_api_app -->|"reports model status"| node_inference
node_api_app -->|"loads settings"| node_settings
node_predict_route -->|"validates requests"| node_schemas
node_predict_route -->|"extracts URL text"| node_scraper
node_predict_route -->|"runs prediction"| node_inference
node_predict_route -->|"persists verdict"| node_verification
node_history_route -->|"reads recent records"| node_verification
node_db_session -->|"creates tables"| node_verification
node_inference -->|"loads artifacts"| node_model_artifacts
node_result -->|"renders dial"| node_dial
node_frontend -.->|"displays verdict"| node_result
node_frontend -.->|"shows case log"| node_history_ui
node_history_ui -.->|"requests history"| node_api_client
node_demo_data -->|"provides synthetic data"| node_demo_training
node_data_prep -->|"prepares dataset"| node_training_pipeline
node_training_pipeline -->|"saves trained model"| node_model_artifacts
node_demo_training -->|"saves demo model"| node_model_artifacts

click node_frontend "https://github.com/jogirohithkumar/factforge/blob/main/frontend/app/page.tsx"
click node_analyzer "https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/AnalyzerCard.tsx"
click node_api_client "https://github.com/jogirohithkumar/factforge/blob/main/frontend/lib/api.ts"
click node_result "https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/ResultPanel.tsx"
click node_dial "https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/VerdictDial.tsx"
click node_history_ui "https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/HistorySidebar.tsx"
click node_api_app "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/main.py"
click node_settings "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/core/config.py"
click node_schemas "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/schemas/prediction.py"
click node_predict_route "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/api/routes/predict.py"
click node_history_route "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/api/routes/history.py"
click node_scraper "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/services/scraper.py"
click node_inference "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/services/ml_service.py"
click node_model_artifacts "https://github.com/jogirohithkumar/factforge/tree/main/backend/app/model"
click node_db_session "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/db/database.py"
click node_verification "https://github.com/jogirohithkumar/factforge/blob/main/backend/app/db/models.py"
click node_data_prep "https://github.com/jogirohithkumar/factforge/blob/main/ml/data_preparation.py"
click node_demo_data "https://github.com/jogirohithkumar/factforge/blob/main/ml/generate_demo_data.py"
click node_training_pipeline "https://github.com/jogirohithkumar/factforge/blob/main/ml/model_training.py"
click node_demo_training "https://github.com/jogirohithkumar/factforge/blob/main/ml/train_demo_model.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_frontend,node_analyzer,node_api_client,node_result,node_dial,node_history_ui,node_user toneBlue
class node_api_app,node_settings,node_schemas,node_predict_route,node_history_route toneAmber
class node_scraper,node_inference,node_model_artifacts toneMint
class node_db_session,node_verification toneRose
class node_data_prep,node_demo_data,node_training_pipeline,node_demo_training toneIndigo
```

## Components

### Web experience

- [FactForge interface](https://github.com/jogirohithkumar/factforge/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Analyzer form](https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/AnalyzerCard.tsx): `frontend/components/AnalyzerCard.tsx`
- [API client](https://github.com/jogirohithkumar/factforge/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`
- [Verdict panel](https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/ResultPanel.tsx): `frontend/components/ResultPanel.tsx`
- [Verdict dial](https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/VerdictDial.tsx): `frontend/components/VerdictDial.tsx`
- [History sidebar](https://github.com/jogirohithkumar/factforge/blob/main/frontend/components/HistorySidebar.tsx): `frontend/components/HistorySidebar.tsx`

### API and validation

- [FastAPI application](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/main.py): `backend/app/main.py`
- [Application settings](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Request and response schemas](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/schemas/prediction.py): `backend/app/schemas/prediction.py`
- [Prediction endpoints](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/api/routes/predict.py): `backend/app/api/routes/predict.py`
- [History endpoint](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/api/routes/history.py): `backend/app/api/routes/history.py`

### Analysis services

- [URL extraction](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/services/scraper.py): `backend/app/services/scraper.py`
- [Model inference](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/services/ml_service.py): `backend/app/services/ml_service.py`
- [Model artifacts](https://github.com/jogirohithkumar/factforge/tree/main/backend/app/model): `backend/app/model`

### Persistence

- [Database sessions](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/db/database.py): `backend/app/db/database.py`
- [Verification records](https://github.com/jogirohithkumar/factforge/blob/main/backend/app/db/models.py): `backend/app/db/models.py`

### Model training

- [Data preparation](https://github.com/jogirohithkumar/factforge/blob/main/ml/data_preparation.py): `ml/data_preparation.py`
- [Demo data generation](https://github.com/jogirohithkumar/factforge/blob/main/ml/generate_demo_data.py): `ml/generate_demo_data.py`
- [Model training](https://github.com/jogirohithkumar/factforge/blob/main/ml/model_training.py): `ml/model_training.py`
- [Demo model training](https://github.com/jogirohithkumar/factforge/blob/main/ml/train_demo_model.py): `ml/train_demo_model.py`

### Other components

- **User**

## Connections

- User → FactForge interface: submits check (evidence: `README.md`)
- FactForge interface → Analyzer form: offers analysis
- Analyzer form → API client: requests analysis
- API client → Prediction endpoints: POSTs text or URL (evidence: `frontend/lib/api.ts`)
- API client → History endpoint: fetches history (evidence: `frontend/lib/api.ts`)
- FastAPI application → Prediction endpoints: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → History endpoint: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Database sessions: initializes database (evidence: `backend/app/main.py`)
- FastAPI application → Model inference: reports model status (evidence: `backend/app/main.py`)
- FastAPI application → Application settings: loads settings (evidence: `backend/app/main.py`)
- Prediction endpoints → Request and response schemas: validates requests (evidence: `backend/app/api/routes/predict.py`)
- Prediction endpoints → URL extraction: extracts URL text (evidence: `backend/app/api/routes/predict.py`)
- Prediction endpoints → Model inference: runs prediction (evidence: `backend/app/api/routes/predict.py`)
- Prediction endpoints → Verification records: persists verdict (evidence: `backend/app/api/routes/predict.py`)
- History endpoint → Verification records: reads recent records (evidence: `backend/app/api/routes/history.py`)
- Database sessions → Verification records: creates tables (evidence: `backend/app/db/database.py`)
- Model inference → Model artifacts: loads artifacts (evidence: `README.md`)
- Verdict panel → Verdict dial: renders dial (evidence: `frontend/components/ResultPanel.tsx`)
- FactForge interface → Verdict panel: displays verdict
- FactForge interface → History sidebar: shows case log
- History sidebar → API client: requests history
- Demo data generation → Demo model training: provides synthetic data (evidence: `README.md`)
- Data preparation → Model training: prepares dataset (evidence: `README.md`)
- Model training → Model artifacts: saves trained model (evidence: `README.md`)
- Demo model training → Model artifacts: saves demo model (evidence: `README.md`)
