Skip to content

How Schemas Become Components

System that transforms JSON into functional components — schema in, interface out.

Factories

Factory Pattern is the heart of schepta:

What It Is:

InputFactoryOutputResultStatus
Form JSONFormFactoryReact/Vue FormWorking interfaceReady
Menu JSONMenuFactoryReact/Vue NavigationComplete navigationIn development

How It Works:

Automatic Process:

  1. JSON Schema defines structure and behavior (using properties and x-component per node)
  2. Factory interprets schema and resolves components from the registry (defaults + Provider + local props)
  3. Middleware Pipeline transforms props (e.g. template expressions)
  4. React/Vue Component renders final interface

Quick Example:

json
{
  "type": "object",
  "x-component": "FormContainer",
  "properties": {
    "email": {
      "type": "string",
      "x-component": "InputText",
      "x-component-props": { "placeholder": "Email" }
    }
  }
}

FormFactory processes

jsx
<form>
  <input name="email" placeholder="Email" />
</form>

Result: Structured JSON → Functional React/Vue interface. Zero manual configuration!

Factory Types

Each Factory is specialized in a type of interface:

FormFactory - Dynamic Forms:

Schema PropertyFunctionExampleResult
propertiesDefines form structure (JSON Schema){ "email": { ... } }Nested nodes with components
x-componentComponent to render"InputText"Text input
x-component-propsProps for the component{ "placeholder": "Email" }Passed to component
Schema PropertyFunctionExampleResult
propertiesDefines menu items{ "home": {...} }Navigation item
x-component-props.hrefNavigation link"/dashboard"Working link
properties.submenuHierarchical submenuNested propertiesDropdown menu

Factory Architecture

How the Factory Pattern works internally:

Processing Pipeline:

JSON Schema

Validate Schema (Correct structure?)

Resolve Components (x-component → component from defaults / Provider / local)

Transform Props (Middleware + context)

Orchestrate Render (Final component tree)

React/Vue Elements

How Factories Specialize:

Each Factory has specific logic for its domain:

  • FormFactory: Injects form adapter context, applies validations, manages state
  • MenuFactory: Manages navigation, active states, menu hierarchy

Extension points: Provider components and customComponents, Factory props for local overrides, Middleware Pipeline (e.g. middlewares array), externalContext for shared state.

Practical Use Cases

Factory Pattern solves real development problems:

Solved Scenarios:

SituationTraditional ProblemWith Factory PatternBenefit
Repetitive FormsCopy-paste JSXReusable schemaDRY principle
Complex ValidationsDuplicated codeRules in schemaCentralization
Dynamic MenusHardcoded conditionalsExpressions in propsFlexibility
Multi-tenant UIBranches per clientSchema per tenantScalability
A/B TestingComplex feature flagsDifferent schemasAgility
To UnderstandReadRelation to Factories
How to write schemas02. Schema LanguageSyntax that factories interpret
Internal pipeline04. Schema ResolutionHow factories process schemas
Rendering engine05. RendererSystem used by factories
Props transformations06. MiddlewarePipeline applied by factories
Global configuration03. ProviderHow to configure factories