# kevinzwong/mapling architecture

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

- Interactive diagram: https://gitdiagram.com/kevinzwong/mapling
- Repository: https://github.com/kevinzwong/mapling

## Overview

##### Main Components
- User Interface and Input:
- GUI components for path creation and adjustment (PathCreator.py, PointSelection.py, tkSliderWidget.py).
- Command-line interactions for initiating the process.
- Core Spline and Movement Logic:
- Spline3D.py for generating and handling the 3D spline curve which dictates the image’s movement.
- TimeAdjustment.py to modulate the timing between points (thus affecting pan speed).
- DynamicEffects.py, which likely applies any animated or transitional visual effects.
- Video and Image Processing:
- Mapling.py serves as the primary engine for generating the video from the input image using the selected movement path.
- example.py (or examples.py as referenced) provides a sample demonstration of the overall process.
- Data Persistence and Models:
- mapling_models directory hosts saved JSON models (like spline_data_hook.json and spline_data_loop.json), representing predefined or custom spline paths.
- Output Handling:
- finishedVideos folder stores the final produced videos.
- images folder contains static assets (previews, GUI images) that support instructions or documentation.
- Dependency and Configuration Management:
- requirements.txt lists all external libraries.
- license.txt and README.md give project context.

##### Relationships and Data Flow
- The input from the GUI feeds into the spline creation logic (handled in Spline3D.py), and then TimeAdjustment.py tweaks the timing for smooth animation.
- The completed spline model can be saved in the mapling_models folder for re-use or edited further.
- The video generation engine then uses the spline data and applies dynamic effects (possibly via DynamicEffects.py) to generate frames with smooth transitions, writing the final output to the finishedVideos folder.
- The example.py serves to tie these components together as an easily runnable demonstration.

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate the GUI/input, business logic (spline interpolation and time adjustment), and the output processing (video generation) into distinct modules.
- Modular Design: Each Python script tackles a specific function (e.g., spline creation vs. GUI interaction), making it simple to follow dependencies and enhance or swap out components later.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface and Input
    subgraph "User Interface and Input"
        UI1["Path Creator GUI (PathCreator.py)"]
        UI2["Point Selector (PointSelection.py)"]
        UI3["Slider Widget (tkSliderWidget.py)"]
    end

    %% Core Spline and Movement Logic
    subgraph "Core Spline and Movement Logic"
        S1["Spline Generator (Spline3D.py)"]
        S2["Time Adjustment (TimeAdjustment.py)"]
        S3["Dynamic Effects (DynamicEffects.py)"]
    end

    %% Video and Image Processing
    subgraph "Video and Image Processing"
        VP1["Video Processing Engine (Mapling.py)"]
        VP2["Demo Example (example.py)"]
    end

    %% Data Persistence and Models
    subgraph "Data Persistence and Models"
        P1[("Model Storage (mapling_models/)")]
    end

    %% Output Handling
    subgraph "Output Handling"
        O1["Video Output (finishedVideos/)"]
        O2["Image Assets (images/)"]
    end

    %% Dependency and Configuration Management
    subgraph "Dependency and Configuration Management"
        C1["Dependencies (requirements.txt)"]
        C2["Project Info (README.md)"]
        C3["License (license.txt)"]
    end

    %% Data Flow Connections
    UI1 -->|"feeds"| S1
    UI2 -->|"feeds"| S1
    UI3 -->|"feeds"| S1

    S1 -->|"calculates"| S2
    S2 -->|"outputs spline"| VP1
    S3 -->|"applies effects"| VP1

    S2 -->|"saves model"| P1
    P1 -->|"loads model"| VP1

    VP2 -->|"demonstrates"| VP1

    VP1 -->|"produces video"| O1

    %% Styling Classes
    class UI1,UI2,UI3 ui
    class S1,S2,S3 spline
    class VP1,VP2 video
    class P1 persistence
    class O1,O2 output
    class C1,C2,C3 config

    %% Class Definitions
    classDef ui fill:#a0d8f1,stroke:#333,stroke-width:2px;
    classDef spline fill:#c0e8c0,stroke:#333,stroke-width:2px;
    classDef video fill:#f7d794,stroke:#333,stroke-width:2px;
    classDef persistence fill:#fdbcaa,stroke:#333,stroke-width:2px;
    classDef output fill:#ffb3ba,stroke:#333,stroke-width:2px;
    classDef config fill:#d1c4e9,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click UI1 "https://github.com/kevinzwong/mapling/blob/main/PathCreator.py"
    click UI2 "https://github.com/kevinzwong/mapling/blob/main/PointSelection.py"
    click UI3 "https://github.com/kevinzwong/mapling/blob/main/tkSliderWidget.py"
    click S1 "https://github.com/kevinzwong/mapling/blob/main/Spline3D.py"
    click S2 "https://github.com/kevinzwong/mapling/blob/main/TimeAdjustment.py"
    click S3 "https://github.com/kevinzwong/mapling/blob/main/DynamicEffects.py"
    click VP1 "https://github.com/kevinzwong/mapling/blob/main/Mapling.py"
    click VP2 "https://github.com/kevinzwong/mapling/blob/main/example.py"
    click P1 "https://github.com/kevinzwong/mapling/tree/main/mapling_models/"
    click O1 "https://github.com/kevinzwong/mapling/tree/main/finishedVideos/"
    click O2 "https://github.com/kevinzwong/mapling/tree/main/images/"
    click C1 "https://github.com/kevinzwong/mapling/blob/main/requirements.txt"
    click C2 "https://github.com/kevinzwong/mapling/blob/main/README.md"
    click C3 "https://github.com/kevinzwong/mapling/blob/main/license.txt"
```
