# azizdeveci/lstm-text-generation architecture

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

- Interactive diagram: https://gitdiagram.com/azizdeveci/lstm-text-generation
- Repository: https://github.com/azizdeveci/lstm-text-generation

## Overview

This is a Turkish next-word prediction and text-generation application: users enter a seed phrase and requested word count, then receive generated text through a FastAPI endpoint. The runtime path runs from the browser interface through the API route to the LSTM service, which tokenizes the prompt and repeatedly predicts the next word. A separate training stage builds the model from the sentence corpus. The README also describes Swagger and CORS capabilities; their wiring is visible in the app entry point. The template itself was not sampled, so the browser-to-endpoint interaction follows the README’s description.

Main entry points: [`app/main.py`](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/main.py) (FastAPI app), [`app/routes/text_generation.py`](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/routes/text_generation.py) (Generation endpoint), [`app/services/lstm_service.py`](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/services/lstm_service.py) (LSTM inference), [`train_lstm.py`](https://github.com/azizdeveci/lstm-text-generation/blob/main/train_lstm.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_page["Generator page<br/>[index.html]"]
  node_styles["Interface styles<br/>[style.css]"]
end

subgraph group_api["API"]
  node_main["FastAPI app<br/>[main.py]"]
  node_route["Generation endpoint<br/>[text_generation.py]"]
  node_request["Text request<br/>[text_request.py]"]
  node_swagger["Swagger docs<br/>[main.py]"]
  node_cors["CORS middleware<br/>[main.py]"]
end

subgraph group_generation["Text generation"]
  node_service["LSTM inference<br/>[lstm_service.py]"]
end

subgraph group_training["Model training"]
  node_corpus["Sentence corpus<br/>[sentences.txt]"]
  node_trainer["Model training<br/>[train_lstm.py]"]
end

node_user(("Browser user"))
node_model["Trained model"]

node_user -->|"opens app"| node_main
node_main -->|"renders page"| node_page
node_page -->|"uses styles"| node_styles
node_user -->|"submits prompt"| node_route
node_route -->|"validates input"| node_request
node_route -->|"requests generation"| node_service
node_service -->|"reads sentences"| node_corpus
node_service -->|"loads model"| node_model
node_trainer -->|"reads sentences"| node_corpus
node_trainer -->|"trains and saves"| node_model
node_user -.->|"views API docs"| node_swagger
node_main -->|"configures"| node_cors

click node_main "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/main.py"
click node_page "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/templates/index.html"
click node_styles "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/static/style.css"
click node_route "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/routes/text_generation.py"
click node_request "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/models/text_request.py"
click node_service "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/services/lstm_service.py"
click node_corpus "https://github.com/azizdeveci/lstm-text-generation/blob/main/data/sentences.txt"
click node_trainer "https://github.com/azizdeveci/lstm-text-generation/blob/main/train_lstm.py"
click node_swagger "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/main.py"
click node_cors "https://github.com/azizdeveci/lstm-text-generation/blob/main/app/main.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_page,node_styles,node_user toneBlue
class node_main,node_route,node_request,node_swagger,node_cors toneAmber
class node_service toneMint
class node_corpus,node_trainer toneRose
class node_model toneIndigo
```

## Components

### Web interface

- [Generator page](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/templates/index.html): `app/templates/index.html`
- [Interface styles](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/static/style.css): `app/static/style.css`

### API

- [FastAPI app](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/main.py): `app/main.py`
- [Generation endpoint](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/routes/text_generation.py): `app/routes/text_generation.py`
- [Text request](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/models/text_request.py): `app/models/text_request.py`
- [Swagger docs](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/main.py): `app/main.py`
- [CORS middleware](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/main.py): `app/main.py`

### Text generation

- [LSTM inference](https://github.com/azizdeveci/lstm-text-generation/blob/main/app/services/lstm_service.py): `app/services/lstm_service.py`

### Model training

- [Sentence corpus](https://github.com/azizdeveci/lstm-text-generation/blob/main/data/sentences.txt): `data/sentences.txt`
- [Model training](https://github.com/azizdeveci/lstm-text-generation/blob/main/train_lstm.py): `train_lstm.py`

### Other components

- **Browser user**
- **Trained model**

## Connections

- Browser user → FastAPI app: opens app
- FastAPI app → Generator page: renders page
- Generator page → Interface styles: uses styles
- Browser user → Generation endpoint: submits prompt
- Generation endpoint → Text request: validates input
- Generation endpoint → LSTM inference: requests generation
- LSTM inference → Sentence corpus: reads sentences
- LSTM inference → Trained model: loads model
- Model training → Sentence corpus: reads sentences
- Model training → Trained model: trains and saves
- Browser user → Swagger docs: views API docs
- FastAPI app → CORS middleware: configures
