# azurice/ranim architecture

> Architecture diagram of the GitHub repository azurice/ranim, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azurice/ranim
- Repository: https://github.com/azurice/ranim

## Overview

##### Main Components

a. Core Engine Components:
- Scene Management System
- Animation Pipeline
- Rendering System
- Object Management System

b. External Dependencies:
- WGPU (Graphics API)
- FFmpeg (Video Encoding)

**Application Layer**

**Scene Management Layer**

**Object/Animation Layer**

**Rendering Layer**

**Output Layer**

##### Key Components and Relationships

a. Scene Management Layer:
- Scene Store (`src/scene/store.rs`)
- Entity Management (`src/scene/entity.rs`)
- Canvas System (`src/scene/canvas/`)
- File Writer (`src/scene/file_writer.rs`)

b. Object/Animation Layer:
- RObject System (`src/rabject/`)
- 2D Objects (`rabject2d/`)
- 3D Objects (`rabject3d/`)
- Animation System (`src/animation/`)
- Transform Animations
- Fading Animations

c. Rendering Layer:
- WGPU Integration (`src/utils/wgpu.rs`)
- Shader Pipeline
- Multiple shader files for different purposes (fill, stroke, compute)
- Canvas Pipeline (`src/scene/canvas/pipeline.rs`)

##### Specific Design Elements

- Rectangles: Core components
- Hexagons: External dependencies

##### Important Relationships to Highlight

- Scene → Objects: Composition relationship
- Objects → Shaders: Rendering pipeline
- Animation System → Objects: Transformation flow
- Canvas → WGPU: Graphics rendering
- File Writer → FFmpeg: Video encoding

##### Technical Details

- Shader Pipeline Architecture
- Compute shaders
- Fill/Stroke operations
- Object Hierarchy
- 2D/3D separation
- Vector paths
- Mesh objects

##### Implementation Notes

- The separation between 2D and 3D rendering pipelines
- The relationship between animations and objects
- The shader pipeline architecture
- The video encoding process

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#2b6cb0,stroke:#1a4971,color:white
    classDef rendering fill:#48bb78,stroke:#2f855a,color:white
    classDef animation fill:#ed8936,stroke:#c05621,color:white
    classDef external fill:#805ad5,stroke:#553c9a,color:white
    classDef utility fill:#718096,stroke:#4a5568,color:white
    classDef storage fill:#4299e1,stroke:#2b6cb0,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Rendering Components]:::rendering
        L3[Animation Components]:::animation
        L4[External Dependencies]:::external
        L5[Utility Components]:::utility
    end

    %% External Dependencies
    WGPU{{WGPU}}:::external
    FFmpeg{{FFmpeg}}:::external

    %% Application Layer
    subgraph Application
        SceneManager[Scene Management System]:::core
        click SceneManager "https://github.com/azurice/ranim/blob/main/src/scene/mod.rs"
    end

    %% Scene Management Layer
    subgraph SceneManagement
        SceneStore[(Scene Store)]:::storage
        EntityManager[Entity Management]:::core
        Canvas[Canvas System]:::core
        FileWriter[File Writer]:::utility
        
        click SceneStore "https://github.com/azurice/ranim/blob/main/src/scene/store.rs"
        click EntityManager "https://github.com/azurice/ranim/blob/main/src/scene/entity.rs"
        click Canvas "https://github.com/azurice/ranim/blob/main/src/scene/canvas/mod.rs"
        click FileWriter "https://github.com/azurice/ranim/blob/main/src/scene/file_writer.rs"
    end

    %% Object/Animation Layer
    subgraph ObjectAnimation
        Objects[Object Management System]:::core
        Objects2D[2D Objects]:::core
        Objects3D[3D Objects]:::core
        AnimationSystem[Animation System]:::animation
        TransformAnim[Transform Animations]:::animation
        FadingAnim[Fading Animations]:::animation
        
        click Objects "https://github.com/azurice/ranim/blob/main/src/rabject/group.rs"
        click Objects2D "https://github.com/azurice/ranim/tree/main/src/rabject/rabject2d"
        click Objects3D "https://github.com/azurice/ranim/tree/main/src/rabject/rabject3d"
        click AnimationSystem "https://github.com/azurice/ranim/blob/main/src/animation/mod.rs"
        click TransformAnim "https://github.com/azurice/ranim/blob/main/src/animation/transform.rs"
        click FadingAnim "https://github.com/azurice/ranim/blob/main/src/animation/fading.rs"
    end

    %% Rendering Layer
    subgraph Rendering
        WGPUIntegration[WGPU Integration]:::rendering
        ShaderPipeline[Shader Pipeline]:::rendering
        CanvasPipeline[Canvas Pipeline]:::rendering
        Camera[Camera System]:::rendering
        
        click WGPUIntegration "https://github.com/azurice/ranim/blob/main/src/utils/wgpu.rs"
        click ShaderPipeline "https://github.com/azurice/ranim/tree/main/shader"
        click CanvasPipeline "https://github.com/azurice/ranim/blob/main/src/scene/canvas/pipeline.rs"
        click Camera "https://github.com/azurice/ranim/blob/main/src/scene/canvas/camera.rs"
    end

    %% Utility Components
    subgraph Utils
        BezierCurves[Bezier Curves]:::utility
        RateFunctions[Rate Functions]:::utility
        ColorManagement[Color Management]:::utility
        
        click BezierCurves "https://github.com/azurice/ranim/blob/main/src/utils/bezier.rs"
        click RateFunctions "https://github.com/azurice/ranim/blob/main/src/utils/rate_functions.rs"
        click ColorManagement "https://github.com/azurice/ranim/blob/main/src/color/mod.rs"
    end

    %% Relationships
    SceneManager --> SceneStore
    SceneManager --> EntityManager
    SceneManager --> Canvas
    Canvas --> WGPUIntegration
    WGPUIntegration --> WGPU
    FileWriter --> FFmpeg
    Objects --> Objects2D
    Objects --> Objects3D
    AnimationSystem --> TransformAnim
    AnimationSystem --> FadingAnim
    Objects --> ShaderPipeline
    ShaderPipeline --> CanvasPipeline
    CanvasPipeline --> Camera
    Objects -.-> BezierCurves
    AnimationSystem -.-> RateFunctions
    Objects -.-> ColorManagement
```
