# hasnainnqv/texpose-deployment architecture

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

- Interactive diagram: https://gitdiagram.com/hasnainnqv/texpose-deployment
- Repository: https://github.com/hasnainnqv/texpose-deployment

## Overview

This repository is a web-based AI-text detector. A user submits text through the FastAPI page; the classify route runs a two-stage prediction and returns the result in the page. The classifier cleans text, applies a BERT human-versus-AI model, and, for AI predictions, applies a second model to identify a likely LLM. At startup, the app loads model weights and a tokenizer; missing weights are downloaded. The tree also includes static informational pages and assets. Source evidence is limited to the excerpts and index, so links among unsampled pages are omitted.

Main entry points: [`app/main.py`](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/main.py) (FastAPI app), [`app/classifier_model.py`](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py) (Model loader), [`app/templates/index.html`](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/templates/index.html) (Classifier page), [`app/static`](https://github.com/hasnainnqv/texpose-deployment/tree/main/app/static) (Static pages and assets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_page["Classifier page<br/>[index.html]"]
  node_static["Static pages and assets"]
end

subgraph group_classification["Text classification"]
  node_clean["Text cleaning"]
  node_detector["Human-AI model"]
  node_llm_classifier["LLM classifier"]
end

subgraph group_models["Model resources"]
  node_tokenizer["BERT tokenizer"]
  node_loader["Model loader"]
  node_weights[("Local model weights")]
end

node_user(("User"))
node_huggingface["Hugging Face"]
node_gdrive["Google Drive"]
node_stopwords["NLTK stopwords"]

node_user -->|"submits text"| node_fastapi
node_fastapi -->|"renders"| node_page
node_fastapi -->|"serves assets"| node_static
node_fastapi -->|"loads models"| node_loader
node_fastapi -->|"classifies text"| node_clean
node_clean -->|"encodes text"| node_tokenizer
node_clean -->|"removes stopwords"| node_stopwords
node_tokenizer -->|"provides tokens"| node_detector
node_detector -->|"dispatches AI cases"| node_llm_classifier
node_loader -->|"loads pretrained tokenizer"| node_huggingface
node_loader -->|"loads weights"| node_weights
node_loader -->|"downloads missing weights"| node_gdrive

click node_fastapi "https://github.com/hasnainnqv/texpose-deployment/blob/main/app/main.py"
click node_page "https://github.com/hasnainnqv/texpose-deployment/blob/main/app/templates/index.html"
click node_static "https://github.com/hasnainnqv/texpose-deployment/tree/main/app/static"
click node_clean "https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py"
click node_tokenizer "https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py"
click node_detector "https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py"
click node_llm_classifier "https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py"
click node_loader "https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_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_fastapi,node_page,node_static,node_user toneBlue
class node_clean,node_detector,node_llm_classifier toneAmber
class node_tokenizer,node_loader,node_weights toneMint
class node_huggingface,node_gdrive,node_stopwords toneIndigo
```

## Components

### Web interface

- [FastAPI app](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/main.py): `app/main.py`
- [Classifier page](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/templates/index.html): `app/templates/index.html`
- [Static pages and assets](https://github.com/hasnainnqv/texpose-deployment/tree/main/app/static): `app/static`

### Text classification

- [Text cleaning](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py): `app/classifier_model.py`
- [Human-AI model](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py): `app/classifier_model.py`
- [LLM classifier](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py): `app/classifier_model.py`

### Model resources

- [BERT tokenizer](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py): `app/classifier_model.py`
- [Model loader](https://github.com/hasnainnqv/texpose-deployment/blob/main/app/classifier_model.py): `app/classifier_model.py`
- **Local model weights**

### Other components

- **User**
- **Hugging Face**
- **Google Drive**
- **NLTK stopwords**

## Connections

- User → FastAPI app: submits text (evidence: `app/main.py`)
- FastAPI app → Classifier page: renders (evidence: `app/main.py`)
- FastAPI app → Static pages and assets: serves assets (evidence: `app/main.py`)
- FastAPI app → Model loader: loads models (evidence: `app/main.py`)
- FastAPI app → Text cleaning: classifies text (evidence: `app/main.py`)
- Text cleaning → BERT tokenizer: encodes text (evidence: `app/classifier_model.py`)
- Text cleaning → NLTK stopwords: removes stopwords (evidence: `app/classifier_model.py`)
- BERT tokenizer → Human-AI model: provides tokens (evidence: `app/classifier_model.py`)
- Human-AI model → LLM classifier: dispatches AI cases (evidence: `app/classifier_model.py`)
- Model loader → Hugging Face: loads pretrained tokenizer (evidence: `app/classifier_model.py`)
- Model loader → Local model weights: loads weights (evidence: `app/classifier_model.py`)
- Model loader → Google Drive: downloads missing weights (evidence: `app/classifier_model.py`)
