Minimact Client Architecture: Layered Reactive DOM Stack โ
Minimact's client modules form a coherent hierarchy of reactive capabilities โ from predictive rendering to distributed DOM synchronization.
Each layer is a separate npm package. Install only what you need.
The Evolution Stack โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ minimact-quantum โ โ 6๏ธโฃ Distributed Identity
โ Entanglement Protocol โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ minimact-trees โ โ 5๏ธโฃ Semantic Trees
โ Declarative State โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ minimact-spatial โ โ 4๏ธโฃ Layout & Flow Analysis
โ Viewport as 2D Database โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ minimact-dynamic โ โ 3๏ธโฃ Function-Based Binding
โ Structure/Logic Split โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ minimact-query โ โ 2๏ธโฃ SQL for Reactive DOM
โ Relational Queries โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ minimact-punch โ โ 1๏ธโฃ DOM as Reactive State
โ 80+ Observable Props โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ minimact (core) โ โ 0๏ธโฃ Predictive Rendering
โ 13.33 KB Runtime โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโThe Journey:
React โ Reactive DOM โ Queryable DOM โ Predictive Layout โ Distributed DOM0๏ธโฃ minimact (Core) โ
Foundation: Predictive rendering, state hooks, and patch cache execution.
npm install minimactWhat It Includes โ
- Hooks:
useState,useEffect,useRef,useContext,useComputed,useServerTask - Predictive patches via template cache
- Server-rendered HTML with client patch application
- 13.33 KB runtime (gzipped) โ 71% smaller than React
- Alternative:
minimact-rwith full SignalR (25.03 KB)
Key Features โ
// Server-managed state
const [count, setCount] = useState(0);
// Client-only state (no server round-trip)
const [isOpen, setIsOpen] = useClientState(false);
// Long-running server tasks with progress
const [task, startTask] = useServerTask(async (updateProgress) => {
for (let i = 0; i <= 100; i += 10) {
await delay(500);
updateProgress(i);
}
return 'Complete!';
});1๏ธโฃ minimact-punch: DOM as Reactive Data Source โ
Capability: Make the DOM observable โ structure, pseudo-state, styles, lifecycle.
npm install minimact-punchWhat It Adds โ
useDomElementState(selector)- Makes DOM queryable like a database- 80+ reactive properties (isIntersecting, childrenCount, attributes, classList, etc.)
- MutationObserver integration (automatic updates)
- IntersectionObserver integration (viewport tracking)
- Statistical aggregates (
.vals.avg(),.vals.sum(),.vals.median()) - Collection queries (count, map, filter, find)
- MES Silver certified (Minimact Extension Standards)
Example โ
import { useDomElementState } from 'minimact-punch';
function AdaptiveHeader() {
const scrollContainer = useDomElementState('#main-content');
return (
<header className={scrollContainer.scrollTop > 100 ? 'compact' : 'full'}>
{/* Header adapts based on scroll position */}
</header>
);
}See: DOM as Data Source Use Cases
2๏ธโฃ minimact-query: SQL for the DOM โ
Capability: Query reactive DOM state declaratively with SQL semantics.
npm install minimact-queryWhat It Adds โ
useDomQuery()- Query DOM like a relational database- Full SQL semantics (SELECT, FROM, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT)
- Aggregate functions (COUNT, SUM, AVG, MIN, MAX, STDDEV)
- Set operations (UNION, INTERSECT, EXCEPT, DISTINCT)
- Reactive by default (queries auto-update when DOM changes)
- Type-safe with autocomplete for 80+ DOM properties
- Performance optimized (throttling/debouncing built-in)
Example โ
import { useDomQuery } from 'minimact-query';
function PerformanceMonitor() {
const unstableComponents = useDomQuery()
.from('.component')
.where(c => c.history.changesPerSecond > 10)
.orderBy(c => c.history.volatility, 'DESC')
.limit(10);
return (
<div>
<h3>Unstable Components ({unstableComponents.count})</h3>
{unstableComponents.map(c => (
<div>{c.id}: {c.history.changesPerSecond} changes/sec</div>
))}
</div>
);
}Status: ๐งช Experimental (in development)
3๏ธโฃ minimact-dynamic: Function-Based Value Binding โ
Capability: Separate structure from logic. JSX stays clean; logic lives in TypeScript functions.
npm install minimact-dynamicWhat It Adds โ
useDynamicState(selector, fn)- Separate structure from content- Define DOM once, bind values with functions
- Auto dependency tracking with Proxy
- Direct DOM updates (< 1ms, no VDOM)
- Server pre-compilation support
- Minimal bundle (< 3KB gzipped)
Example โ
import { dynamic } from 'minimact-dynamic';
function PricingCard({ product, user }) {
// Structure ONCE
return (
<div className="card">
<span className="price"></span>
</div>
);
}
// Bind SEPARATELY (logic outside JSX)
dynamic('.price', (state) =>
state.user.isPremium
? state.product.factoryPrice
: state.product.price
);Key Benefit: Structure is static, logic is dynamic. Re-bind without re-rendering.
4๏ธโฃ minimact-spatial: Physical Layout Reasoning โ
Capability: DOM spatial intelligence โ gaps, overlaps, flow, lookahead/lookbehind.
npm install minimact-spatialWhat It Adds โ
useArea()- Query spatial regions of the viewport- Track coverage, density, element counts
- Reactive spatial queries
- Region-based event handling
- Spatial collision detection
Example โ
import { useArea } from 'minimact-spatial';
function AdaptiveLayout() {
const header = useArea({ top: 0, height: 80 });
const sidebar = useArea('#sidebar');
return (
<div>
{header.isFull && <CompactMode />}
{sidebar.elementsCount > 10 && <ScrollIndicator />}
</div>
);
}Use Cases:
- Sticky headers that adapt to content
- Scroll indicators based on viewport coverage
- Layout collision detection
- Responsive design based on actual layout (not just viewport size)
5๏ธโฃ minimact-trees: Declarative State Machines โ
Capability: Understand ancestry, depth, siblings, and tree relationships declaratively.
npm install minimact-treesWhat It Adds โ
useDecisionTree()- XState but minimal and declarative- Universal value type support (any primitive or object)
- Nested decision paths
- Predictive transition pre-computation
- Server-side rendering integration
- TypeScript inference for tree structure
Example โ
import { useDecisionTree } from 'minimact-trees';
function PricingEngine({ user, cartSize }) {
const price = useDecisionTree({
roleAdmin: 0,
rolePremium: {
count5: 0,
count3: 5
},
roleBasic: 10
}, { role: user.role, count: cartSize });
return <div>Price: ${price}</div>;
}Key Insight: Decision trees are predictable state machines. Server can pre-compute all transitions.
6๏ธโฃ minimact-quantum: The Entangled DOM โ
Capability: DOM sync across clients & pages. Mutation vectors. Shared identity.
npm install minimact-quantumWhat It Adds โ
- Multi-client DOM synchronization across physical space
- Identity sync (not data sync - same element in two places at once)
- Mutation vectors for efficient transmission
- Bidirectional entanglement
- Operational Transform for conflict resolution
- 100x bandwidth reduction vs full state sync
- WebWormhole integration for P2P
Example โ
import { quantum } from 'minimact-quantum';
async function CollaborativeSlider() {
const slider = document.querySelector('#volume-slider');
// User A in New York, User B in Tokyo
const link = await quantum.entangle(slider, {
clientId: 'user-b',
selector: '#volume-slider'
}, 'bidirectional');
// User A drags โ User B's slider moves instantly
// SAME IDENTITY. DIFFERENT SPACETIME COORDINATES.
}Key Concept:
Traditional: Sync data, reconstruct UI
Quantum: Sync DOM identity, mutations propagateStatus: ๐งช Experimental (proof-of-concept)
Layer Composition โ
Each layer builds on the previous:
| Layer | Adds | Builds On |
|---|---|---|
| 0: Core | Predictive rendering | Server HTML |
| 1: Punch | DOM observability | Core state |
| 2: Query | Relational queries | Punch properties |
| 3: Dynamic | Function binding | Core patches |
| 4: Spatial | Layout intelligence | Punch spatial data |
| 5: Trees | State machines | Core prediction |
| 6: Quantum | Multi-client sync | Core patches + Punch state |
You can use any layer without the ones above it.
Example:
- Use just
minimact-dynamicwith core (no Punch/Query needed) - Use
minimact-spatialwithout Query - Use
minimact-quantumdirectly with core
Philosophy: From React to Reactive โ
Traditional React โ
React Component โ VDOM โ Reconciliation โ DOMMinimact Core โ
TSX Component โ Server Render โ Predictive Patches โ DOMMinimact + Extensions โ
TSX Component โ Server Render โ Predictive Patches โ DOM
โ
Observable State
โ
SQL Queries
โ
Function Bindings
โ
Spatial Reasoning
โ
State Machines
โ
Quantum SyncThe DOM becomes:
- Reactive (Punch) - Observable like state
- Queryable (Query) - Relational like a database
- Declarative (Dynamic) - Bindable like templates
- Spatial (Spatial) - Geometric like a canvas
- Structural (Trees) - Hierarchical like a filesystem
- Distributed (Quantum) - Synchronized like CRDT
Production Readiness โ
โ Production-Ready โ
- minimact (core)
- minimact-punch (MES Silver certified)
- minimact-dynamic
- minimact-spatial
- minimact-trees
๐งช Experimental โ
- minimact-query (in development)
- minimact-quantum (proof-of-concept)
Next Steps โ
- What Makes Minimact Different - Core paradigm
- Predictive Rendering 101 - How prediction works
- Use Cases - Real-world applications
- Hooks API - Complete hook reference
React gave us components.
Minimact gives us a reactive, queryable, distributed DOM.
๐ต The future is layered. ๐ต
