Comparing to React

← Documentation
STRVCT

A technical guide and conceptual "Rosetta Stone" for React developers exploring Strvct.

Core Architectural Divergence

React and Strvct both keep user interfaces synchronized with application state, but they start from opposite design philosophies:

  • React is a View-First Library: You author component trees in JSX, manage component state (useState, useReducer, Redux, Zustand), and write custom render functions. You are responsible for integrating state management, form components, ORMs, REST/GraphQL APIs, routing, internationalization, and accessibility.
  • Strvct is a Model-First Naked Objects Framework: You declare the domain model (SvStorableNode classes) with annotated property slots. The framework automatically derives the user interface, manages local IndexedDB persistence and cloud sync, generates Miller column navigation, and provides an AI tool surface without hand-authored UI code.
React (View-First) Component & Rendering Library You Must Author & Maintain: • UI Components (JSX / TSX) • Form Controls & Validation • State Stores (Redux/Zustand) • Routing & Navigation Graphs • REST/GraphQL/ORM Sync Logic Framework Provides: • Virtual DOM Reconciliation • Component Lifecycle & Hooks • Event Delegation System Requires continuous manual sync across model, UI, & API schemas. Strvct (Model-First) Naked Objects Framework You Author: • Domain Models (SvNode classes) • Slot Annotations (metadata) • Action Methods (business logic) Framework Provides Automatically: • Miller Column UI Generation • Local IndexedDB & Cloud Sync • Native AI Tool Surface • Headless Node.js Execution • Universal Accessibility & i18n Zero UI maintenance cost; model change updates all layers.

Code Comparison: Defining a Editable Contact Record

The React Approach (Manual Component + State + Persistence Wiring)

// ContactForm.jsx - Hand-authored UI component
function ContactForm({ contactId, onSave }) {
    const [name, setName] = useState("");
    const [email, setEmail] = useState("");
    const [errors, setErrors] = useState({});

    useEffect(() => {
        // Fetch from API or local store
        api.getContact(contactId).then(data => {
            setName(data.name);
            setEmail(data.email);
        });
    }, [contactId]);

    const handleSubmit = async (e) => {
        e.preventDefault();
        if (!email.includes("@")) {
            setErrors({ email: "Invalid email address" });
            return;
        }
        await api.updateContact(contactId, { name, email });
        onSave();
    };

    return (
        <form onSubmit={handleSubmit} className="contact-form">
            <label>Name:
                <input value={name} onChange={e => setName(e.target.value)} />
            </label>
            <label>Email:
                <input value={email} onChange={e => setEmail(e.target.value)} />
                {errors.email && <span className="error">{errors.email}</span>}
            </label>
            <button type="submit">Save Changes</button>
        </form>
    );
}

Summary: Requires manually coding state hooks, form inputs, validation error handlers, API serializers, and submit listeners.

The Strvct Approach (Model-First Slot Declaration)

// Contact.js - Annotated domain model
(class Contact extends SvStorableNode {

    initPrototypeSlots () {
        {
            const slot = this.newSlot("name", "");
            slot.setSlotType("String");
            slot.setShouldStoreSlot(true);   // Persist to IndexedDB
            slot.setSyncsToView(true);       // Live UI update
            slot.setCanEditInspection(true); // Editable field
        }
        {
            const slot = this.newSlot("email", "");
            slot.setSlotType("String");
            slot.setShouldStoreSlot(true);
            slot.setSyncsToView(true);
            slot.setCanEditInspection(true);
        }
    }

    initPrototype () {
        this.setTitle("Contact");
        this.setShouldStore(true);
    }

}.initThisClass());

Summary: Declares properties and metadata once. Strvct automatically derives editable UI input fields, handles IndexedDB persistence, emits change notifications, generates Miller column navigation tiles, and exposes an AI tool specification.

Concept Mapping ("Rosetta Stone")

React ConceptStrvct EquivalentArchitectural Difference
Component (JSX)SvNodeView (Auto-generated or custom subclass)React components render JSX trees. Strvct views are derived lazily at runtime from SvNode slot metadata.
State (useState)Slot getters/setters (this.name(), this.setName(v))React state lives in components. Strvct state lives in model slots (setSyncsToView(true)).
Context / Redux StoreSvNotificationCenter & SvModel Object GraphReact uses context or external stores for global state. Strvct uses a single local object graph with notification observers.
Effects (useEffect)Notification Observations (SvNotificationCenter)React runs effect hooks after render passes. Strvct observes model events via weak notifications.
React Router / Next.jsMiller Column Navigation (SvStackView, SvNavView)React maps URLs to components manually. Strvct derives navigation paths directly from parent-child object relationships.
ORM / REST API SyncSvPersistentObjectPool (IndexedDB + Cloud)React requires custom API calls (Axios/TanStack Query). Strvct commits dirty nodes automatically at the end of each event loop.
Virtual DOM ReconciliationPer-Slot Notification Sync (SvSyncScheduler)React diffs full virtual DOM trees. Strvct updates individual DOM elements directly via coalesced slot change passes.
Bundlers (Vite / Webpack)Content-Addressable Memory (CAM) SystemReact bundles code into chunks. Strvct caches individual source files in IndexedDB by SHA-256 hash.
TypeScript / Prop TypesSlot Type Declarations (slot.setSlotType("String"))React uses compile-time type checking. Strvct enforces runtime type checking on setters and AI JSON patches.

State & Change Propagation

React (Unidirectional Data Flow) 1. State Change (useState / Redux) 2. Component Subtree Re-Render 3. Virtual DOM Tree Diffing 4. Real DOM Minimal Patch Strvct (Asymmetric Notification) 1. View Calls Model Setter 2. Model Slot Updates Internal State 3. Notification Posted via Center 4. Coalesced View Pull & Render
  • React: Uses unidirectional data flow with Virtual DOM diffing. A state update triggers a re-render of the component subtree, computing a Virtual DOM delta to patch the real DOM.
  • Strvct: Uses an asymmetric notification model. Views call setter methods on model nodes. Setters update slot state and post named notifications via SvNotificationCenter. SvSyncScheduler coalesces multiple updates within the event loop, notifying observing views to pull updated values directly.

Detailed Paradigm Comparison

DimensionReact EcosystemStrvct Framework
Primary ArtifactAuthored Component Trees (JSX)Annotated Domain Models (SvNode)
UI DerivationManual per screen100% Derived automatically
Persistence StrategyCustom integration (REST, GraphQL, Firebase)Built-in local IndexedDB pools + Cloud Sync
Offline SupportComplex PWA / Service Worker setupNative local-first (offline by default)
AI Agent InteropCustom per-screen tool definitionsNative constant-size tool surface (schema-fetch / apply-patch)
Headless TestingRequires jsdom / PuppeteerNative Node.js execution (zero DOM dependencies)
InternationalizationManual string wrapping & translation filesIntercepted centrally at tile primitive boundary
Module EcosystemFull npm ecosystem & Vite / WebpackVendored libraries & Content-Addressable Memory (CAM)

Decision Matrix: When to Use Which?

Choose React When:

  • You are building a marketing site, landing page, or media-rich portal requiring highly branded, bespoke visuals.
  • Server-Side Rendering (SSR) or Search Engine Optimization (SEO) is a primary business requirement.
  • Your application relies heavily on third-party npm UI component libraries (e.g., shadcn/ui, MUI, Ant Design).
  • Your UI design bears no structural relationship to a structured domain model.

Choose Strvct When:

  • You are building a data-model-intensive application (CRMs, ERPs, project management, RPG gaming tools, settings panels).
  • You want zero-maintenance UI generation and client-side persistence without writing component or glue code.
  • You want native, zero-cost AI agent operability over your entire data model.
  • You are building a local-first application that must function offline with cloud synchronization.
  • You want ultra-fast, headless unit and integration testing under Node.js without browser automation.