$ show samuelmtimbo/unit
This is a comprehensive visual programming system called 'Unit' that implements a dataflow/reactive paradigm where programs are composed of interconnected units (MIMO finite state machines) in a directed graph. The system includes a full-stack runtime (Node.js server and browser client), a graph editor UI with drag-and-drop, a rich library of built-in functional units (arithmetic, string, array, control flow, etc.), platform API wrappers (canvas, audio, Bluetooth, WebSocket, etc.), and a custom spec language for defining units. The architecture is centered around a core class hierarchy (Unit, Graph, Pin, Component) with a reactive push-based execution model. The project is actively maintained with a large community (4920 stars) and demonstrates sophisticated engineering in areas like force-directed layout simulation, custom parser with type inference, and a comprehensive debugging infrastructure. While the codebase is extensive and well-structured, some components (e.g., the main Component class) are large and tightly coupled, and there are signs of duplication and incomplete implementations in some areas.
The LLM identified 3 files worth highlighting for reuse:
A generic binary heap implementation supporting both synchronous and asynchronous operations (push, pop, peek). Uses bubble-up/bubble-down algorithms and includes a findRoot method. The class is self-contained, well-typed, and could be extracted into any TypeScript project needing a priority queue.
A force-directed graph layout simulation using Runge-Kutta integration (RK1–RK4) with configurable alpha decay, repulsion, and attraction forces. The simulation is parameterized and can be applied to any node-edge graph for visualization. It demonstrates non-trivial numerical integration and is isolated enough for reuse in other graph rendering projects.
A custom parser for the Unit spec language that builds an abstract syntax tree (AST) with 30+ node types, supports generics, type matching, value validation, and generic extraction/application. The parser is self-contained (no heavy external dependencies) and could be adapted for other domain-specific languages requiring type inference and tree manipulation.