# evildmp/brachiograph architecture

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

- Interactive diagram: https://gitdiagram.com/evildmp/brachiograph
- Repository: https://github.com/evildmp/brachiograph

## Overview

##### Main Components

A. Hardware Layer:
- Raspberry Pi Zero (central controller)
- Three servo motors
- Physical components (arms, pen mechanism)
- Power supply system

B. Software Components:
- Core Plotter Logic (brachiograph.py)
- Movement Control System (plotter.py)
- Drawing Utilities:
- Line drawing processor (linedraw.py)
- Turtle plotter simulator (turtle_plotter.py)
- Hardware Abstractions:
- Pen control (pen.py)
- Servo management (bg.py, bgt.py)

**┌─────────────── Application Layer ───────────────┐**
- Drawing Utilities   │     Plotting Interface   │
- Line Processing  │     - Turtle Simulator   │
- Image Processing │     - Pattern Generation │
- ┘
- ↕
**┌─────────────── Core Logic Layer ──────────────┐**
- Geometry Calculations                      │
- Coordinate Transformations                 │
- Movement Planning                          │
- ┘
- ↕
**┌─────────────── Hardware Control Layer ────────┐**
- Servo Control                             │
- Pen Mechanism                             │
- Calibration Management                    │
- ┘
- ↕
**┌─────────────── Physical Layer ───────────────┐**
- Raspberry Pi Zero                         │
- Servo Motors                             │
- Mechanical Arms                          │
- Power Supply                             │
- ┘

##### Key Relationships to Highlight

- Data flow from image input through processing to physical movement
- Control signals from core logic to hardware
- Feedback mechanisms from hardware to software
- Calibration and configuration paths

##### Implementation Details

- Maintain consistent spacing and alignment
- Version information
- Clear labels for all components

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef software fill:#b3d1ff,stroke:#333
    classDef hardware fill:#90EE90,stroke:#333
    classDef interface fill:#FFE5B4,stroke:#333
    classDef critical fill:#FFB6C1,stroke:#333
    
    subgraph Application
        DrawUtils["Drawing Utilities"]:::software
        LineProc["Line Processing"]:::software
        ImgProc["Image Processing"]:::software
        TurtleSim["Turtle Simulator"]:::software
        PatternGen["Pattern Generation"]:::software
        
        DrawUtils --> LineProc
        DrawUtils --> ImgProc
        DrawUtils --> TurtleSim
        DrawUtils --> PatternGen
    end

    subgraph CoreLogic
        Geometry["Geometry Calculations"]:::software
        CoordTrans["Coordinate Transformations"]:::software
        MovePlanner["Movement Planning"]:::software
        CorePlotter["Core Plotter Logic"]:::critical
        
        Geometry --> CoordTrans
        CoordTrans --> MovePlanner
        MovePlanner --> CorePlotter
    end

    subgraph HardwareControl
        ServoCtrl["Servo Control"]:::interface
        PenMech["Pen Mechanism"]:::interface
        CalibMgmt["Calibration Management"]:::interface
        
        ServoCtrl --> PenMech
        ServoCtrl --> CalibMgmt
    end

    subgraph Physical
        RasPi["Raspberry Pi Zero"]:::hardware
        Servos["Servo Motors"]:::hardware
        Arms["Mechanical Arms"]:::hardware
        Power["Power Supply"]:::hardware
        
        RasPi --> Servos
        Servos --> Arms
        Power --> RasPi
        Power --> Servos
    end

    %% Inter-layer connections
    Application --> CoreLogic
    CoreLogic --> HardwareControl
    HardwareControl --> Physical

    %% Testing and Documentation
    TestFrame["Testing Framework"]:::software
    DocSystem["Documentation System"]:::software
    
    TestFrame --> CoreLogic
    DocSystem --> CoreLogic

    %% Click events for component mapping
    click CorePlotter "https://github.com/evildmp/brachiograph/blob/master/brachiograph.py"
    click MovePlanner "https://github.com/evildmp/brachiograph/blob/master/plotter.py"
    click LineProc "https://github.com/evildmp/brachiograph/blob/master/linedraw.py"
    click TurtleSim "https://github.com/evildmp/brachiograph/blob/master/turtle_plotter.py"
    click PenMech "https://github.com/evildmp/brachiograph/blob/master/pen.py"
    click ServoCtrl "https://github.com/evildmp/brachiograph/blob/master/bg.py"
    click TestFrame "https://github.com/evildmp/brachiograph/tree/master/tests/"
    click DocSystem "https://github.com/evildmp/brachiograph/blob/master/docs/explanation/how-it-works.rst"
    click Arms "https://github.com/evildmp/brachiograph/blob/master/docs/explanation/hardware.rst"
    click Geometry "https://github.com/evildmp/brachiograph/blob/master/docs/explanation/mathematics.rst"
    click PatternGen "https://github.com/evildmp/brachiograph/tree/master/test-patterns/"

    %% Legend
    subgraph Legend
        SW["Software Component"]:::software
        HW["Hardware Component"]:::hardware
        IF["Interface"]:::interface
        CR["Critical Component"]:::critical
    end
```
