# mohansaikokku/veritext-ai architecture

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

- Interactive diagram: https://gitdiagram.com/mohansaikokku/veritext-ai
- Repository: https://github.com/mohansaikokku/veritext-ai

## Overview

VeriText AI accepts text or PDF, DOCX, and TXT uploads through a web interface, sends them to a FastAPI backend, and returns AI-versus-human predictions with confidence and chunk details. File requests are temporarily saved, extracted, and removed; both input paths are cleaned, split into chunks, classified by a Hugging Face transformer, and aggregated. The graph separates those domain stages and the UI result presentation. Connections are limited to relationships shown in excerpts or documented in the README; unsampled HTML details are not inferred.

Main entry points: [`main.py`](https://github.com/mohansaikokku/veritext-ai/blob/main/main.py) (FastAPI routes), [`script.js`](https://github.com/mohansaikokku/veritext-ai/blob/main/script.js) (Input and results), [`analyzer.py`](https://github.com/mohansaikokku/veritext-ai/blob/main/analyzer.py) (Clean and chunk), [`index.html`](https://github.com/mohansaikokku/veritext-ai/blob/main/index.html) (Analysis interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_web["Analysis interface<br/>[index.html]"]
  node_interactions["Input and results<br/>[script.js]"]
end

subgraph group_api["API and uploads"]
  node_api_routes["FastAPI routes<br/>[main.py]"]
  node_temp_files["Temporary uploads<br/>[main.py]"]
end

subgraph group_documents["Document extraction"]
  node_extract_dispatch["Format dispatch<br/>[text_extractor.py]"]
  node_extract_formats["PDF DOCX TXT readers<br/>[text_extractor.py]"]
end

subgraph group_detection["Text detection"]
  node_text_prep["Clean and chunk<br/>[analyzer.py]"]
  node_classification["Text classifier<br/>[model.py]"]
  node_aggregation["Prediction summary<br/>[analyzer.py]"]
end

node_user(("User"))
node_transformer["Hugging Face model"]

node_user -->|"provides input"| node_web
node_web -.->|"uses interface"| node_interactions
node_interactions -->|"posts text or file"| node_api_routes
node_api_routes -->|"returns results"| node_interactions
node_api_routes -->|"saves and removes"| node_temp_files
node_api_routes -->|"extracts uploaded text"| node_extract_dispatch
node_extract_dispatch -->|"selects reader"| node_extract_formats
node_api_routes -->|"analyzes text"| node_text_prep
node_text_prep -->|"classifies chunks"| node_classification
node_classification -.->|"runs inference"| node_transformer
node_text_prep -->|"summarizes predictions"| node_aggregation
node_aggregation -->|"displays analysis"| node_interactions

click node_web "https://github.com/mohansaikokku/veritext-ai/blob/main/index.html"
click node_interactions "https://github.com/mohansaikokku/veritext-ai/blob/main/script.js"
click node_api_routes "https://github.com/mohansaikokku/veritext-ai/blob/main/main.py"
click node_temp_files "https://github.com/mohansaikokku/veritext-ai/blob/main/main.py"
click node_extract_dispatch "https://github.com/mohansaikokku/veritext-ai/blob/main/text_extractor.py"
click node_extract_formats "https://github.com/mohansaikokku/veritext-ai/blob/main/text_extractor.py"
click node_text_prep "https://github.com/mohansaikokku/veritext-ai/blob/main/analyzer.py"
click node_classification "https://github.com/mohansaikokku/veritext-ai/blob/main/model.py"
click node_aggregation "https://github.com/mohansaikokku/veritext-ai/blob/main/analyzer.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_web,node_interactions,node_user toneBlue
class node_api_routes,node_temp_files toneAmber
class node_extract_dispatch,node_extract_formats toneMint
class node_text_prep,node_classification,node_aggregation toneRose
class node_transformer toneIndigo
```

## Components

### Web interface

- [Analysis interface](https://github.com/mohansaikokku/veritext-ai/blob/main/index.html): `index.html`
- [Input and results](https://github.com/mohansaikokku/veritext-ai/blob/main/script.js): `script.js`

### API and uploads

- [FastAPI routes](https://github.com/mohansaikokku/veritext-ai/blob/main/main.py): `main.py`
- [Temporary uploads](https://github.com/mohansaikokku/veritext-ai/blob/main/main.py): `main.py`

### Document extraction

- [Format dispatch](https://github.com/mohansaikokku/veritext-ai/blob/main/text_extractor.py): `text_extractor.py`
- [PDF DOCX TXT readers](https://github.com/mohansaikokku/veritext-ai/blob/main/text_extractor.py): `text_extractor.py`

### Text detection

- [Clean and chunk](https://github.com/mohansaikokku/veritext-ai/blob/main/analyzer.py): `analyzer.py`
- [Text classifier](https://github.com/mohansaikokku/veritext-ai/blob/main/model.py): `model.py`
- [Prediction summary](https://github.com/mohansaikokku/veritext-ai/blob/main/analyzer.py): `analyzer.py`

### Other components

- **User**
- **Hugging Face model**

## Connections

- User → Analysis interface: provides input (evidence: `README.md`)
- Analysis interface → Input and results: uses interface
- Input and results → FastAPI routes: posts text or file (evidence: `script.js`)
- FastAPI routes → Input and results: returns results (evidence: `script.js`)
- FastAPI routes → Temporary uploads: saves and removes (evidence: `main.py`)
- FastAPI routes → Format dispatch: extracts uploaded text (evidence: `main.py`)
- Format dispatch → PDF DOCX TXT readers: selects reader (evidence: `text_extractor.py`)
- FastAPI routes → Clean and chunk: analyzes text (evidence: `main.py`)
- Clean and chunk → Text classifier: classifies chunks (evidence: `analyzer.py`)
- Text classifier → Hugging Face model: runs inference
- Clean and chunk → Prediction summary: summarizes predictions (evidence: `analyzer.py`)
- Prediction summary → Input and results: displays analysis (evidence: `script.js`)
