# satishjey/ai-text-generation-studio architecture

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

- Interactive diagram: https://gitdiagram.com/satishjey/ai-text-generation-studio
- Repository: https://github.com/satishjey/ai-text-generation-studio

## Overview

AI Text Generation Studio is a local Streamlit chat application backed by Gemini. A user submits a message through the chat screen; the app validates it, keeps the conversation in session state, and asks the generator to stream a reply using the thread’s history. The generator handles capacity retries and model fallback, then returns reply text and metadata for display. Configuration supplies the model choices, limits, thinking levels, and API key. The README documents these behaviors; generator internals are only partially excerpted, so unshown implementation details are not expanded.

Main entry points: [`app.py`](https://github.com/satishjey/ai-text-generation-studio/blob/main/app.py) (Streamlit chat), [`src/generator.py`](https://github.com/satishjey/ai-text-generation-studio/blob/main/src/generator.py) (Streaming and recovery), [`src/chat.py`](https://github.com/satishjey/ai-text-generation-studio/blob/main/src/chat.py) (Message checks and history), [`src/config.py`](https://github.com/satishjey/ai-text-generation-studio/blob/main/src/config.py) (Models and configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_streamlit_app["Streamlit chat<br/>[app.py]"]
end

subgraph group_conversation["Conversation"]
  node_session_thread["Session thread<br/>[app.py]"]
  node_chat_history["Message checks and history<br/>[chat.py]"]
end

subgraph group_generation["Generation and settings"]
  node_app_config["Models and configuration<br/>[config.py]"]
  node_text_generator["Streaming and recovery<br/>[generator.py]"]
end

node_user(("Chat user"))
node_gemini{{"Gemini Interactions API"}}

node_user -->|"submits message"| node_streamlit_app
node_streamlit_app -->|"validates message"| node_chat_history
node_streamlit_app -->|"updates thread"| node_session_thread
node_streamlit_app -->|"clears thread"| node_session_thread
node_session_thread -->|"renders messages"| node_streamlit_app
node_streamlit_app -->|"requests stream"| node_text_generator
node_text_generator -->|"builds API history"| node_chat_history
node_chat_history -->|"uses message limit"| node_app_config
node_streamlit_app -->|"loads settings"| node_app_config
node_text_generator -->|"uses generation settings"| node_app_config
node_text_generator -->|"streams generation"| node_gemini
node_gemini -->|"returns reply and usage"| node_text_generator
node_text_generator -->|"yields reply events"| node_streamlit_app
node_text_generator -->|"retries and falls back"| node_gemini

click node_streamlit_app "https://github.com/satishjey/ai-text-generation-studio/blob/main/app.py"
click node_session_thread "https://github.com/satishjey/ai-text-generation-studio/blob/main/app.py"
click node_chat_history "https://github.com/satishjey/ai-text-generation-studio/blob/main/src/chat.py"
click node_app_config "https://github.com/satishjey/ai-text-generation-studio/blob/main/src/config.py"
click node_text_generator "https://github.com/satishjey/ai-text-generation-studio/blob/main/src/generator.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_streamlit_app,node_user toneBlue
class node_session_thread,node_chat_history toneAmber
class node_app_config,node_text_generator,node_gemini toneMint
```

## Components

### Chat interface

- [Streamlit chat](https://github.com/satishjey/ai-text-generation-studio/blob/main/app.py): `app.py`

### Conversation

- [Session thread](https://github.com/satishjey/ai-text-generation-studio/blob/main/app.py): `app.py`
- [Message checks and history](https://github.com/satishjey/ai-text-generation-studio/blob/main/src/chat.py): `src/chat.py`

### Generation and settings

- [Models and configuration](https://github.com/satishjey/ai-text-generation-studio/blob/main/src/config.py): `src/config.py`
- [Streaming and recovery](https://github.com/satishjey/ai-text-generation-studio/blob/main/src/generator.py): `src/generator.py`

### Other components

- **Chat user**
- **Gemini Interactions API**

## Connections

- Chat user → Streamlit chat: submits message (evidence: `app.py`)
- Streamlit chat → Message checks and history: validates message (evidence: `app.py`)
- Streamlit chat → Session thread: updates thread (evidence: `app.py`)
- Streamlit chat → Session thread: clears thread (evidence: `app.py`)
- Session thread → Streamlit chat: renders messages (evidence: `app.py`)
- Streamlit chat → Streaming and recovery: requests stream (evidence: `app.py`)
- Streaming and recovery → Message checks and history: builds API history (evidence: `README.md`)
- Message checks and history → Models and configuration: uses message limit (evidence: `src/chat.py`)
- Streamlit chat → Models and configuration: loads settings (evidence: `app.py`)
- Streaming and recovery → Models and configuration: uses generation settings (evidence: `src/generator.py`)
- Streaming and recovery → Gemini Interactions API: streams generation (evidence: `src/generator.py`)
- Gemini Interactions API → Streaming and recovery: returns reply and usage (evidence: `src/generator.py`)
- Streaming and recovery → Streamlit chat: yields reply events (evidence: `app.py`)
- Streaming and recovery → Gemini Interactions API: retries and falls back (evidence: `README.md`)
