# dmarx/keyframed architecture

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

- Interactive diagram: https://gitdiagram.com/dmarx/keyframed
- Repository: https://github.com/dmarx/keyframed

## Overview

##### Main Components

a. Core Components:
- Curve System
- Base Curve Class
- Specialized Curve Types (SmoothCurve)
- Keyframe Management
- Interpolation Engine
- Parameter Management
- ParameterGroup Handler
- Composition System
- DSL (Domain Specific Language)
- Parser for Chigozie Nri string format
- Serialization Layer
- YAML Serialization
- Dict Conversion

b. Supporting Components:
- Utility Functions
- Mathematical Operations
- Visualization System

##### Relationships and Data Flow

**[User Input Layer]**

- ▼
**[Curve Creation & Management]**

- ┬─────────────────┐
- ▼                 ▼                 ▼
**[Interpolation]  [Parameter Groups]  [Compositions]**

- ┴─────────────┐   │
- ▼   ▼
- [Operations Layer]

- ▼
- [Output/Visualization]

- ▼
- [Serialization Layer]

##### Specific Implementation Details to Highlight

a. Curve System:
- Inheritance hierarchy from CurveBase
- Internal SortedDict structure
- Keyframe object structure
- Interpolation method registry

b. Parameter Management:
- ParameterGroup relationship with Curves
- Composition's relationship with ParameterGroup
- Arithmetic operation flow

c. Integration Points:
- Matplotlib integration for visualization
- Serialization formats (YAML/Dict)
- DSL parser integration

##### Implementation Notes

- Different curve types (Curve, SmoothCurve)
- Interpolation methods (previous, linear, eased_lerp)
- Parameter group operations
- Composition reductions
- Serialization formats

##### Additional Elements

- A small example workflow
- Common use case patterns
- Extension points for custom functionality
- Test coverage areas

This design will help developers understand both the high-level architecture and the detailed implementation aspects of the Keyframed library.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        UI[User Input]
        DSL[DSL Parser]:::dsl
    end

    subgraph Core
        CS[Curve System]:::curve
        IE[Interpolation Engine]:::interpolation
        PG[Parameter Groups]:::curve
        CO[Compositions]:::curve
    end

    subgraph Operations
        MO[Mathematical Operations]:::math
        UF[Utility Functions]:::utils
    end

    subgraph Output
        VIS[Visualization]
        SER[Serialization]:::serialization
    end

    UI --> DSL
    DSL --> CS
    CS --> IE
    CS --> PG
    CS --> CO
    
    IE --> MO
    PG --> MO
    CO --> MO
    
    MO --> VIS
    MO --> SER
    UF -.-> CS
    UF -.-> IE
    UF -.-> MO

    %% Component Mappings
    click CS "https://github.com/dmarx/keyframed/blob/main/src/keyframed/curve.py"
    click IE "https://github.com/dmarx/keyframed/blob/main/src/keyframed/interpolation.py"
    click DSL "https://github.com/dmarx/keyframed/blob/main/src/keyframed/dsl.py"
    click SER "https://github.com/dmarx/keyframed/blob/main/src/keyframed/serialization.py"
    click UF "https://github.com/dmarx/keyframed/blob/main/src/keyframed/utils.py"
    click MO "https://github.com/dmarx/keyframed/blob/main/src/keyframed/misc.py"
    click PG "https://github.com/dmarx/keyframed/blob/main/src/keyframed/curve.py"
    click CO "https://github.com/dmarx/keyframed/blob/main/src/keyframed/curve.py"

    %% Styling
    classDef curve fill:#3498db,stroke:#2980b9,color:white
    classDef interpolation fill:#2ecc71,stroke:#27ae60,color:white
    classDef dsl fill:#e74c3c,stroke:#c0392b,color:white
    classDef math fill:#f1c40f,stroke:#f39c12,color:black
    classDef utils fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef serialization fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        L1[Curve Components]:::curve
        L2[Interpolation]:::interpolation
        L3[DSL Parser]:::dsl
        L4[Math Operations]:::math
        L5[Utilities]:::utils
        L6[Serialization]:::serialization
    end
```
