# clive0707/textiq architecture

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

- Interactive diagram: https://gitdiagram.com/clive0707/textiq
- Repository: https://github.com/clive0707/textiq

## Overview

TextIQ is a web platform for news-text classification and NLP analysis. Users load or upload a labeled dataset, configure and train a model, review experiments and evaluation, then classify text or CSV batches; predictions include calibrated confidence, feature explanations where supported, and optional similar-document results. Reports export evaluation results to PDF. The README documents these capabilities and their broad architecture; sampled source confirms app registration, dataset validation, model registry, persistence conventions, and frontend classification behavior, but most route/service call wiring was not sampled.

Main entry points: [`backend/app.py`](https://github.com/clive0707/textiq/blob/main/backend/app.py) (Flask application), [`backend/services/training.py`](https://github.com/clive0707/textiq/blob/main/backend/services/training.py) (Training and evaluation), [`backend/services/predictor.py`](https://github.com/clive0707/textiq/blob/main/backend/services/predictor.py) (Prediction service), [`backend/services/repository.py`](https://github.com/clive0707/textiq/blob/main/backend/services/repository.py) (Repository and runs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_web["React application<br/>[App.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_classify_ui["Classification workspace<br/>[ClassifyPage.tsx]"]
  node_batch_ui["Batch workflow<br/>[BatchPage.tsx]"]
  node_dataset_ui["Dataset workspace<br/>[DatasetPage.tsx]"]
  node_models_ui["Models and experiments<br/>[ModelsPage.tsx]"]
  node_analytics_ui["Analytics dashboard<br/>[AnalyticsPage.tsx]"]
end

subgraph group_api["API workflows"]
  node_flask["Flask application<br/>[app.py]"]
  node_dataset_routes["Dataset routes<br/>[datasets.py]"]
  node_classify_routes["Classification routes<br/>[classify.py]"]
  node_batch_routes["Batch routes<br/>[batch.py]"]
  node_model_routes["Model routes<br/>[models.py]"]
  node_analytics_routes["Analytics routes<br/>[analytics.py]"]
  node_report_routes["Report routes<br/>[reports.py]"]
end

subgraph group_ml["NLP and models"]
  node_dataset_loader["Dataset validation<br/>[loader.py]"]
  node_preprocessing["Text preprocessing<br/>[text.py]"]
  node_features["Feature extraction<br/>[features.py]"]
  node_registry["Classifier registry<br/>[registry.py]"]
  node_training["Training and evaluation<br/>[training.py]"]
  node_predictor["Prediction service<br/>[predictor.py]"]
  node_explain["Feature explanations<br/>[explain.py]"]
  node_similarity["Similarity search<br/>[index.py]"]
end

subgraph group_state["Persistence and results"]
  node_repository["Repository and runs<br/>[repository.py]"]
  node_db[("SQLite state<br/>[db.py]")]
  node_pdf["PDF report output<br/>[report.py]"]
end

node_user(("Platform user"))
node_csv["Dataset CSV files"]
node_model_files["Saved model artifacts"]

node_user -->|"uses"| node_web
node_web -->|"routes to"| node_classify_ui
node_web -->|"routes to"| node_batch_ui
node_web -->|"routes to"| node_dataset_ui
node_web -->|"routes to"| node_models_ui
node_web -->|"routes to"| node_analytics_ui
node_classify_ui -->|"requests"| node_api_client
node_batch_ui -->|"requests"| node_api_client
node_dataset_ui -->|"requests"| node_api_client
node_models_ui -->|"requests"| node_api_client
node_analytics_ui -->|"requests"| node_api_client
node_api_client -->|"HTTP /api"| node_flask
node_flask -->|"registers"| node_dataset_routes
node_flask -->|"registers"| node_classify_routes
node_flask -->|"registers"| node_batch_routes
node_flask -->|"registers"| node_model_routes
node_flask -->|"registers"| node_analytics_routes
node_flask -->|"registers"| node_report_routes
node_dataset_routes -->|"validates"| node_dataset_loader
node_dataset_routes -->|"reads / writes"| node_csv
node_dataset_loader -->|"reads"| node_csv
node_dataset_routes -->|"queries"| node_repository
node_repository -->|"reads / writes"| node_db
node_model_routes -->|"starts training"| node_training
node_training -->|"builds training frame"| node_dataset_loader
node_training -->|"processes text"| node_preprocessing
node_training -->|"extracts features"| node_features
node_training -->|"tunes and fits"| node_registry
node_training -->|"records run"| node_repository
node_training -->|"saves artifact"| node_model_files
node_classify_routes -->|"predicts"| node_predictor
node_batch_routes -->|"classifies rows"| node_predictor
node_predictor -->|"loads deployed run"| node_repository
node_predictor -->|"loads artifact"| node_model_files
node_predictor -->|"processes text"| node_preprocessing
node_predictor -->|"vectorizes"| node_features
node_predictor -->|"gets contributions"| node_explain
node_classify_routes -.->|"queries similar texts"| node_similarity
node_analytics_routes -->|"reads run results"| node_repository
node_report_routes -->|"exports results"| node_pdf
node_pdf -->|"reads evaluation"| node_repository
node_repository -->|"returns run data"| node_analytics_routes

click node_web "https://github.com/clive0707/textiq/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/clive0707/textiq/blob/main/frontend/src/services/api.ts"
click node_classify_ui "https://github.com/clive0707/textiq/blob/main/frontend/src/pages/ClassifyPage.tsx"
click node_batch_ui "https://github.com/clive0707/textiq/blob/main/frontend/src/pages/BatchPage.tsx"
click node_dataset_ui "https://github.com/clive0707/textiq/blob/main/frontend/src/pages/DatasetPage.tsx"
click node_models_ui "https://github.com/clive0707/textiq/blob/main/frontend/src/pages/ModelsPage.tsx"
click node_analytics_ui "https://github.com/clive0707/textiq/blob/main/frontend/src/pages/AnalyticsPage.tsx"
click node_flask "https://github.com/clive0707/textiq/blob/main/backend/app.py"
click node_dataset_routes "https://github.com/clive0707/textiq/blob/main/backend/routes/datasets.py"
click node_classify_routes "https://github.com/clive0707/textiq/blob/main/backend/routes/classify.py"
click node_batch_routes "https://github.com/clive0707/textiq/blob/main/backend/routes/batch.py"
click node_model_routes "https://github.com/clive0707/textiq/blob/main/backend/routes/models.py"
click node_analytics_routes "https://github.com/clive0707/textiq/blob/main/backend/routes/analytics.py"
click node_report_routes "https://github.com/clive0707/textiq/blob/main/backend/routes/reports.py"
click node_dataset_loader "https://github.com/clive0707/textiq/blob/main/backend/datasets/loader.py"
click node_preprocessing "https://github.com/clive0707/textiq/blob/main/backend/preprocessing/text.py"
click node_features "https://github.com/clive0707/textiq/blob/main/backend/classification/features.py"
click node_registry "https://github.com/clive0707/textiq/blob/main/backend/classification/registry.py"
click node_training "https://github.com/clive0707/textiq/blob/main/backend/services/training.py"
click node_predictor "https://github.com/clive0707/textiq/blob/main/backend/services/predictor.py"
click node_explain "https://github.com/clive0707/textiq/blob/main/backend/explainability/explain.py"
click node_similarity "https://github.com/clive0707/textiq/blob/main/backend/similarity/index.py"
click node_repository "https://github.com/clive0707/textiq/blob/main/backend/services/repository.py"
click node_db "https://github.com/clive0707/textiq/blob/main/backend/db.py"
click node_pdf "https://github.com/clive0707/textiq/blob/main/backend/services/report.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_api_client,node_classify_ui,node_batch_ui,node_dataset_ui,node_models_ui,node_analytics_ui,node_user toneBlue
class node_flask,node_dataset_routes,node_classify_routes,node_batch_routes,node_model_routes,node_analytics_routes,node_report_routes toneAmber
class node_dataset_loader,node_preprocessing,node_features,node_registry,node_training,node_predictor,node_explain,node_similarity toneMint
class node_repository,node_db,node_pdf toneRose
class node_csv,node_model_files toneIndigo
```

## Components

### Web interface

- [React application](https://github.com/clive0707/textiq/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/clive0707/textiq/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Classification workspace](https://github.com/clive0707/textiq/blob/main/frontend/src/pages/ClassifyPage.tsx): `frontend/src/pages/ClassifyPage.tsx`
- [Batch workflow](https://github.com/clive0707/textiq/blob/main/frontend/src/pages/BatchPage.tsx): `frontend/src/pages/BatchPage.tsx`
- [Dataset workspace](https://github.com/clive0707/textiq/blob/main/frontend/src/pages/DatasetPage.tsx): `frontend/src/pages/DatasetPage.tsx`
- [Models and experiments](https://github.com/clive0707/textiq/blob/main/frontend/src/pages/ModelsPage.tsx): `frontend/src/pages/ModelsPage.tsx`
- [Analytics dashboard](https://github.com/clive0707/textiq/blob/main/frontend/src/pages/AnalyticsPage.tsx): `frontend/src/pages/AnalyticsPage.tsx`

### API workflows

- [Flask application](https://github.com/clive0707/textiq/blob/main/backend/app.py): `backend/app.py`
- [Dataset routes](https://github.com/clive0707/textiq/blob/main/backend/routes/datasets.py): `backend/routes/datasets.py`
- [Classification routes](https://github.com/clive0707/textiq/blob/main/backend/routes/classify.py): `backend/routes/classify.py`
- [Batch routes](https://github.com/clive0707/textiq/blob/main/backend/routes/batch.py): `backend/routes/batch.py`
- [Model routes](https://github.com/clive0707/textiq/blob/main/backend/routes/models.py): `backend/routes/models.py`
- [Analytics routes](https://github.com/clive0707/textiq/blob/main/backend/routes/analytics.py): `backend/routes/analytics.py`
- [Report routes](https://github.com/clive0707/textiq/blob/main/backend/routes/reports.py): `backend/routes/reports.py`

### NLP and models

- [Dataset validation](https://github.com/clive0707/textiq/blob/main/backend/datasets/loader.py): `backend/datasets/loader.py`
- [Text preprocessing](https://github.com/clive0707/textiq/blob/main/backend/preprocessing/text.py): `backend/preprocessing/text.py`
- [Feature extraction](https://github.com/clive0707/textiq/blob/main/backend/classification/features.py): `backend/classification/features.py`
- [Classifier registry](https://github.com/clive0707/textiq/blob/main/backend/classification/registry.py): `backend/classification/registry.py`
- [Training and evaluation](https://github.com/clive0707/textiq/blob/main/backend/services/training.py): `backend/services/training.py`
- [Prediction service](https://github.com/clive0707/textiq/blob/main/backend/services/predictor.py): `backend/services/predictor.py`
- [Feature explanations](https://github.com/clive0707/textiq/blob/main/backend/explainability/explain.py): `backend/explainability/explain.py`
- [Similarity search](https://github.com/clive0707/textiq/blob/main/backend/similarity/index.py): `backend/similarity/index.py`

### Persistence and results

- [Repository and runs](https://github.com/clive0707/textiq/blob/main/backend/services/repository.py): `backend/services/repository.py`
- [SQLite state](https://github.com/clive0707/textiq/blob/main/backend/db.py): `backend/db.py`
- [PDF report output](https://github.com/clive0707/textiq/blob/main/backend/services/report.py): `backend/services/report.py`

### Other components

- **Platform user**
- **Dataset CSV files**
- **Saved model artifacts**

## Connections

- Platform user → React application: uses
- React application → Classification workspace: routes to
- React application → Batch workflow: routes to
- React application → Dataset workspace: routes to
- React application → Models and experiments: routes to
- React application → Analytics dashboard: routes to
- Classification workspace → API client: requests
- Batch workflow → API client: requests
- Dataset workspace → API client: requests
- Models and experiments → API client: requests
- Analytics dashboard → API client: requests
- API client → Flask application: HTTP /api
- Flask application → Dataset routes: registers
- Flask application → Classification routes: registers
- Flask application → Batch routes: registers
- Flask application → Model routes: registers
- Flask application → Analytics routes: registers
- Flask application → Report routes: registers
- Dataset routes → Dataset validation: validates
- Dataset routes → Dataset CSV files: reads / writes
- Dataset validation → Dataset CSV files: reads
- Dataset routes → Repository and runs: queries
- Repository and runs → SQLite state: reads / writes
- Model routes → Training and evaluation: starts training
- Training and evaluation → Dataset validation: builds training frame
- Training and evaluation → Text preprocessing: processes text
- Training and evaluation → Feature extraction: extracts features
- Training and evaluation → Classifier registry: tunes and fits
- Training and evaluation → Repository and runs: records run
- Training and evaluation → Saved model artifacts: saves artifact
- Classification routes → Prediction service: predicts
- Batch routes → Prediction service: classifies rows
- Prediction service → Repository and runs: loads deployed run
- Prediction service → Saved model artifacts: loads artifact
- Prediction service → Text preprocessing: processes text
- Prediction service → Feature extraction: vectorizes
- Prediction service → Feature explanations: gets contributions
- Classification routes → Similarity search: queries similar texts
- Analytics routes → Repository and runs: reads run results
- Report routes → PDF report output: exports results
- PDF report output → Repository and runs: reads evaluation
- Repository and runs → Analytics routes: returns run data
