# asdcainicela/lnx architecture

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

- Interactive diagram: https://gitdiagram.com/asdcainicela/lnx
- Repository: https://github.com/asdcainicela/lnx

## Overview

##### Project type and purpose
- Lnx is an open-source toolkit for generating high-quality mathematical animations and documents. It combines Python (with the Manim library) and LaTeX to produce videos (MP4s) and PDFs illustrating advanced calculus concepts, solved problems, and visual math explanations.

##### File structure
- Top‐level:
- animation/scripts: Python “scenes” to feed Manim
- assets/logo: branding images
- docs-tex: LaTeX source for exercises and exams
- template: LaTeX style files and main.tex
- path_dev: auxiliary dev scripts and HTML preview
- Under animation/scripts/calculus: dozens of predefined Manim scenes (sum.py, Esfera.py, etc.)
- No web frontend or database—this is a CLI‐driven generation tool
- Dependencies implied: `requirements.txt` → Manim, Python 3.8+, LaTeX distribution, ffmpeg (via Manim)

##### README for architecture insights
- Describes a two-stage pipeline:
a) Python + Manim renders animations
b) LaTeX compiles equations, docs, and templates
- Usage is entirely via CLI: `manim -pql calculus/sum.py`

##### Main components and their interactions
a. User / Developer (CLI invoker)
b. Lnx CLI Scripts (`animation/scripts/*.py`)
c. Manim Library (Python package)
d. LaTeX Engine (pdflatex, xelatex) + style templates (`template/`)
e. FFmpeg (via Manim) for encoding
f. Docs Builder (LaTeX sources in `docs-tex/`)
g. Output artifacts:
– Videos (.mp4, .gif) under Manim’s media directory
– PDFs for exercises and main.tex book

Relationships:
- The user runs a script → Python loads the scene → Manim invokes LaTeX (for embedded equations) → Manim produces raw frames → FFmpeg encodes video → files appear in `/media`
- For documentation: user runs `pdflatex main.tex` or `make` → LaTeX reads `docs-tex/` and `template/` → produces PDFs

##### Architectural patterns & design principles
- Modular CLI: each Python file in `animation/scripts` is a plugin/scene
- Separation of concerns:
- Rendering engine (Manim + ffmpeg)
- Typesetting engine (LaTeX + templates)
- Content sources (scripts, TeX, assets)
- Extensibility: drop new `.py` in `calculus` or new `.tex` in docs to add content

##### Detail level
- Extension point: “drop new .py or .tex → automatically discovered”
- Build steps: “CLI command” → “Rendering pipeline” → “Output”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Point
    User["User / CLI"]:::internal
    click User "https://github.com/asdcainicela/lnx/blob/main/README.md"

    %% Development Utilities
    DevUtils["Development Utilities (path_dev/)"]:::internal
    click DevUtils "https://github.com/asdcainicela/lnx/tree/main/path_dev/"

    %% Project Dependencies
    Dependencies["Project Dependencies (requirements.txt)"]:::internal
    click Dependencies "https://github.com/asdcainicela/lnx/blob/main/requirements.txt"

    %% Asset Store
    Assets["Asset Store (assets/logo/)"]:::internal
    click Assets "https://github.com/asdcainicela/lnx/tree/main/assets/logo/"

    %% Scene Modules
    subgraph "Scene Modules (animation/scripts/calculus)" 
        BaseScene["Base Scene (LnxScene.py)"]:::internal
        click BaseScene "https://github.com/asdcainicela/lnx/blob/main/animation/scripts/calculus/LnxScene.py"
        SumScene["Sum Animation (sum.py)"]:::internal
        click SumScene "https://github.com/asdcainicela/lnx/blob/main/animation/scripts/calculus/sum.py"
        ShapesScene["3D Shapes (Shapes3D.py)"]:::internal
        click ShapesScene "https://github.com/asdcainicela/lnx/blob/main/animation/scripts/calculus/Shapes3D.py"
    end
    click SceneModules "https://github.com/asdcainicela/lnx/tree/main/animation/scripts/calculus/"

    %% External Engines
    ManimLib["Manim Library"]:::external
    LaTeXEngine["LaTeX Engine & Templates"]:::external
    click LaTeXEngine "https://github.com/asdcainicela/lnx/tree/main/template/"
    FFmpeg["FFmpeg"]:::external

    %% Documentation Builder
    DocsBuilder["Documentation Builder Sources (docs-tex/exercises/)"]:::internal
    click DocsBuilder "https://github.com/asdcainicela/lnx/tree/main/docs-tex/exercises/"

    %% Outputs
    Videos["Video Outputs (media/)"]:::output
    PDFs["PDF Outputs"]:::output

    %% Pipeline for animations
    User -->|runs scene| SceneModules
    SceneModules -->|executes| ManimLib
    ManimLib -->|invokes typesetting| LaTeXEngine
    LaTeXEngine -->|returns typeset| ManimLib
    ManimLib -->|encodes| FFmpeg
    FFmpeg -->|produces| Videos

    %% Documentation pipeline
    User -->|build docs| DocsBuilder
    DocsBuilder -->|compiles| LaTeXEngine
    LaTeXEngine -->|generates| PDFs

    %% Dependencies & Assets usage
    SceneModules -->|depends on| Dependencies
    SceneModules -->|loads assets| Assets

    %% Dev utilities reference
    User -->|uses| DevUtils

    classDef internal fill:#e0ffe0,stroke:#2d882d,color:#055702
    classDef external fill:#e0f0ff,stroke:#0044cc,color:#002a66
    classDef output fill:#fff0e0,stroke:#cc8400,color:#995500
```
