# deepshikha-chhaperia/green-thread-app architecture

> Architecture diagram of the GitHub repository deepshikha-chhaperia/green-thread-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deepshikha-chhaperia/green-thread-app
- Repository: https://github.com/deepshikha-chhaperia/green-thread-app

## Overview

##### Project type and purpose
- This is a full-stack, single-repo Python web application (“Green Thread”) built with Streamlit for the frontend and a lightweight Python backend.
- Purpose: Provide four AI-powered sustainable-fashion tools (Design Studio, Fabric Advisor, Production Optimizer, Textile Generator) plus a sustainability dashboard, combining local AI models (Stable Diffusion, ResNet50) with external APIs (Google Gemini).

##### File structure
- Top level:
- main.py – Entry point launching the Streamlit UI and routing between feature modules.
- design_studio.py, fabric_analyzer.py, sustainable_production_optimizer.py, sustainable_textile_generator.py, sustainability_dashboard.py – Business-logic modules for each feature.
- qr_code_id.py – Utility for generating QR code identifiers for designs.
- config.toml – Streamlit configuration (theme, server).
- requirements.txt & packages.txt – Python dependencies.
- .env.example – Placeholder for GEMINI_API_KEY and HF_API_TOKEN; loaded via python-dotenv.
- .devcontainer/ – VS Code dev-container configuration for reproducible environments.
- Implicit architectural choices:
- Monolithic Python service with modular feature scripts.
- Use of in-process function calls for AI tasks and optional Flask endpoints (per README) for API serving.
- SQLite3 as embedded database, Pandas for data manipulation.
- Caching (Streamlit’s @st.cache_resource, functools.lru_cache) and retry/backoff patterns for robustness.

##### README for insights
- Confirms the tech stack: Streamlit, Flask, SQLite3, Pandas, Stable Diffusion, ResNet50, Google Gemini.
- Highlights caching, attention slicing, exponential backoff—all important optimization layers to represent.
- Mentions a flowchart showing how user inputs traverse the system. Use that as a reference to produce your own.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users and Interface
    User["User"]:::external
    Browser["Browser"]:::external
    User --> Browser
    Browser --> Streamlit["Streamlit Frontend"]:::frontend

    subgraph "Frontend Layer"
        Streamlit
    end

    %% Business Logic Modules
    subgraph "Business Logic Modules"
        DesignStudio["Design Studio Module"]:::logic
        FabricAdvisor["Fabric Advisor Module"]:::logic
        ProductionOptimizer["Production Optimizer Module"]:::logic
        TextileGenerator["Textile Generator Module"]:::logic
        Dashboard["Sustainability Dashboard Module"]:::logic
        QRCodeUtil["QR Code Utility"]:::util
    end

    Streamlit --> DesignStudio
    Streamlit --> FabricAdvisor
    Streamlit --> ProductionOptimizer
    Streamlit --> TextileGenerator
    Streamlit --> Dashboard
    Streamlit --> QRCodeUtil

    %% AI Engines & Libraries
    subgraph "AI Engines & Libraries"
        StableDiff["Stable Diffusion"]:::ai
        ResNet["ResNet50"]:::ai
    end

    DesignStudio --> StableDiff
    TextileGenerator --> StableDiff
    FabricAdvisor --> ResNet

    %% External Services
    subgraph "External Services"
        Gemini["Google Gemini API"]:::external
    end

    Dashboard --> Gemini
    ProductionOptimizer --> Gemini

    %% Data, Caching & Config
    subgraph "Data & Config & Utilities"
        DB["SQLite3 Database"]:::data
        CacheRetry["Caching & Retry Layers"]:::util
        Config["Streamlit Config (config.toml)"]:::data
        Env["Environment Template (.env.example)"]:::data
        Req["Dependencies (requirements.txt)"]:::data
        Pkg["Packages (packages.txt)"]:::data
        DevDir["Dev Container (.devcontainer/)"]:::data
        DevFile["Dev Container Settings"]:::data
    end

    DesignStudio --> DB
    FabricAdvisor --> DB
    ProductionOptimizer --> DB
    Dashboard --> DB
    QRCodeUtil --> DB

    DesignStudio --> CacheRetry
    FabricAdvisor --> CacheRetry
    ProductionOptimizer --> CacheRetry
    TextileGenerator --> CacheRetry
    Dashboard --> CacheRetry

    Streamlit --> Config
    Streamlit --> Env
    Streamlit --> Req
    Streamlit --> Pkg
    Streamlit --> DevDir
    DevDir --> DevFile

    %% Click Events
    click Streamlit "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/main.py"
    click DesignStudio "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/design_studio.py"
    click FabricAdvisor "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/fabric_analyzer.py"
    click ProductionOptimizer "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/sustainable_production_optimizer.py"
    click TextileGenerator "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/sustainable_textile_generator.py"
    click Dashboard "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/sustainability_dashboard.py"
    click QRCodeUtil "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/qr_code_id.py"
    click Config "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/config.toml"
    click Env "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/.env.example"
    click Req "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/requirements.txt"
    click Pkg "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/packages.txt"
    click DevDir "https://github.com/deepshikha-chhaperia/green-thread-app/tree/main/.devcontainer/"
    click DevFile "https://github.com/deepshikha-chhaperia/green-thread-app/blob/main/.devcontainer/devcontainer.json"

    %% Styles
    classDef frontend fill:#D0EBFF,stroke:#1E90FF,stroke-width:2px
    classDef logic fill:#D4F8E8,stroke:#2E8B57,stroke-width:2px
    classDef ai fill:#FFE5B4,stroke:#FF8C00,stroke-width:2px
    classDef external fill:#FFD1DC,stroke:#FF1493,stroke-width:2px
    classDef data fill:#FFF5BA,stroke:#DAA520,stroke-width:2px
    classDef util fill:#E0E0E0,stroke:#808080,stroke-width:2px
```
