Skip to content

Code Base

This section is for developers who want to read, build or change ShapeLogic. The rest of the user guide explains how to use the app; these pages explain how it is made.

ShapeLogic is three programs over one library:

the desktop app (web/: Electron + TypeScript + three.js)
│ JSON-RPC 2.0 over stdio, binary frames for meshes
▼
shapelogic_engine (engine/) shapelogic_cli (cli/) shapelogic (python/, the Python module)
│ │ │
└──────────────┬──────────────┴───────────────────────────┘
▼
libsl_core (core/shapelogic/)
app Document, undo/redo, editing commands, queries, playback, explorers
solve assemblers, disassemblers, rotation rules, SolveSession
mesh half-edge meshes and drawing meshes for all grids
io XML, gzip, .xmpuzzle reader/writer
model Puzzle, Problem, Assembly, Disassembly, Solution
grid grid types, voxel spaces, symmetry tables
base StopToken, SolveState, Result/Error, SL_ASSERT, thread pool
  • The core (core/) is a C++ library. It knows nothing about windows, JSON or files on disk beyond reading and writing puzzles. It never prints and has no global state.
  • The engine (engine/) wraps one open puzzle (a Document) in a process that speaks JSON-RPC over its standard input and output. Every feature the app offers is a method of the engine.
  • The app (web/) is an Electron application. Its window is a sandboxed web page that can only talk to the engine. The 3D view is three.js. The app never computes what the engine can answer: cells, fits, counts, meshes and sort orders all come from the engine.
  • The command line tool (cli/) and the Python module (python/) use the same core directly, without the engine.
  • The website (site/) is this user guide and the landing page, built with Astro Starlight, plus a browser demo of the app with the engine compiled to WebAssembly.

ShapeLogic is a rebuild of BurrTools. Its answers were checked against the original’s while it was ported, and a regression suite keeps them: it compares the solver with the answers recorded then. Many files begin with a comment naming the original file they were ported from.

If you are new, read the pages in the order above. The Example Solve Flow ties the others together: it crosses every layer, from a button in the web page to the threads of the search and back.

The repository’s own documents go further than these pages. Start with AGENTS.md at the root (the working rules), then docs/ARCHITECTURE.md (a map of every module, file by file, and its rules) and the decision records in docs/decisions/; the hand-off notes in docs/handoff/ are the history. The engine’s methods are documented in docs/API.md, generated from the schema in api/.