How iliasbhal/statebuild works
Main components
• Core Engine (src/core)
– Atom, Selector, Reaction, State, Track, base Entity
– Implements the observer/graph-based state model
• Query Layer (src/query)
– Exposes programmatic query APIs on top of core entities
• React Integration (src/react)
– Custom hooks (useAtom, useSelector, useReaction, useBuild, useInstance, useEntity)
– Enables automatic re-rendering via makeRenderable & enableAutoRendering
• Utilities (src/utils + src/core/utils)
– DependencyGraph, EventBus, MapSet, disposable, Generator, convertToCallback, useForceRender
– Support data structures, event dispatching, and helper functions
• Build & Test Infrastructure
– Configuration: tsconfig.json, babel, jest.config.js
– Build scripts: scripts/playground.ts
– CI workflows: .github/workflows/*.yml
Relationships & data flow
• Core Engine is central. Query and React modules depend on it.
• React hooks invoke core Atom/Selector APIs, subscribe to updates via EventBus/DependencyGraph, then trigger component re-render.
• Query layer wraps core APIs to expose higher-level querying functions.
• Utility modules are shared dependencies consumed by Core, Query, and React layers.
• Build/Test infrastructure orchestrates bundling and validation but does not ship in runtime.
Architectural patterns
• Observer/Reactive pattern: Atoms/Sels/Reactions form a dependency graph tracked by Track & DependencyGraph.
• Adapter pattern: Query and React modules adapt the core engine to different usage contexts.
• Modular “layered library” approach: clear separation between engine, adapters, and helpers.