# barun-saha/slide-deck-ai architecture

> Architecture diagram of the GitHub repository barun-saha/slide-deck-ai, 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/barun-saha/slide-deck-ai
- Repository: https://github.com/barun-saha/slide-deck-ai

## Overview

##### Project type and purpose
- SlideDeck AI is a Streamlit‐based web application that co-creates PowerPoint slide decks using Generative AI.
- It provides a user interface, orchestrates calls to LLM providers (online or offline via Ollama), fetches images from Pexels, and uses python-pptx to build/download presentations.

##### File structure
- Top-level entrypoint: app.py (Streamlit UI + controller)
- Configuration: .env.example, global_config.py, .streamlit/config.toml
- Helpers (business logic):
- helpers/llm_helper.py (wraps LLM calls, online/offline)
- helpers/image_search.py (Pexels integration)
- helpers/pptx_helper.py (python-pptx slide generation)
- helpers/text_helper.py, file_manager.py, icons_embeddings.py
- Static assets & templates:
- prompts/ (LLM prompt templates)
- pptx_templates/ (PowerPoint templates)
- examples/ (input/output JSON samples)
- Output/history: slides_for_this_project_by_this_project/
- Dependencies: requirements.txt

##### README for additional insights
- Describes a 2-phase process: initial JSON from LLM → optional user refinement → PPTX generation
- Supports multiple LLM backends (Azure, Hugging Face, Google, Cohere, OpenRouter, Together, Ollama)
- Uses Pexels API for image download

##### Main components
a. Frontend (Streamlit UI)
- Input form for topic or PDF
- LLM provider selection & API key management
- Refinement input area
- Download button for PPTX
b. Controller (app.py + global_config.py)
- Reads user input & environment variables
- Invokes llm_helper, image_search, pptx_helper
- Manages history of instructions
c. Helper modules (business logic)
- LLM Helper: routes to online or Ollama
- Image Search: queries Pexels API based on keywords
- PPTX Helper: consumes structured JSON + images + template → .pptx
d. Data & Templates
e. External Services
- LLM APIs (Azure, HF, Google, Cohere, etc.)
- Pexels Image API
- Ollama (optional offline LLM)

##### Relationships & interactions
- User → Streamlit UI → Controller
- Controller → llm_helper → LLM Provider → JSON response
- Controller → image_search → Pexels → image files
- Controller → pptx_helper (+ JSON + images + template) → generates PPTX
- Controller → Streamlit UI (download link)
- Refinement loop: User → UI → Controller → llm_helper (with history) → updated JSON → pptx rebuild

##### Architectural patterns & design principles
- Layered architecture: UI layer / controller layer / service layer / data layer
- Separation of concerns: each helper module has a single responsibility
- Plugin-style support for multiple LLM providers
- Config driven: environment variables & global_config.py
- Resource organization: static assets in dedicated folders

##### Elements
- Clear labels: “Streamlit UI,” “LLM Helper,” “PPTX Helper,” etc.
- Rounded rectangles for components
- Clouds for external services (LLM APIs, Pexels)

##### Detail without over-splitting
- Template and asset folders as a single “Static Resources” store
- Both initial generation and refinement phases

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% UI Layer
  subgraph "UI Layer"
    UI["Streamlit UI & Controller"]:::ui
  end

  %% Business Logic
  subgraph "Business Logic"
    LLM["LLM Helper"]:::logic
    IMG["Image Search"]:::logic
    PPTX["PPTX Helper"]:::logic
    FM["File Manager"]:::logic
    ICONS_EMB["Icons Embeddings"]:::logic
    TEXT["Text Helper"]:::logic
  end

  %% Data & Templates
  subgraph "Data & Templates"
    PROMPTS["Prompt Templates"]:::data
    PPT_TEMPL["PowerPoint Templates"]:::data
    ICONS["Icon Assets"]:::data
    FILE_EMB["File Embeddings Store"]:::data
    EXAMPLES["Example I/O Samples"]:::data
    HISTORY["Generated Slide History"]:::data
    REQ["requirements.txt"]:::data
  end

  %% Configuration
  subgraph "Configuration"
    ENV[".env.example"]:::data
    GCFG["global_config.py"]:::data
    SCONF[".streamlit/config.toml"]:::data
    STR["strings.json"]:::data
  end

  %% External Services
  subgraph "External Services"
    LLMAPI["LLM APIs (Azure, HF, Google, etc.)"]:::ext
    OLLAMA["Ollama (Offline LLM)"]:::ext
    PEXELS["Pexels Image API"]:::ext
  end

  %% Data Flows
  User-->UI
  UI-->GCFG
  UI-->LLM
  UI-->IMG
  UI-->PPTX
  UI-->REQ
  LLM-->LLMAPI
  LLM-->OLLAMA
  IMG-->PEXELS
  PPTX-->PROMPTS
  PPTX-->PPT_TEMPL
  PPTX-->ICONS
  PPTX-->FILE_EMB
  PPTX-->EXAMPLES
  PPTX-->HISTORY
  LLM-->|"JSON response"|UI
  UI-->|"refine JSON"|LLM
  UI-->|"download PPTX"|HISTORY

  %% Click Events
  click UI "https://github.com/barun-saha/slide-deck-ai/blob/main/app.py"
  click ENV "https://github.com/barun-saha/slide-deck-ai/blob/main/.env.example"
  click GCFG "https://github.com/barun-saha/slide-deck-ai/blob/main/global_config.py"
  click SCONF "https://github.com/barun-saha/slide-deck-ai/blob/main/.streamlit/config.toml"
  click LLM "https://github.com/barun-saha/slide-deck-ai/blob/main/helpers/llm_helper.py"
  click IMG "https://github.com/barun-saha/slide-deck-ai/blob/main/helpers/image_search.py"
  click PPTX "https://github.com/barun-saha/slide-deck-ai/blob/main/helpers/pptx_helper.py"
  click FM "https://github.com/barun-saha/slide-deck-ai/blob/main/helpers/file_manager.py"
  click ICONS_EMB "https://github.com/barun-saha/slide-deck-ai/blob/main/helpers/icons_embeddings.py"
  click TEXT "https://github.com/barun-saha/slide-deck-ai/blob/main/helpers/text_helper.py"
  click PROMPTS "https://github.com/barun-saha/slide-deck-ai/tree/main/prompts/"
  click PPT_TEMPL "https://github.com/barun-saha/slide-deck-ai/tree/main/pptx_templates/"
  click ICONS "https://github.com/barun-saha/slide-deck-ai/tree/main/icons/"
  click FILE_EMB "https://github.com/barun-saha/slide-deck-ai/tree/main/file_embeddings/"
  click EXAMPLES "https://github.com/barun-saha/slide-deck-ai/tree/main/examples/"
  click HISTORY "https://github.com/barun-saha/slide-deck-ai/tree/main/slides_for_this_project_by_this_project/"
  click REQ "https://github.com/barun-saha/slide-deck-ai/blob/main/requirements.txt"
  click STR "https://github.com/barun-saha/slide-deck-ai/blob/main/strings.json"

  %% Styles
  classDef ui fill:#D0E7FF,stroke:#333,stroke-width:1px
  classDef logic fill:#DFF5D1,stroke:#333,stroke-width:1px
  classDef data fill:#FFF5B1,stroke:#333,stroke-width:1px
  classDef ext fill:#FFD8A8,stroke:#333,stroke-width:1px
```
