# martin226/vibe-draw architecture

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

- Interactive diagram: https://gitdiagram.com/martin226/vibe-draw
- Repository: https://github.com/martin226/vibe-draw

## Overview

##### Project Type and Purpose
- The frontend is built with Next.js, React, and Three.js for responsive UI and high-quality 3D rendering, whereas the backend uses Python (FastAPI), Celery, and Redis to manage API endpoints and handle asynchronous AI processing tasks.

##### Analyzing the File Structure
- Top-Level Separation: The project is clearly divided into two main directories:
- frontend: Contains the Next.js-based application, UI components (including those for interfacing with Three.js), layout files, and supporting libraries.
- backend: Contains the Python server-side code, a FastAPI application, API routes, configuration files, Celery tasks (in modules like cerebras_tasks.py, claude_tasks.py, gemini_tasks.py), and Docker orchestration files (e.g., Dockerfile, docker-compose.yml).
- “api” for API models and routes – handling incoming requests.
- “core” for configuration, the Celery app initialization, and Redis interactions – this indicates the use of Celery for task management.
- “tasks” for various AI integration tasks – clear separation of concerns based on the external AI services.
- Presence of Docker-related files shows containerization and a likely orchestrated deployment (Docker Compose).

##### Interpreting the README
- It outlines the tech stack for both the frontend (Next.js, React, Three.js) and backend (FastAPI, Celery, Redis) along with the roles each AI service (Gemini, Claude, Cerebras) plays in the conversion process.

a. Main Components:
- User Interface: Represented by the Frontend that handles sketching, previewing 3D models, and interactive components.
- Frontend Application: Components based on Next.js/React and specific Three.js modules (e.g., Model3DPreviewShape, CustomTransformControls, etc.).
- Backend API Server: The FastAPI application that receives requests from the frontend (e.g., sketch data) and initiates processing.
- Task Queue & Worker System: Highlight the Celery configuration in the backend. Separate modules (cerebras_tasks, claude_tasks, gemini_tasks) illustrate interaction with different AI services.
- Message Broker: Although not explicitly detailed, the presence of “redis.py” suggests Redis is used to support Celery.
- External AI Services: Indicate the integration with AI models like Gemini, Claude, and Cerebras for image enhancement, code extraction, and 3D model generation.
- Deployment Infrastructure: Docker (Dockerfile, docker-compose.yml) is used for containerization and orchestration.

b. Component Relationships:
- Frontend communicating with the Backend API Server – RESTful API calls.
- Once processing is complete, indicate the task results being passed back through Celery to the API server, and then the API server responding to the frontend.

c. Architectural Patterns:
- Separation of Concerns: Distinct layers separating UI (frontend) from business logic and asynchronous processing (backend/API and Celery).
- Asynchronous Processing: Emphasize how the Celery worker design pattern decouples intensive AI processing tasks from the synchronous API handling.
- Modular Integration: Different tasks/modules are dedicated for each AI service.

d. Technologies and Frameworks:
- Frontend: Next.js, React, Three.js.
- Backend: Python, FastAPI, Celery.
- Supporting: Redis (as a message broker for Celery) and Docker (for containerization).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Node
    User["User"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["User Interface"]:::frontend
        Three["Three.js Components"]:::frontend
        PS["Preview Shape"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        APIS["API Server (FastAPI)"]:::backend
        CEL["Task Queue (Celery)"]:::backend
        RED["Message Broker (Redis)"]:::redis
        subgraph "External AI Services"
            GEM["Gemini Tasks"]:::external
            CLA["Claude Tasks"]:::external
            CER["Cerebras Tasks"]:::external
        end
    end

    %% Deployment Infrastructure
    DI["Deployment (Docker)"]:::docker

    %% Data Flow
    User --> UI
    UI --> Three
    Three --> PS
    PS --> APIS
    APIS --> CEL
    CEL --> RED
    CEL --> GEM
    CEL --> CLA
    CEL --> CER
    GEM --> CEL
    CLA --> CEL
    CER --> CEL
    CEL --> APIS
    APIS --> PS

    %% Docker Containerization Connections (dashed)
    DI --- UI
    DI --- Three
    DI --- PS
    DI --- APIS
    DI --- CEL
    DI --- RED
    DI --- GEM
    DI --- CLA
    DI --- CER

    %% Click Events
    click UI "https://github.com/martin226/vibe-draw/blob/main/frontend/app/page.tsx"
    click Three "https://github.com/martin226/vibe-draw/tree/main/frontend/app/components/three"
    click PS "https://github.com/martin226/vibe-draw/tree/main/frontend/app/PreviewShape"
    click APIS "https://github.com/martin226/vibe-draw/blob/main/backend/app/main.py"
    click APIS "https://github.com/martin226/vibe-draw/blob/main/backend/app/api/routes.py"
    click CEL "https://github.com/martin226/vibe-draw/blob/main/backend/app/core/celery_app.py"
    click CEL "https://github.com/martin226/vibe-draw/tree/main/backend/app/tasks/"
    click RED "https://github.com/martin226/vibe-draw/blob/main/backend/app/core/redis.py"
    click GEM "https://github.com/martin226/vibe-draw/blob/main/backend/app/tasks/gemini_tasks.py"
    click CLA "https://github.com/martin226/vibe-draw/blob/main/backend/app/tasks/claude_tasks.py"
    click CER "https://github.com/martin226/vibe-draw/blob/main/backend/app/tasks/cerebras_tasks.py"
    click DI "https://github.com/martin226/vibe-draw/tree/main/backend/Dockerfile"
    click DI "https://github.com/martin226/vibe-draw/blob/main/backend/docker-compose.yml"

    %% Styles
    classDef user fill:#fde2e4,stroke:#d11149,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#1f77b4,stroke-width:2px;
    classDef backend fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef redis fill:#f5e79e,stroke:#d4ac0d,stroke-width:2px;
    classDef external fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef docker fill:#ecf0f1,stroke:#7f8c8d,stroke-width:2px;
```
