# welpmemates/dlsa architecture

> Architecture diagram of the GitHub repository welpmemates/dlsa, 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/welpmemates/dlsa
- Repository: https://github.com/welpmemates/dlsa

## Overview

DLSA is a full-stack IMDB review sentiment analyzer: users submit a review in the React app, which calls a FastAPI endpoint that preprocesses the text and runs a trained BiLSTM, then displays the prediction and session history. A separate notebook trains and evaluates the model; inference reuses its saved checkpoint and vocabulary. The graph includes documented training stages and the visible frontend components. Training details and some UI modules are documented or indexed but not excerpted, so those links rely on the README or import references.

Main entry points: [`frontend/src/App.jsx`](https://github.com/welpmemates/dlsa/blob/main/frontend/src/App.jsx) (App state and API), [`backend/model.py`](https://github.com/welpmemates/dlsa/blob/main/backend/model.py) (Tokenizer and BiLSTM), [`backend/main.py`](https://github.com/welpmemates/dlsa/blob/main/backend/main.py) (FastAPI endpoints), [`IMDB_BiLSTM_Sentiment_Analysis.ipynb`](https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb) (Model evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_dataset[("IMDB reviews")]
  node_preprocessing["Text preprocessing"]
  node_vocabulary_build["Vocabulary building"]
  node_encoding["Review encoding"]
  node_training_model["BiLSTM training"]
  node_evaluation["Model evaluation"]
end

subgraph group_inference["Inference service"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_model_runtime["Tokenizer and BiLSTM<br/>[model.py]"]
end

subgraph group_frontend["Web application"]
  node_web_entry["React entry<br/>[main.jsx]"]
  node_app["App state and API<br/>[App.jsx]"]
  node_analyzer["Review analyzer<br/>[Analyzer.jsx]"]
  node_examples["Example reviews<br/>[examples.js]"]
  node_result_view["Prediction result"]
  node_history_view["Prediction history"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_stats["Model information<br/>[ModelStats.jsx]"]
  node_pipeline_view["Pipeline overview<br/>[Pipeline.jsx]"]
  node_footer["Footer<br/>[Footer.jsx]"]
end

subgraph group_artifacts["Model artifacts"]
  node_vocab_file["Saved vocabulary<br/>[vocab.json]"]
  node_checkpoint["Model checkpoint"]
end

node_reviewer(("Review user"))

node_reviewer -->|"enters review"| node_app
node_dataset -->|"loads and cleans"| node_preprocessing
node_preprocessing -->|"tokenizes text"| node_vocabulary_build
node_vocabulary_build -->|"maps tokens"| node_encoding
node_encoding -->|"feeds sequences"| node_training_model
node_training_model -->|"evaluated by"| node_evaluation
node_evaluation -->|"saves checkpoint"| node_checkpoint
node_evaluation -->|"saves vocabulary"| node_vocab_file
node_web_entry -->|"renders"| node_app
node_app -->|"renders and supplies props"| node_analyzer
node_app -->|"reads examples"| node_examples
node_app -->|"renders result"| node_result_view
node_app -->|"renders history"| node_history_view
node_app -->|"renders"| node_navbar
node_app -->|"renders"| node_stats
node_app -->|"renders"| node_pipeline_view
node_app -->|"renders"| node_footer
node_app -->|"checks health and posts review"| node_api
node_api -->|"loads and invokes"| node_model_runtime
node_model_runtime -->|"loads vocabulary"| node_vocab_file
node_model_runtime -->|"loads weights"| node_checkpoint
node_api -->|"returns prediction or status"| node_app
node_model_runtime -->|"returns sentiment and probabilities"| node_api

click node_preprocessing "https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb"
click node_vocabulary_build "https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb"
click node_encoding "https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb"
click node_training_model "https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb"
click node_evaluation "https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb"
click node_vocab_file "https://github.com/welpmemates/dlsa/blob/main/models/vocab.json"
click node_checkpoint "https://github.com/welpmemates/dlsa/blob/main/models/sentiment_bilstm.pth"
click node_web_entry "https://github.com/welpmemates/dlsa/blob/main/frontend/src/main.jsx"
click node_app "https://github.com/welpmemates/dlsa/blob/main/frontend/src/App.jsx"
click node_analyzer "https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Analyzer.jsx"
click node_examples "https://github.com/welpmemates/dlsa/blob/main/frontend/src/data/examples.js"
click node_result_view "https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/PredictionResult.jsx"
click node_history_view "https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/PredictionHistory.jsx"
click node_navbar "https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Navbar.jsx"
click node_stats "https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/ModelStats.jsx"
click node_pipeline_view "https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Pipeline.jsx"
click node_footer "https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Footer.jsx"
click node_api "https://github.com/welpmemates/dlsa/blob/main/backend/main.py"
click node_model_runtime "https://github.com/welpmemates/dlsa/blob/main/backend/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_dataset,node_preprocessing,node_vocabulary_build,node_encoding,node_training_model,node_evaluation,node_reviewer toneBlue
class node_api,node_model_runtime toneAmber
class node_web_entry,node_app,node_analyzer,node_examples,node_result_view,node_history_view,node_navbar,node_stats,node_pipeline_view,node_footer toneMint
class node_vocab_file,node_checkpoint toneRose
```

## Components

### Model training

- **IMDB reviews**
- [Text preprocessing](https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb): `IMDB_BiLSTM_Sentiment_Analysis.ipynb`
- [Vocabulary building](https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb): `IMDB_BiLSTM_Sentiment_Analysis.ipynb`
- [Review encoding](https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb): `IMDB_BiLSTM_Sentiment_Analysis.ipynb`
- [BiLSTM training](https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb): `IMDB_BiLSTM_Sentiment_Analysis.ipynb`
- [Model evaluation](https://github.com/welpmemates/dlsa/blob/main/IMDB_BiLSTM_Sentiment_Analysis.ipynb): `IMDB_BiLSTM_Sentiment_Analysis.ipynb`

### Inference service

- [FastAPI endpoints](https://github.com/welpmemates/dlsa/blob/main/backend/main.py): `backend/main.py`
- [Tokenizer and BiLSTM](https://github.com/welpmemates/dlsa/blob/main/backend/model.py): `backend/model.py`

### Web application

- [React entry](https://github.com/welpmemates/dlsa/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [App state and API](https://github.com/welpmemates/dlsa/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Review analyzer](https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Analyzer.jsx): `frontend/src/components/Analyzer.jsx`
- [Example reviews](https://github.com/welpmemates/dlsa/blob/main/frontend/src/data/examples.js): `frontend/src/data/examples.js`
- [Prediction result](https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/PredictionResult.jsx): `frontend/src/components/PredictionResult.jsx`
- [Prediction history](https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/PredictionHistory.jsx): `frontend/src/components/PredictionHistory.jsx`
- [Navigation](https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Model information](https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/ModelStats.jsx): `frontend/src/components/ModelStats.jsx`
- [Pipeline overview](https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Pipeline.jsx): `frontend/src/components/Pipeline.jsx`
- [Footer](https://github.com/welpmemates/dlsa/blob/main/frontend/src/components/Footer.jsx): `frontend/src/components/Footer.jsx`

### Model artifacts

- [Saved vocabulary](https://github.com/welpmemates/dlsa/blob/main/models/vocab.json): `models/vocab.json`
- [Model checkpoint](https://github.com/welpmemates/dlsa/blob/main/models/sentiment_bilstm.pth): `models/sentiment_bilstm.pth`

### Other components

- **Review user**

## Connections

- Review user → App state and API: enters review (evidence: `README.md`)
- IMDB reviews → Text preprocessing: loads and cleans (evidence: `README.md`)
- Text preprocessing → Vocabulary building: tokenizes text (evidence: `README.md`)
- Vocabulary building → Review encoding: maps tokens (evidence: `README.md`)
- Review encoding → BiLSTM training: feeds sequences (evidence: `README.md`)
- BiLSTM training → Model evaluation: evaluated by (evidence: `README.md`)
- Model evaluation → Model checkpoint: saves checkpoint (evidence: `README.md`)
- Model evaluation → Saved vocabulary: saves vocabulary (evidence: `README.md`)
- React entry → App state and API: renders (evidence: `frontend/src/main.jsx`)
- App state and API → Review analyzer: renders and supplies props (evidence: `frontend/src/App.jsx`)
- App state and API → Example reviews: reads examples (evidence: `frontend/src/App.jsx`)
- App state and API → Prediction result: renders result (evidence: `frontend/src/App.jsx`)
- App state and API → Prediction history: renders history (evidence: `frontend/src/App.jsx`)
- App state and API → Navigation: renders (evidence: `frontend/src/App.jsx`)
- App state and API → Model information: renders (evidence: `frontend/src/App.jsx`)
- App state and API → Pipeline overview: renders (evidence: `frontend/src/App.jsx`)
- App state and API → Footer: renders (evidence: `frontend/src/App.jsx`)
- App state and API → FastAPI endpoints: checks health and posts review (evidence: `frontend/src/App.jsx`)
- FastAPI endpoints → Tokenizer and BiLSTM: loads and invokes (evidence: `backend/main.py`)
- Tokenizer and BiLSTM → Saved vocabulary: loads vocabulary (evidence: `backend/model.py`)
- Tokenizer and BiLSTM → Model checkpoint: loads weights (evidence: `backend/model.py`)
- FastAPI endpoints → App state and API: returns prediction or status (evidence: `frontend/src/App.jsx`)
- Tokenizer and BiLSTM → FastAPI endpoints: returns sentiment and probabilities (evidence: `backend/main.py`)
