# kratoossss/text-to-image-converter architecture

> Architecture diagram of the GitHub repository kratoossss/text-to-image-converter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kratoossss/text-to-image-converter
- Repository: https://github.com/kratoossss/text-to-image-converter

## Overview

##### Project type and purpose
- This is a single-container Streamlit web application (“PromptToImage Converter”) that exposes a browser-based UI, orchestrates a local LLM module for prompt expansion, invokes the Stability AI image-generation API, and returns downloadable images.

##### File structure
- Top level:
- .devcontainer/ – VS Code dev container config
- README.md – documentation
- requirements.txt – Python dependencies
- app/
- main.py – Streamlit UI entry-point and request handler
- llm_utils.py – encapsulates llama-cpp-python calls (prompt expansion)
- No separate “frontend” folder: Streamlit serves both UI and backend code.

##### README for additional insights
- The app loads environment variable STABILITY_API_KEY, lets the user pick an art style, optionally expands the prompt via Llama, then calls the Stability AI REST API to generate images.
- Key technologies: Python ≥3.8, Streamlit, llama-cpp-python, requests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["User Browser"]:::frontend

    %% Streamlit App Components
    subgraph "Streamlit App"
        direction TB
        UI["UI Layer<br/>(text input, style selector)"]:::internal
        Controller["Controller / Orchestrator"]:::internal
        LLM["Prompt Expansion Module<br/>(llm_utils.py)"]:::internal
        Download["Download Handler"]:::internal
        EnvVar["Env Var<br/>STABILITY_API_KEY"]:::infra
    end

    %% External Service
    External["Stability AI Service"]:::external

    %% Runtime Environment
    subgraph "Runtime Environment"
        direction TB
        DC[".devcontainer"]:::infra
        DCjson["devcontainer.json"]:::infra
    end

    %% Project Files
    subgraph "Project Files"
        direction TB
        Doc["README.md"]:::infra
        Req["requirements.txt"]:::infra
    end

    %% Data Flow
    Client -->|"HTTP/WS"| UI
    UI -->|"submit prompt"| Controller
    Controller -->|"function call"| LLM
    LLM -->|"I/O to local model files"| ModelFiles["Local Model Files"]:::infra
    Controller -->|"HTTPS POST /generate-image"| External
    External -->|"image data"| Controller
    Controller -->|"render + link"| Download
    Download -->|"HTTP/WS"| Client
    DC -->|"hosts"| Controller

    %% Click Events
    click Controller "https://github.com/kratoossss/text-to-image-converter/blob/main/app/main.py"
    click LLM "https://github.com/kratoossss/text-to-image-converter/blob/main/app/llm_utils.py"
    click DC "https://github.com/kratoossss/text-to-image-converter/blob/main/.devcontainer"
    click DCjson "https://github.com/kratoossss/text-to-image-converter/blob/main/.devcontainer/devcontainer.json"
    click Doc "https://github.com/kratoossss/text-to-image-converter/blob/main/README.md"
    click Req "https://github.com/kratoossss/text-to-image-converter/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#8FBC8F,stroke:#333,stroke-width:1px;
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
