# mohit6304/fableforgeai-storyengine architecture

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

- Interactive diagram: https://gitdiagram.com/mohit6304/fableforgeai-storyengine
- Repository: https://github.com/mohit6304/fableforgeai-storyengine

## Overview

##### Project type and purpose
- This is a Python-based, full-stack web application built with Streamlit.
- Purpose: Provide three AI-powered content-creation features—ChatBot, Story Generator, and Comic Video Generator—by orchestrating calls to Google’s Gemini AI models and HuggingFace services.

##### File structure
- Top level:
- main.py       → Streamlit entry point (routes UI requests to different features)
- gemini_utility.py → Wrapper module encapsulating all calls to Gemini-Pro, Gemini-Pro-Vision, embeddings, Gradio Client, and TTS
- requirements.txt → Declares Python dependencies (streamlit, openai, transformers, gradio-client, python-dotenv, etc.)
- .gitignore     → Standard exclusions (e.g., .env)
- There is no separate “frontend” folder because Streamlit handles the UI in main.py.

##### README for architectural clues
- Streamlit UI
- Business-logic layer (gemini_utility)
- External AI services (Gemini APIs, HuggingFace, Gradio video generator, TTS)
- Describes three feature modules (ChatBot, Story Generator, Comic Video Generator).

1. Streamlit Frontend (main.py UI layer)
2. Business Logic Layer (feature controllers inside main.py)
3. AI Service Wrapper (gemini_utility.py)
4. External Services:
– Gemini-Pro Text API
– Gemini-Pro-Vision Image API
– HuggingFace Embeddings API
– Gradio Client Video Generation
– Text-to-Speech Engine (e.g., pyttsx3 or external TTS API)
5. Configuration Store (.env)

- User interacts with Streamlit UI → triggers a feature controller in main.py
- Controller calls corresponding functions in gemini_utility → passes user input (text / image)
- gemini_utility forwards requests → External AI services
- AI services return responses → gemini_utility post-processes (e.g., assemble story, synthesize audio, build comic frames/video)
- Post-processed data flows back → Controller → UI renders text, audio player, or embeds video

c. Architectural patterns & design principles:
- MVC-style separation: Streamlit UI (View), main.py controllers (Controller), gemini_utility (Model/Service)
- Single Responsibility: Each feature (ChatBot/Story/Video) is a distinct flow in controllers calling generic wrapper methods
- External Service Abstraction: gemini_utility centralizes all API integrations
- Configuration Management: .env keys are loaded once at startup

d. Key technologies & libraries:
– Python 3.7+
– Streamlit for UI
– python-dotenv for environment configuration
– HTTP/REST clients (requests or openai SDK) for Gemini APIs
– HuggingFace transformers or API client for embeddings
– gradio-client for video generation
– Any TTS library or external service

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration"
        Env[".env Configuration"]:::config
        Req["requirements.txt"]:::config
    end

    Env -->|"loads variables"| Main
    Req -.->|"installs dependencies"| Main

    subgraph "Presentation Layer"
        Main["Streamlit Frontend\n(main.py)"]:::ui
    end

    subgraph "Application Logic"
        Chat["ChatBot Controller"]:::logic
        Story["Story Generator Controller"]:::logic
        Video["Comic Video Generator Controller"]:::logic
    end

    subgraph "Service Layer"
        Util["AI Service Wrapper\n(gemini_utility.py)"]:::service
    end

    subgraph "External AI Services"
        GPTText["Gemini-Pro Text API"]:::external
        GPTVision["Gemini-Pro-Vision Image API"]:::external
        HFEmbed["HuggingFace Embeddings API"]:::external
        GradioVid["Gradio Client Video Generation"]:::external
        TTS["Text-to-Speech Engine"]:::external
    end

    Main --> Chat
    Main --> Story
    Main --> Video

    Chat -->|"text input"| Util
    Story -->|"story prompt"| Util
    Video -->|"image + prompt"| Util

    Util --> GPTText
    Util --> GPTVision
    Util --> HFEmbed
    Util --> GradioVid
    Util --> TTS

    GPTText -->|"text response"| Util
    GPTVision -->|"image frames"| Util
    HFEmbed -->|"embeddings"| Util
    GradioVid -->|"video file"| Util
    TTS -->|"audio file"| Util

    Util --> Chat
    Util --> Story
    Util --> Video

    click Main "https://github.com/mohit6304/fableforgeai-storyengine/blob/main/main.py"
    click Util "https://github.com/mohit6304/fableforgeai-storyengine/blob/main/gemini_utility.py"
    click Req "https://github.com/mohit6304/fableforgeai-storyengine/blob/main/requirements.txt"
    click Env "https://github.com/mohit6304/fableforgeai-storyengine/blob/main/.env"

    classDef config fill:#eef,stroke:#333;
    classDef ui fill:#bbdefb,stroke:#1e88e5,color:#000;
    classDef logic fill:#c8e6c9,stroke:#388e3c,color:#000;
    classDef service fill:#a5d6a7,stroke:#2e7d32,color:#000;
    classDef external fill:#ffe0b2,stroke:#fb8c00,color:#000;
```
