# bullwinkle3000/dactyl-keyboard architecture

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

- Interactive diagram: https://gitdiagram.com/bullwinkle3000/dactyl-keyboard
- Repository: https://github.com/bullwinkle3000/dactyl-keyboard

## Overview

##### Project type and purpose
- This is a Python-based model generator (“open-source tool”) for creating parameterized ergonomic keyboard geometries (Dactyl-Manuform and trackball clusters) in CAD formats (OpenSCAD/STEP/STL).
- It provides a CLI and scripts to load JSON configurations, assemble geometric primitives via CadQuery or SolidPython/OpenSCAD, and output ready-to-print 3D models.

##### File structure
- Top-level scripts:
- dactyl_manuform.py: main entrypoint
- generate_configuration.py: builds or mutates run_config.json
- model_builder.py / bulk_build.py / builder.py: orchestrate batch and single-run builds
- Configuration:
- configs/default.json
- run_config.json / run_config.yaml
- src/json/…: library of JSON snippets (materials, mounts, options, clusters)
- Core source tree (src/):
- src/clusters: cluster classes (strategy-pattern—each subclass encapsulates a thumb/trackball cluster)
- src/helpers_*: abstraction over geometry engines (CadQuery vs. SolidPython)
- src/json_loader.py: loads & merges JSON fragments into in-memory config
- src/build_report.py: reporting/logging
- src/model_builder.py: high-level build step
- Output directories:
- things/: final generated SCAD, STEP, STL, DXF files
- DevOps and environment:
- Dockerfile, build scripts (run.sh, dactyl.sh, Makefile)
- conda.sh, shell.nix, .github/workflows/release.yaml

##### README for additional insights
- Two “ENGINES”: “solid” (OpenSCAD/SolidPython) vs. “cadquery” (OpenCascade via CadQuery).
- Multiple runner environments: Docker, Conda, direct Python.
- Workflow: configure → run dactyl_manuform.py → files drop into things/
- Extensibility points: “overrides” JSON, custom clusters, custom plate geometry imports.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Swimlanes
    subgraph "User/CLI Layer"
        direction TB
        CLI["CLI Runner\n(dactyl_manuform.py)"]:::code
        CLI2["Bulk Runner\n(bulk_build.py)"]:::code
    end

    subgraph "Config Layer"
        direction TB
        GenConfig["Configuration Manager\n(generate_configuration.py)"]:::code
        DefaultCfg["Default Config\n(configs/default.json)"]:::data
        RunCfg["Run Config\n(run_config.json / run_config.yaml)"]:::data
        JSONLoader["JSON Loader & Config Merger\n(json_loader.py)"]:::code
        JSONLib["JSON Library\n(src/json)"]:::dir
        ClustersJSON["Cluster Prototypes\n(src/clusters/json)"]:::dir
    end

    subgraph "Build Layer"
        direction TB
        BuilderCore["Model Builder Core\n(model_builder.py / builder.py)"]:::code
        Strategy["Cluster Strategy Module\n(src/clusters)"]:::code
        Report["Build Reporting\n(build_report.py)"]:::code
    end

    subgraph "Engine Layer"
        direction TB
        EngineSwitch{"ENGINE = cadquery | solid"}:::decision
        SolidEngine["SolidPython/OpenSCAD Adapter\n(helpers_solid.py)"]:::code
        CadEngine["CadQuery/OpenCascade Adapter\n(helpers_cadquery.py)"]:::code
        BlenderEngine["Blender Adapter\n(helpers_blender.py)"]:::code
    end

    subgraph "Output Layer"
        direction TB
        OutputWriter["Output File Writer\n(STL/STEP/SCAD exporters)"]:::code
        OutputDir["things/"]:::dir
        PartsRepo["Parts Repository\n(src/parts)"]:::dir
    end

    subgraph "DevOps Layer"
        direction TB
        Docker["Docker Environment\n(docker/Dockerfile)"]:::external
        Conda["Conda/ShellNix\n(conda.sh / shell.nix)"]:::external
        CI["CI/CD Workflow\n(.github/workflows/release.yaml)"]:::external
        Scripts["CLI Helpers\n(run.sh / dactyl.sh / Makefile)"]:::external
    end

    %% Flows
    CLI -->|invokes| GenConfig
    CLI2 -->|invokes| BuilderCore
    GenConfig -->|reads/writes| DefaultCfg
    GenConfig -->|reads/writes| RunCfg
    GenConfig --> JSONLoader
    JSONLoader --> JSONLib
    JSONLoader --> ClustersJSON
    JSONLoader -->|outputs merged config| BuilderCore
    BuilderCore --> Strategy
    BuilderCore --> Report
    BuilderCore --> EngineSwitch
    EngineSwitch -->|solid| SolidEngine
    EngineSwitch -->|cadquery| CadEngine
    EngineSwitch -->|blender| BlenderEngine
    SolidEngine --> OutputWriter
    CadEngine --> OutputWriter
    BlenderEngine --> OutputWriter
    Strategy -->|provides cluster objs| BuilderCore
    OutputWriter --> OutputDir
    OutputWriter --> PartsRepo
    CLI --> Docker
    CLI --> Conda
    CLI --> CI
    CLI --> Scripts

    %% Click Events
    click CLI "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/dactyl_manuform.py"
    click CLI2 "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/bulk_build.py"
    click GenConfig "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/generate_configuration.py"
    click DefaultCfg "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/configs/default.json"
    click RunCfg "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/run_config.json"
    click RunCfg "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/run_config.yaml"
    click JSONLoader "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/json_loader.py"
    click Strategy "https://github.com/bullwinkle3000/dactyl-keyboard/tree/wilder/src/clusters"
    click ClustersJSON "https://github.com/bullwinkle3000/dactyl-keyboard/tree/wilder/src/clusters/json"
    click SolidEngine "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/helpers_solid.py"
    click CadEngine "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/helpers_cadquery.py"
    click BlenderEngine "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/helpers_blender.py"
    click BuilderCore "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/model_builder.py"
    click BuilderCore "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/builder.py"
    click Report "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/src/build_report.py"
    click JSONLib "https://github.com/bullwinkle3000/dactyl-keyboard/tree/wilder/src/json"
    click PartsRepo "https://github.com/bullwinkle3000/dactyl-keyboard/tree/wilder/src/parts"
    click OutputDir "https://github.com/bullwinkle3000/dactyl-keyboard/tree/wilder/things/"
    click Docker "https://github.com/bullwinkle3000/dactyl-keyboard/tree/wilder/docker/Dockerfile"
    click Conda "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/conda.sh"
    click Conda "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/shell.nix"
    click CI "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/.github/workflows/release.yaml"
    click Scripts "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/run.sh"
    click Scripts "https://github.com/bullwinkle3000/dactyl-keyboard/blob/wilder/dactyl.sh"
    click Scripts "https://github.com/bullwinkle3000/dactyl-keyboard/tree/wilder/Makefile"

    %% Styles
    classDef code fill:#AED6F1,stroke:#21618C,stroke-width:1px
    classDef data fill:#ABEBC6,stroke:#1D8348,stroke-width:1px
    classDef external fill:#F5B041,stroke:#B9770E,stroke-width:1px
    classDef dir fill:#D5D8DC,stroke:#566573,stroke-width:1px
    classDef decision fill:#F8C471,stroke:#B9770E,stroke-width:1px,stroke-dasharray: 5 5
```
