How Schemas Become Components β
System that transforms JSON into functional components β schema in, interface out.

Factory Pattern is the heart of schepta:
π§ What It Is: β
| Input | Factory | Output | Result |
|---|---|---|---|
| Form JSON | FormFactory | React/Vue Form | Working interface |
| Menu JSON | MenuFactory | React/Vue Navigation | Complete navigation |
| Component JSON | ComponentFactory | React/Vue Component | Rendered component |
π How It Works: β
Automatic Process:
- JSON Schema defines structure and behavior
- Factory interprets schema and resolves components
- Component Registry provides React/Vue components to be rendered
- Middleware Pipeline transforms props
- React/Vue Component renders final interface
Quick Example:
json
{ "fields": [{ "name": "email", "x-component": "InputEmail" }] }β FormFactory processes
jsx
<input type="email" name="email" />π‘ 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 Property | Function | Example | Result |
|---|---|---|---|
fields[] | Defines form fields | [{ name: "email" }] | Email field |
x-component | Input type | "InputText" | Text input |
required | Required validation | true | Required field |
x-rules | Custom validations | { minLength: 8 } | Length validation |
π§ MenuFactory - Dynamic Navigation: β
| Schema Property | Function | Example | Result |
|---|---|---|---|
properties{} | Defines menu items | { "home": {...} } | Navigation item |
x-component-props.href | Navigation link | "/dashboard" | Working link |
active | Visibility control | "\{\{ $segment.role === 'admin' \}\}" | Permission-based menu |
properties.submenu | Hierarchical submenu | Nested properties | Dropdown menu |
ποΈ ComponentFactory - Generic Components: β
| Schema Property | Function | Example | Result |
|---|---|---|---|
x-component | Component type | "Button" | React/Vue button |
x-component-props | Specific props | { variant: "primary" } | Styled button |
x-ui | Layout and positioning | { grid: { xs: 12 } } | Responsive grid |
βοΈ Factory Architecture β
How the Factory Pattern works internally:
π Processing Pipeline: β
JSON Schema
β
Validate Schema (Correct structure?)
β
Resolve Components (x-component β React/Vue component)
β
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 FormContext, applies validations, manages state
- MenuFactory: Manages navigation, active states, menu hierarchy
- ComponentFactory: Generic rendering, simple props, no specific context
Extension points: Component Registry (global/local), Middleware Pipeline (custom transformations), Context Providers (domain-specific state).
π Practical Use Cases β
Factory Pattern solves real development problems:
π― Solved Scenarios: β
| Situation | Traditional Problem | With Factory Pattern | Benefit |
|---|---|---|---|
| Repetitive Forms | Copy-paste JSX | Reusable schema | DRY principle |
| Complex Validations | Duplicated code | Rules in schema | Centralization |
| Dynamic Menus | Hardcoded conditionals | visible expressions | Flexibility |
| Multi-tenant UI | Branches per client | Schema per tenant | Scalability |
| A/B Testing | Complex feature flags | Different schemas | Agility |
π Essential Links β
| To Understand | Read | Relation to Factories |
|---|---|---|
| How to write schemas | 02. Schema Language | Syntax that factories interpret |
| Internal pipeline | 04. Schema Resolution | How factories process schemas |
| Rendering engine | 05. Renderer | System used by factories |
| Props transformations | 06. Middleware | Pipeline applied by factories |
| Global configuration | 03. Provider | How to configure factories |