# jayanthcsv/nextwordpredictor architecture

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

- Interactive diagram: https://gitdiagram.com/jayanthcsv/nextwordpredictor
- Repository: https://github.com/jayanthcsv/nextwordpredictor

## Overview

This is a Shakespeare-text next-word prediction application: users enter text in a Streamlit interface, which tokenizes and pads it, runs the saved LSTM, and displays the predicted word. The README also documents the data-preparation, training, and evaluation stages; those stages are represented at the notebook path, but its contents were not sampled. The app’s model and tokenizer loading and prediction calls are visible in app.py.

Main entry points: [`app.py`](https://github.com/jayanthcsv/nextwordpredictor/blob/main/app.py) (Next-word prediction), [`experiment.ipynb`](https://github.com/jayanthcsv/nextwordpredictor/blob/main/experiment.ipynb) (Text preprocessing), [`hamlet.txt`](https://github.com/jayanthcsv/nextwordpredictor/blob/main/hamlet.txt) (Hamlet text), [`nextwordlstm.h5`](https://github.com/jayanthcsv/nextwordpredictor/blob/main/nextwordlstm.h5) (Saved LSTM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_development["Data and training"]
  node_hamlet["Hamlet text<br/>[hamlet.txt]"]
  node_preprocessing["Text preprocessing<br/>[experiment.ipynb]"]
  node_training["LSTM training<br/>[experiment.ipynb]"]
  node_evaluation["Model evaluation<br/>[experiment.ipynb]"]
end

subgraph group_serving["Prediction app"]
  node_model["Saved LSTM<br/>[nextwordlstm.h5]"]
  node_tokenizer["Saved tokenizer<br/>[tokenizer.pickle]"]
  node_interface["Text input and results<br/>[app.py]"]
  node_prediction["Next-word prediction<br/>[app.py]"]
end

node_user(("User"))

node_hamlet -->|"provides text"| node_preprocessing
node_preprocessing -->|"prepares sequences"| node_training
node_training -->|"evaluated by"| node_evaluation
node_user -->|"enters text"| node_interface
node_interface -->|"invokes"| node_prediction
node_prediction -->|"loads and encodes"| node_tokenizer
node_prediction -->|"loads and predicts"| node_model
node_prediction -->|"returns word"| node_interface

click node_hamlet "https://github.com/jayanthcsv/nextwordpredictor/blob/main/hamlet.txt"
click node_preprocessing "https://github.com/jayanthcsv/nextwordpredictor/blob/main/experiment.ipynb"
click node_training "https://github.com/jayanthcsv/nextwordpredictor/blob/main/experiment.ipynb"
click node_evaluation "https://github.com/jayanthcsv/nextwordpredictor/blob/main/experiment.ipynb"
click node_model "https://github.com/jayanthcsv/nextwordpredictor/blob/main/nextwordlstm.h5"
click node_tokenizer "https://github.com/jayanthcsv/nextwordpredictor/blob/main/tokenizer.pickle"
click node_interface "https://github.com/jayanthcsv/nextwordpredictor/blob/main/app.py"
click node_prediction "https://github.com/jayanthcsv/nextwordpredictor/blob/main/app.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_hamlet,node_preprocessing,node_training,node_evaluation,node_user toneBlue
class node_model,node_tokenizer,node_interface,node_prediction toneAmber
```

## Components

### Data and training

- [Hamlet text](https://github.com/jayanthcsv/nextwordpredictor/blob/main/hamlet.txt): `hamlet.txt`
- [Text preprocessing](https://github.com/jayanthcsv/nextwordpredictor/blob/main/experiment.ipynb): `experiment.ipynb`
- [LSTM training](https://github.com/jayanthcsv/nextwordpredictor/blob/main/experiment.ipynb): `experiment.ipynb`
- [Model evaluation](https://github.com/jayanthcsv/nextwordpredictor/blob/main/experiment.ipynb): `experiment.ipynb`

### Prediction app

- [Saved LSTM](https://github.com/jayanthcsv/nextwordpredictor/blob/main/nextwordlstm.h5): `nextwordlstm.h5`
- [Saved tokenizer](https://github.com/jayanthcsv/nextwordpredictor/blob/main/tokenizer.pickle): `tokenizer.pickle`
- [Text input and results](https://github.com/jayanthcsv/nextwordpredictor/blob/main/app.py): `app.py`
- [Next-word prediction](https://github.com/jayanthcsv/nextwordpredictor/blob/main/app.py): `app.py`

### Other components

- **User**

## Connections

- Hamlet text → Text preprocessing: provides text (evidence: `README.md`)
- Text preprocessing → LSTM training: prepares sequences (evidence: `README.md`)
- LSTM training → Model evaluation: evaluated by (evidence: `README.md`)
- User → Text input and results: enters text (evidence: `app.py`)
- Text input and results → Next-word prediction: invokes (evidence: `app.py`)
- Next-word prediction → Saved tokenizer: loads and encodes (evidence: `app.py`)
- Next-word prediction → Saved LSTM: loads and predicts (evidence: `app.py`)
- Next-word prediction → Text input and results: returns word (evidence: `app.py`)
