# nikhilsetiya/prism architecture

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

- Interactive diagram: https://gitdiagram.com/nikhilsetiya/prism
- Repository: https://github.com/nikhilsetiya/prism

## Overview

##### Project type and purpose
- This is a full-stack asset-generation application (CLI + Streamlit UI) that automates the creation of localized marketing assets using an AI image service (OpenAI DALL-E).
- One “brief” describes products, locales, ratios → pipeline → a batch of finished images.

##### File structure
Top-level files and folders:
- run_prism.py, create_campaign.py, validate_setup.py – entry points for CLI workflows
- app.py + .streamlit/ – Streamlit UI interface
- config.yaml – global configuration for quality, governance, workers, rate limits, post-processing
- src/ – core modules implementing each pipeline stage
– pipeline.py orchestrates the sequence
– governance.py, asset_manager.py, image_generator.py, compositor.py, post_processor.py, storage.py, utils.py, models.py, aspect_ratio_processor.py, localizer.py
- assets/ – brand and input placeholders
- test_campaigns_package/ – sample briefs and data for end-to-end testing
- requirements.txt – Python dependencies

##### README for additional insights
Brief → Governance → Asset Manager → Generator → Compositor → Post-Process → Output
- Mentions parallel execution, rate limiting, cache-first storage, local (or cloud) storage
- Dual interface: CLI and Streamlit UI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "User Interfaces"
        direction TB
        UI_CLI["UI – CLI\n(run_prism.py,\ncreate_campaign.py,\nvalidate_setup.py)"]:::ui
        UI_Streamlit["UI – Streamlit\n(app.py,\n.ui/gallery.py,\n.ui/reports.py,\n.ui/uploader.py)"]:::ui
    end

    %% Configuration
    Config["Configuration\n(config.yaml,\nSETUP_GUIDE.md)"]:::config

    %% Pipeline Layer
    subgraph "Pipeline Orchestrator"
        direction TB
        Pipeline["Pipeline Orchestrator\n(src/pipeline.py)"]:::pipeline
        Governance["Governance Module\n(src/governance.py)"]:::pipeline
        AssetManager["Asset Manager\n(src/asset_manager.py)\n(cache-first lookup)"]:::pipeline
        ImageGenerator["Image Generator\n(src/image_generator.py)\n(parallel workers,\nrate limit=45 req/min)"]:::pipeline
        Compositor["Compositor\n(src/compositor.py)"]:::pipeline
            subgraph "Compositor Subcomponents"
                AspectRatio["Aspect Ratio Processor\n(src/aspect_ratio_processor.py)"]:::pipeline
            end
        PostProcessor["Post-Processor\n(src/post_processor.py)\n(film grain intensity)"]:::pipeline
    end

    %% Storage & Data
    subgraph "Storage & Data"
        direction TB
        Storage["Storage Layer\n(src/storage.py)"]:::datastore
        Assets["Assets Repositories\n(assets/brand/, assets/input/)"]:::datastore
        TestData["Test Data\n(test_campaigns_package/)"]:::datastore
    end

    %% External Services
    OpenAI["OpenAI DALL-E API\n(external service)"]:::external

    %% Connections
    UI_CLI -->|loads config,\nsubmits brief JSON| Config
    UI_Streamlit -->|loads config,\nsubmits brief JSON| Config
    Config -->|provides parameters| Pipeline
    Pipeline -->|validates brief| Governance
    Governance -->|valid| AssetManager
    AssetManager -->|cache hits| Storage
    AssetManager -->|cache misses,\nenqueues jobs| ImageGenerator
    ImageGenerator -->|generated images| Compositor
    Compositor -->|uses aspect ratio| AspectRatio
    Compositor -->|composited images| PostProcessor
    PostProcessor -->|final assets| Storage
    Storage -->|serves assets| UI_Streamlit
    ImageGenerator -->|API calls| OpenAI

    %% Click Events
    click UI_CLI "https://github.com/nikhilsetiya/prism/blob/main/run_prism.py"
    click UI_Streamlit "https://github.com/nikhilsetiya/prism/blob/main/app.py"
    click Config "https://github.com/nikhilsetiya/prism/blob/main/config.yaml"
    click Pipeline "https://github.com/nikhilsetiya/prism/blob/main/src/pipeline.py"
    click Governance "https://github.com/nikhilsetiya/prism/blob/main/src/governance.py"
    click AssetManager "https://github.com/nikhilsetiya/prism/blob/main/src/asset_manager.py"
    click ImageGenerator "https://github.com/nikhilsetiya/prism/blob/main/src/image_generator.py"
    click Compositor "https://github.com/nikhilsetiya/prism/blob/main/src/compositor.py"
    click AspectRatio "https://github.com/nikhilsetiya/prism/blob/main/src/aspect_ratio_processor.py"
    click PostProcessor "https://github.com/nikhilsetiya/prism/blob/main/src/post_processor.py"
    click Storage "https://github.com/nikhilsetiya/prism/blob/main/src/storage.py"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366d6,stroke-width:2px;
    classDef config fill:#FFF4D0,stroke:#DAA520,stroke-width:2px;
    classDef pipeline fill:#DFFFD0,stroke:#228B22,stroke-width:2px;
    classDef datastore fill:#FFF0D0,stroke:#DA8A00,stroke-width:2px;
    classDef external fill:#FFD0D0,stroke:#d64545,stroke-width:2px;
```
