# rohithcherukuri816/ai-powered-creative-intelligence-platform architecture

> Architecture diagram of the GitHub repository rohithcherukuri816/ai-powered-creative-intelligence-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohithcherukuri816/ai-powered-creative-intelligence-platform
- Repository: https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform

## Overview

##### Project Type and Purpose
- This is a full-stack, monorepo web application (“AI-Powered Creative Intelligence Platform”) that lets users sketch on a canvas in the browser, send their doodles plus a text prompt to an AI‐powered backend, and receive back stylized, high-quality images generated via ControlNet + Stable Diffusion (with a PIL/Pillow fallback). There is also an alternate “colab_backend” implementation for running the same inference pipeline in Google Colab.

##### High-Level File Structure Analysis
- Root
– package.json, pnpm-workspace.yaml: Defines a workspace that includes “frontend” and “backend”
– scripts/: Setup helpers for installing models and env files
- frontend/
– React + Vite + Tailwind project
– src/components: DrawingCanvas, PromptInput, GeneratedImageCard, etc.
– api.js: Fetch wrapper for talking to backend
- backend/
– FastAPI application (main.py) with routes in routes/design.py
– config/: ai_config.py for model settings
– utils/image_processor.py: orchestrates preprocessing, AI call, fallback
– requirements.txt: PyTorch, FastAPI, Pillow, ControlNet/Stable Diffusion packages
- colab_backend/
– Alternate lightweight FastAPI (or Flask) app plus Jupyter notebook for Colab demos
- Dev tooling
– dev.js, setup scripts, environment examples

##### Key Components
1. Browser / User Interface
- React App (DrawingCanvas, PromptInput, etc.)
2. Frontend Dev Server
- Vite dev server (port 5173)
3. API Layer
- REST endpoints in FastAPI (port 8000)
4. Core Backend
- main.py → routes/design.py
- image_processor pipeline
- config (ai_config.py)
5. AI Inference
- ControlNet + Stable Diffusion (via PyTorch)
- PIL/Pillow fallback path
6. Optional Colab Microservice
- colab_backend/app.py + recognizer/processor modules
7. External Services
- Hugging Face model hub (for token-authenticated model downloads)
8. Local File Store (temporary images) or In-Memory Buffers

##### Relationships and Data Flow
- User draws on canvas in React → on “Generate” button, api.js posts image data + prompt to FastAPI `/design` route
- FastAPI route invokes image_processor:
- Applies pre-processing (skeleton extraction),
- Routes to AI inference (ControlNet + Stable Diffusion) or fallback
- Returns generated image URL/base64 back to frontend
- Frontend receives response, updates UI (GeneratedImageCard)
- Model downloads from Hugging Face occur during backend startup or scripts/setup-ai.py

##### Architectural Patterns & Principles
- Monorepo with clear separation: frontend vs. backend
- Pipeline pattern in backend image processing (preprocess → AI → postprocess)
- Config-driven design (ai_config.py + .env files) for environment flexibility (CPU vs GPU)
- Microservice option: colab_backend for demonstration or lightweight deployment

##### Putting It All Together
Tier 1 (Client): Browser/React → Tier 2 (API): FastAPI → Tier 3 (Processing): AI Engine + Fallback + External Model Hub
- Nest colab_backend as a side‐branch under Tier 3 for optional demo use
- Data flows (POST, processing pipeline, GET/response)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        direction TB
        UI["Browser / React UI"]:::frontend
        VITE["Vite Dev Server\n(port 5173)"]:::frontend
        API_CLIENT["API Wrapper (api.js)"]:::frontend
    end

    subgraph "Backend Layer"
        direction TB
        API["FastAPI Application\n(main.py)"]:::backend
        ROUTE["Routes: design.py"]:::backend
        CONFIG["AI Config\n(ai_config.py)"]:::backend
        REQ["Requirements.txt"]:::backend
        PROCESS["Image Processing Pipeline\n(utils/image_processor.py)"]:::backend
    end

    subgraph "AI Processing Layer"
        direction TB
        ENGINE["AI Engine\n(ControlNet + Stable Diffusion)"]:::ai
        FALLBACK["Fallback Processor\n(PIL/Pillow)"]:::ai
        HUB["External Model Hub\n(Hugging Face)"]:::external
        SETUP["Model Setup Script\n(setup-ai.py)"]:::external
    end

    subgraph "Colab Microservice" style dashed
        direction TB
        COLAB_APP["colab_backend/app.py"]:::backend
        COLAB_PROC["colab_backend/processor.py"]:::backend
        COLAB_RECOG["colab_backend/recognizer.py"]:::backend
        COLAB_NOTE["Colab Backend.ipynb"]:::backend
    end

    VITE --> UI
    UI --> API_CLIENT
    API_CLIENT -->|"POST /design"| API
    API --> ROUTE
    ROUTE --> PROCESS
    PROCESS --> ENGINE
    PROCESS --> FALLBACK
    API -->|"Response: image"| API_CLIENT
    API -->|"Startup download"| HUB
    SETUP --> HUB
    PROCESS -->|"loads config"| CONFIG
    PROCESS -->|"requires"| REQ
    UI -.->|Optional POST /design| COLAB_APP

    click UI "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/tree/main/frontend/src/components"
    click VITE "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/frontend/vite.config.js"
    click API_CLIENT "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/frontend/src/api.js"
    click API "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/backend/main.py"
    click ROUTE "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/backend/routes/design.py"
    click CONFIG "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/backend/config/ai_config.py"
    click PROCESS "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/backend/utils/image_processor.py"
    click REQ "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/backend/requirements.txt"
    click SETUP "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/scripts/setup-ai.py"
    click COLAB_APP "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/colab_backend/app.py"
    click COLAB_PROC "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/colab_backend/processor.py"
    click COLAB_RECOG "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/colab_backend/recognizer.py"
    click COLAB_NOTE "https://github.com/rohithcherukuri816/ai-powered-creative-intelligence-platform/blob/main/colab_backend/Colab_Backend.ipynb"

    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef ai fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A
    classDef external fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
```
