# vyuma/physiquest_animation_generator architecture

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

- Interactive diagram: https://gitdiagram.com/vyuma/physiquest_animation_generator
- Repository: https://github.com/vyuma/physiquest_animation_generator

## Overview

##### Main Components

a. Frontend Layer (Next.js):
- Sub-components:
- Components Module (app/components/)
- Server Actions (app/actions.tsx)
- Utils Module (app/utils/)
- Data Module (app/data/)

b. Backend Layer (Python/Langserve):
- Sub-components:
- FastAPI Server (backend/app.py)
- Manim Generator Modules (manim_generator.py, manim_generator_graph.py)
- Prompt Handler (prompt.py)
- Temporary File Storage (backend/tmp/)

c. External Services:
- OpenAI API
- LaTeX System

##### Connection and Data Flow

- Frontend to Backend: HTTP/REST API calls (port 8000)
- Backend to OpenAI API: External API calls
- Backend to LaTeX: System calls for mathematical rendering
- Temporary file flow between components

##### Specific Implementation Details

- Blue: Frontend components
- Green: Backend services
- Yellow: External services
- Gray: Storage/temporary files

##### Component Relationships

Following key interactions:
**User Interface → Server Actions → Backend API → Manim Generator → LaTeX → Video Output**

##### Technical Stack Indicators

Technology badges or labels for:
- Next.js
- TypeScript
- Python
- FastAPI
- Langserve
- LaTeX
- Docker

##### Environment Context

A container showing the Docker development environment:
- Dev Container
- VSCode Integration
- Shared volumes

**[User Interface Layer]**
- ↓
**[Frontend Application Layer]**
- ↓
**[API Communication Layer]**
- ↓
**[Backend Processing Layer]**
- ↓
**[External Services Layer]**

Important Considerations:

##### Use standardized symbols
- Rectangles for components
- Clouds for external services

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Interface Layer"
        UI[User Interface]:::ui
        Layout[Layout]:::ui
        MainPage[Main Page]:::ui
    end

    subgraph "Frontend Layer"
        Components[Components Module]:::frontend
        ServerActions[Server Actions]:::frontend
        Utils[Utils Module]:::frontend
        Data[Data Module]:::frontend
        FormTypes[Form Types]:::frontend
        FetchUtils[API Communication Utils]:::frontend
        ExamplePrompts[Example Prompts]:::frontend
    end

    subgraph "Backend Layer"
        FastAPI[FastAPI Server]:::backend
        ManimGen[Manim Generator]:::backend
        ManimGraphGen[Manim Graph Generator]:::backend
        PromptHandler[Prompt Handler]:::backend
        TempStorage[(Temporary Storage)]:::storage
    end

    subgraph "External Services"
        OpenAI[OpenAI API]:::external
        LaTeX[LaTeX System]:::external
    end

    subgraph "Development Environment"
        DevContainer[Dev Container]:::dev
    end

    %% Connections
    UI --> Layout
    Layout --> MainPage
    MainPage --> Components
    Components --> ServerActions
    ServerActions --> FetchUtils
    Utils --> FetchUtils
    Data --> ExamplePrompts
    FormTypes --> Components

    FetchUtils --> FastAPI
    FastAPI --> ManimGen
    FastAPI --> ManimGraphGen
    FastAPI --> PromptHandler
    ManimGen --> TempStorage
    ManimGraphGen --> TempStorage
    PromptHandler --> OpenAI
    ManimGen --> LaTeX
    ManimGraphGen --> LaTeX

    %% Click Events
    click Components "https://github.com/vyuma/physiquest_animation_generator/tree/develop/app/components/"
    click ServerActions "https://github.com/vyuma/physiquest_animation_generator/blob/develop/app/actions.tsx"
    click Utils "https://github.com/vyuma/physiquest_animation_generator/tree/develop/app/utils/"
    click Data "https://github.com/vyuma/physiquest_animation_generator/tree/develop/app/data/"
    click FastAPI "https://github.com/vyuma/physiquest_animation_generator/blob/develop/backend/app.py"
    click ManimGen "https://github.com/vyuma/physiquest_animation_generator/blob/develop/backend/manim_generator.py"
    click ManimGraphGen "https://github.com/vyuma/physiquest_animation_generator/blob/develop/backend/manim_generator_graph.py"
    click PromptHandler "https://github.com/vyuma/physiquest_animation_generator/blob/develop/backend/prompt.py"
    click TempStorage "https://github.com/vyuma/physiquest_animation_generator/tree/develop/backend/tmp/"
    click DevContainer "https://github.com/vyuma/physiquest_animation_generator/tree/develop/.devcontainer/"
    click FetchUtils "https://github.com/vyuma/physiquest_animation_generator/blob/develop/app/utils/fetchVideo.ts"
    click FormTypes "https://github.com/vyuma/physiquest_animation_generator/blob/develop/app/type/formType.ts"
    click ExamplePrompts "https://github.com/vyuma/physiquest_animation_generator/blob/develop/app/data/examplePrompt.ts"
    click MainPage "https://github.com/vyuma/physiquest_animation_generator/blob/develop/app/page.tsx"
    click Layout "https://github.com/vyuma/physiquest_animation_generator/blob/develop/app/layout.tsx"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef external fill:#FFC107,color:black
    classDef storage fill:#9E9E9E,color:white
    classDef dev fill:#607D8B,color:white
    classDef ui fill:#3F51B5,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend]:::frontend
        Backend[Backend]:::backend
        External[External Services]:::external
        Storage[Storage]:::storage
        Development[Development]:::dev
        UserInterface[User Interface]:::ui
    end
```
