# saksham1387/looma architecture

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

- Interactive diagram: https://gitdiagram.com/saksham1387/looma
- Repository: https://github.com/saksham1387/looma

## Overview

##### Project type and purpose
- This is a full-stack web application (“Looma”) that converts natural-language prompts into rendered animations.
- Frontend: Next.js 14 with React, Tailwind CSS, Prisma, NextAuth.js
- Worker: FastAPI Python service embedding Manim for actual animation rendering
- Integrations: OpenAI (GPT → Manim code), Google OAuth, a relational database (via Prisma)

##### File structure
- Top level
- package.json / pnpm-workspace.yaml: monorepo workspace config
- prisma/: database schema & migrations
- src/: Next.js application
- worker/: FastAPI + Manim rendering service
- src/app/: Next.js 14 “app router” layout, pages, API routes under /api
- /api/auth/[...nextauth]: authentication
- /api/project and /api/prompt: REST endpoints that use Prisma and call the worker or OpenAI
- src/components/, src/lib/, src/db/, src/generated: UI elements, helper libraries, Prisma client
- worker/:
- main.py: FastAPI entrypoint
- media/videos: storage for partial/full output videos
- requirements.txt: Python dependencies

##### README for additional insights
- README describes the high-level flow: user submits prompt → Next.js → OpenAI generates Python/Manim code → code sent to FastAPI worker → Manim renders video → result delivered back to frontend for playback
- Environment variables: DATABASE_URL, OPENAI_API_KEY, WORKER_URL, Google OAuth keys, NEXTAUTH_SECRET
- Tech stack summary confirms separation of concerns

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and client
    User["User Browser"]:::frontend

    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["React UI Components"]:::frontend
        NextApp["Next.js App Router"]:::frontend
        AuthRoute["NextAuth API Route (/api/auth/[...nextauth])"]:::frontend
        PromptRoute["Prompt API Route (/api/prompt)"]:::frontend
        ProjectRoute1["Project API Route (/api/project)"]:::frontend
        ProjectRoute2["Project API Route (/api/project/:id)"]:::frontend
        ProjectRoute3["Project Prompts Route (/api/project/:id/prompts)"]:::frontend
        Hooks["Business Logic & Hooks"]:::frontend
        CodeLib["OpenAI Integration (GPT → Manim code)"]:::frontend
        GlobalStyles["Tailwind Config & Styles"]:::frontend
    end

    %% Backend & services
    subgraph "Backend & Services"
        DB["Relational Database (Prisma)"]:::database
        PrismaClient["Prisma Client"]:::backend
        OpenAI["OpenAI API"]:::external
        GoogleOAuth["Google OAuth"]:::external
    end

    %% Worker Service
    subgraph "Manim Worker Service"
        FastAPI["FastAPI Worker (FastAPI)"]:::backend
        Manim["Manim Engine"]:::backend
        MediaStorage["Video Storage (media/videos)"]:::storage
    end

    %% Connections
    User --> UI
    UI --> NextApp
    NextApp --> AuthRoute
    NextApp --> PromptRoute
    NextApp --> ProjectRoute1
    NextApp --> ProjectRoute2
    NextApp --> ProjectRoute3
    NextApp --> GlobalStyles

    AuthRoute --> GoogleOAuth
    PromptRoute --> Hooks
    ProjectRoute1 --> Hooks
    ProjectRoute2 --> Hooks
    ProjectRoute3 --> Hooks

    Hooks --> PrismaClient
    PrismaClient --> DB

    PromptRoute --> CodeLib
    CodeLib --> OpenAI

    PromptRoute --> FastAPI
    FastAPI --> Manim
    Manim --> MediaStorage
    FastAPI --> NextApp
    MediaStorage --> NextApp

    %% Click Events
    click UI "https://github.com/saksham1387/looma/tree/main/src/components"
    click NextApp "https://github.com/saksham1387/looma/tree/main/src/app"
    click AuthRoute "https://github.com/saksham1387/looma/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click PromptRoute "https://github.com/saksham1387/looma/blob/main/src/app/api/prompt/route.ts"
    click ProjectRoute1 "https://github.com/saksham1387/looma/blob/main/src/app/api/project/route.ts"
    click ProjectRoute2 "https://github.com/saksham1387/looma/blob/main/src/app/api/project/[id]/route.ts"
    click ProjectRoute3 "https://github.com/saksham1387/looma/blob/main/src/app/api/project/[id]/prompts/route.ts"
    click Hooks "https://github.com/saksham1387/looma/blob/main/src/lib/prompt/index.ts"
    click CodeLib "https://github.com/saksham1387/looma/blob/main/src/lib/parse/code.ts"
    click GlobalStyles "https://github.com/saksham1387/looma/blob/main/src/app/globals.css"
    click DB "https://github.com/saksham1387/looma/blob/main/prisma/schema.prisma"
    click PrismaClient "https://github.com/saksham1387/looma/blob/main/src/db/index.ts"
    click FastAPI "https://github.com/saksham1387/looma/blob/main/worker/main.py"
    click MediaStorage "https://github.com/saksham1387/looma/tree/main/worker/media/videos"

    %% Styles
    classDef frontend fill:#f5faff,stroke:#1e40af,stroke-width:2px
    classDef backend fill:#f0fdf4,stroke:#065f46,stroke-width:2px
    classDef database fill:#fffbeb,stroke:#b45309,stroke-width:2px
    classDef external fill:#eff6ff,stroke:#1e3a8a,stroke-width:2px,stroke-dasharray: 5 5
    classDef storage fill:#fdf2f8,stroke:#9d174d,stroke-width:2px,stroke-dasharray: 2 2
```
