# ancientjames/multivox architecture

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

- Interactive diagram: https://gitdiagram.com/ancientjames/multivox
- Repository: https://github.com/ancientjames/multivox

## Overview

##### Main Components
- Hardware/Driver Layer: At the heart of the system is the driver code that creates a shared voxel buffer and then scans it out to the LED panels in sync with the physical rotation. This is primarily in the src/driver directory (including gadget-specific configuration files under gadgets) and associated modules (gpio.c, rotation.c, etc.).
- Voxel Buffer / Shared Memory: A central, shared memory structure that both the driver and client (content generation) components interact with.
- Client/Application Layer: This includes the “multivox” launcher (src/multivox) and the various volumetric demos (“toys” in src/toys). This part handles content generation for the display.
- Common/Platform Layer: Under src/platform one finds common routines for graphics, image handling, math functions, and voxel management that are reused across different client applications.
- Simulator: The src/simulator directory contains a software “Virtex” that mimics the hardware’s output, rendering the voxel buffer in an X11/OpenGL window. It serves as a diagnostic and development tool for when the physical hardware isn’t available.
- Python Utilities: In the python directory there are tools for calibration, pattern generation, point cloud streaming, and converting 3D models (obj2c.py) so that they can be embedded as header files.

##### Relationships and Interactions
- The Driver Module (src/driver) continuously reads hardware signals (e.g., GPIO inputs for rotation sync) and scans the shared voxel buffer to light up the LED panels.
- The Client/Application Layer (multivox and toys) writes 3D content to the shared voxel buffer for display, and users interact with these via a bluetooth gamepad.
- The Simulator (src/simulator) accesses the same voxel buffer as the driver, but instead renders it in an X11 window using OpenGL calls.
- The Python utilities serve supporting roles—they can generate calibration patterns, stream point clouds to remote viewers (or for testing with the physical device), or transform 3D model files to C header files for embedding in the application.
- Hardware-specific configuration (e.g., gadget settings and GPIO mappings) is abstracted into device-specific headers (e.g., gadget_rotovox.h, gadget_vortex.h) to adapt the driver layer for different display configurations.

##### Architectural Patterns and Design Principles
- The project clearly separates concerns: the low-level driver functions that directly interact with hardware, and the high-level applications/demos that generate visual content.
- There is a modular design where each “toy” or demo in the src/toys directory is self-contained, suggesting an extensible plugin-like approach via cartridges managed by the multivox launcher.
- The use of a shared memory/voxel buffer is central to the design, ensuring that both driver and client code (or simulator) operate on the same core data structure.
- The project is set up for direct hardware interfacing on a Raspberry Pi (using memory-mapped GPIO access), implying real-time performance considerations, which is why the code even pins processes to specific cores.

##### Final Recommendations for the Principal Software Engineer
– Hardware (Raspberry Pi, LED panels, GPIO inputs, Bluetooth gamepad/audio)
– Driver/Hardware Abstraction Layer (with a note on device-specific configuration via gadgets)
– Shared Voxel Buffer (core to the data flow between modules)
– Client Layer: Multivox launcher and individual volumetric toys/demos
– Simulator: Soft-rendering of the voxel buffer output via OpenGL/X11
– Supporting Python tools for calibration and model conversion/streaming
- Detail each block with submodules where appropriate (for example, list the different driver files and their functions).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "System Hardware"
        Hardware["Raspberry Pi (Hardware)"]:::hardware
    end

    subgraph "Driver/Hardware Abstraction Layer"
        Driver["Driver (src/driver)"]:::driver
    end

    VoxelBuffer(("Voxel Buffer/Shared Memory")):::voxel

    nodeCommon["Common Platform Utilities (src/platform)"]:::platform

    subgraph "Client/Application Layer"
        Multivox["Multivox Launcher (src/multivox)"]:::client
        VolumetricDemos["Volumetric Demos (src/toys)"]:::client
    end

    Simulator["Simulator (Virtex) (src/simulator)"]:::simulator

    PythonUtil["Python Utilities (python)"]:::python

    %% Connections
    Hardware -->|"GPIO_Signals"| Driver
    Hardware -->|"Bluetooth_Gamepad"| Multivox
    Driver -->|"Scans_Buffer"| VoxelBuffer
    Multivox -->|"Writes_Content"| VoxelBuffer
    VolumetricDemos -->|"Writes_Content"| VoxelBuffer
    VoxelBuffer -->|"Rendered_Output"| Simulator
    PythonUtil -->|"Calib_Stream_Convert"| VoxelBuffer

    Driver -->|"Uses"| nodeCommon
    Multivox -->|"Uses"| nodeCommon
    VolumetricDemos -->|"Uses"| nodeCommon

    %% Click Events
    click Driver "https://github.com/ancientjames/multivox/tree/main/src/driver"
    click VoxelBuffer "https://github.com/ancientjames/multivox/blob/main/src/platform/voxel.c"
    click Multivox "https://github.com/ancientjames/multivox/tree/main/src/multivox"
    click VolumetricDemos "https://github.com/ancientjames/multivox/tree/main/src/toys"
    click nodeCommon "https://github.com/ancientjames/multivox/tree/main/src/platform"
    click Simulator "https://github.com/ancientjames/multivox/tree/main/src/simulator"
    click PythonUtil "https://github.com/ancientjames/multivox/tree/main/python"

    %% Styles
    classDef hardware fill:#cccccc,stroke:#000000,stroke-width:2px;
    classDef driver fill:#ffaaaa,stroke:#800000,stroke-width:2px;
    classDef voxel fill:#fff7b2,stroke:#aa7700,stroke-width:2px;
    classDef client fill:#bbd9ff,stroke:#3355ff,stroke-width:2px;
    classDef simulator fill:#b2f0b2,stroke:#008800,stroke-width:2px;
    classDef python fill:#ffdd99,stroke:#cc9900,stroke-width:2px;
    classDef platform fill:#dafedc,stroke:#008800,stroke-width:2px;
```
