# aonsanti/mbti-and-sentiment-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/aonsanti/mbti-and-sentiment-prediction
- Repository: https://github.com/aonsanti/mbti-and-sentiment-prediction

## Overview

WebAI is a text-analysis application for IMDB sentiment and MBTI personality prediction. Users choose an analysis page, submit text through a shared frontend hook, and receive a prediction and model metadata from the API; the sentiment path additionally applies VADER to short text. Separate training programs prepare and save model artifacts. The API and frontend excerpts show these runtime links; training-to-artifact links are documented by the README and source index, while unsampled model-training details are not expanded.

Main entry points: [`Frontend/src/App.jsx`](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/App.jsx) (App routing), [`Backend/train_ml.py`](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/train_ml.py) (Sentiment training), [`Backend/main.py`](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py) (Sentiment inference), [`Backend/train_nn.py`](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/train_nn.py) (MBTI training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_app["App routing<br/>[App.jsx]"]
  node_home["Home page<br/>[Home.jsx]"]
  node_header["Header<br/>[Header.jsx]"]
  node_footer["Footer<br/>[Footer.jsx]"]
  node_ml_page["Sentiment page"]
  node_nn_page["MBTI page<br/>[NeuralNetwork.jsx]"]
  node_hook["Model hook<br/>[useModel.js]"]
  node_demo["Demo predictions<br/>[demoPredictions.js]"]
end

subgraph group_api["Prediction API"]
  node_api_main["API endpoints<br/>[main.py]"]
end

subgraph group_inference["Inference and artifacts"]
  node_preprocess["Text cleaning<br/>[preprocess.py]"]
  node_ml_infer["Sentiment inference<br/>[main.py]"]
  node_mbti_infer["MBTI inference<br/>[main.py]"]
  node_vader["VADER override<br/>[main.py]"]
  node_ml_model["Sentiment model<br/>[ml_model.pkl]"]
  node_ml_vectorizer["TF-IDF vectorizer<br/>[ml_vectorizer.pkl]"]
  node_nn_model["MBTI model<br/>[nn_model.pkl]"]
  node_ml_metrics["Sentiment metrics<br/>[ml_metrics.json]"]
  node_nn_metrics["MBTI metrics<br/>[nn_metrics.json]"]
end

subgraph group_training["Model training"]
  node_train_ml["Sentiment training<br/>[train_ml.py]"]
  node_train_nn["MBTI training<br/>[train_nn.py]"]
  node_datasets["Training datasets"]
end

node_user(("Text analyst"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_ml_page
node_app -->|"routes to"| node_nn_page
node_app -->|"renders"| node_header
node_app -->|"renders"| node_footer
node_ml_page -->|"requests prediction"| node_hook
node_nn_page -->|"requests prediction"| node_hook
node_hook -->|"calls API"| node_api_main
node_hook -->|"uses fallback"| node_demo
node_api_main -->|"cleans text"| node_preprocess
node_api_main -->|"dispatches sentiment"| node_ml_infer
node_api_main -->|"dispatches MBTI"| node_mbti_infer
node_ml_infer -->|"loads and predicts"| node_ml_model
node_ml_infer -->|"transforms text"| node_ml_vectorizer
node_ml_infer -->|"checks short text"| node_vader
node_ml_infer -->|"reads metrics"| node_ml_metrics
node_mbti_infer -->|"loads and predicts"| node_nn_model
node_mbti_infer -->|"reads metrics"| node_nn_metrics
node_train_ml -->|"uses cleaning"| node_preprocess
node_train_ml -->|"reads reviews"| node_datasets
node_train_ml -->|"saves model"| node_ml_model
node_train_ml -->|"saves vectorizer"| node_ml_vectorizer
node_train_ml -->|"writes metrics"| node_ml_metrics
node_train_nn -->|"uses cleaning"| node_preprocess
node_train_nn -.->|"trains on"| node_datasets
node_train_nn -.->|"produces model"| node_nn_model
node_train_nn -.->|"produces metrics"| node_nn_metrics

click node_app "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/App.jsx"
click node_home "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/pages/Home.jsx"
click node_header "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/component/Header.jsx"
click node_footer "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/component/Footer.jsx"
click node_ml_page "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/pages/MachineLearning.jsx"
click node_nn_page "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/pages/NeuralNetwork.jsx"
click node_hook "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/hooks/useModel.js"
click node_demo "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/utils/demoPredictions.js"
click node_api_main "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py"
click node_preprocess "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/preprocess.py"
click node_ml_infer "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py"
click node_mbti_infer "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py"
click node_vader "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py"
click node_ml_model "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/ml_model.pkl"
click node_ml_vectorizer "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/ml_vectorizer.pkl"
click node_nn_model "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/nn_model.pkl"
click node_ml_metrics "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/ml_metrics.json"
click node_nn_metrics "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/nn_metrics.json"
click node_train_ml "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/train_ml.py"
click node_train_nn "https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/train_nn.py"
click node_datasets "https://github.com/aonsanti/mbti-and-sentiment-prediction/tree/main/Dataset"

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_app,node_home,node_header,node_footer,node_ml_page,node_nn_page,node_hook,node_demo toneBlue
class node_api_main toneAmber
class node_preprocess,node_ml_infer,node_mbti_infer,node_vader,node_ml_model,node_ml_vectorizer,node_nn_model,node_ml_metrics,node_nn_metrics toneMint
class node_train_ml,node_train_nn,node_datasets toneRose
class node_user toneIndigo
```

## Components

### Web interface

- [App routing](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Home page](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/pages/Home.jsx): `Frontend/src/pages/Home.jsx`
- [Header](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/component/Header.jsx): `Frontend/src/component/Header.jsx`
- [Footer](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/component/Footer.jsx): `Frontend/src/component/Footer.jsx`
- [Sentiment page](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/pages/MachineLearning.jsx): `Frontend/src/pages/MachineLearning.jsx`
- [MBTI page](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/pages/NeuralNetwork.jsx): `Frontend/src/pages/NeuralNetwork.jsx`
- [Model hook](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/hooks/useModel.js): `Frontend/src/hooks/useModel.js`
- [Demo predictions](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Frontend/src/utils/demoPredictions.js): `Frontend/src/utils/demoPredictions.js`

### Prediction API

- [API endpoints](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py): `Backend/main.py`

### Inference and artifacts

- [Text cleaning](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/preprocess.py): `Backend/preprocess.py`
- [Sentiment inference](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py): `Backend/main.py`
- [MBTI inference](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py): `Backend/main.py`
- [VADER override](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/main.py): `Backend/main.py`
- [Sentiment model](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/ml_model.pkl): `Models/ml_model.pkl`
- [TF-IDF vectorizer](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/ml_vectorizer.pkl): `Models/ml_vectorizer.pkl`
- [MBTI model](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/nn_model.pkl): `Models/nn_model.pkl`
- [Sentiment metrics](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/ml_metrics.json): `Models/ml_metrics.json`
- [MBTI metrics](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Models/nn_metrics.json): `Models/nn_metrics.json`

### Model training

- [Sentiment training](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/train_ml.py): `Backend/train_ml.py`
- [MBTI training](https://github.com/aonsanti/mbti-and-sentiment-prediction/blob/main/Backend/train_nn.py): `Backend/train_nn.py`
- [Training datasets](https://github.com/aonsanti/mbti-and-sentiment-prediction/tree/main/Dataset): `Dataset`

### Other components

- **Text analyst**

## Connections

- Text analyst → App routing: uses (evidence: `README.md`)
- App routing → Home page: routes to (evidence: `Frontend/src/App.jsx`)
- App routing → Sentiment page: routes to (evidence: `Frontend/src/App.jsx`)
- App routing → MBTI page: routes to (evidence: `Frontend/src/App.jsx`)
- App routing → Header: renders (evidence: `Frontend/src/App.jsx`)
- App routing → Footer: renders (evidence: `Frontend/src/App.jsx`)
- Sentiment page → Model hook: requests prediction (evidence: `Frontend/src/pages/MachineLearning.jsx`)
- MBTI page → Model hook: requests prediction (evidence: `Frontend/src/pages/NeuralNetwork.jsx`)
- Model hook → API endpoints: calls API (evidence: `Frontend/src/hooks/useModel.js`)
- Model hook → Demo predictions: uses fallback (evidence: `Frontend/src/hooks/useModel.js`)
- API endpoints → Text cleaning: cleans text (evidence: `Backend/main.py`)
- API endpoints → Sentiment inference: dispatches sentiment (evidence: `Backend/main.py`)
- API endpoints → MBTI inference: dispatches MBTI (evidence: `Backend/main.py`)
- Sentiment inference → Sentiment model: loads and predicts (evidence: `Backend/main.py`)
- Sentiment inference → TF-IDF vectorizer: transforms text (evidence: `Backend/main.py`)
- Sentiment inference → VADER override: checks short text (evidence: `Backend/main.py`)
- Sentiment inference → Sentiment metrics: reads metrics (evidence: `Backend/main.py`)
- MBTI inference → MBTI model: loads and predicts (evidence: `Backend/main.py`)
- MBTI inference → MBTI metrics: reads metrics (evidence: `Backend/main.py`)
- Sentiment training → Text cleaning: uses cleaning (evidence: `Backend/train_ml.py`)
- Sentiment training → Training datasets: reads reviews (evidence: `Backend/train_ml.py`)
- Sentiment training → Sentiment model: saves model (evidence: `Backend/train_ml.py`)
- Sentiment training → TF-IDF vectorizer: saves vectorizer (evidence: `Backend/train_ml.py`)
- Sentiment training → Sentiment metrics: writes metrics (evidence: `Backend/train_ml.py`)
- MBTI training → Text cleaning: uses cleaning (evidence: `Backend/train_nn.py`)
- MBTI training → Training datasets: trains on
- MBTI training → MBTI model: produces model
- MBTI training → MBTI metrics: produces metrics
