Skip to content

guynikan/schepta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

121 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Schepta

Framework-agnostic rendering engine for server-driven UI

Build dynamic forms and UIs from JSON schemas with full support for React, Vue, and Vanilla JavaScript. Schepta provides a powerful, type-safe foundation for creating flexible, schema-driven applications.

TypeScript License: SNCL Tests

✨ Features

  • 🎨 Framework Agnostic Core: Single source of truth that works across React, Vue, and Vanilla JS
  • πŸ“ Schema-Driven Forms: Define complex forms using JSON schemas with validation
  • πŸ”Œ Pluggable Integrations: Built-in support for react-hook-form, Formik, and native form management
  • 🎯 Dynamic Component Registry: Register and resolve components at runtime
  • πŸ”„ Middleware System: Transform schemas and add business logic with composable middlewares
  • 🧩 Custom Components: Easily integrate your own components with full framework support
  • ⚑ Reactive System: Handle both declarative and imperative state management
  • 🎭 Conditional Logic: Show/hide fields based on form values using template expressions
  • πŸ›‘οΈ Type Safe: Full TypeScript support with strict type checking
  • πŸ§ͺ Well Tested: Comprehensive E2E test suite with Playwright

πŸ—οΈ Architecture

Schepta follows a three-layer architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Your Application            β”‚
β”‚   (React, Vue, Vanilla JS)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Factories Layer            β”‚
β”‚  Framework-specific form factories  β”‚
β”‚  β€’ @schepta/factory-react           β”‚
β”‚  β€’ @schepta/factory-vue             β”‚
β”‚  β€’ @schepta/factory-vanilla         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Adapters Layer              β”‚
β”‚  Framework-specific runtime logic   β”‚
β”‚  β€’ @schepta/adapter-react           β”‚
β”‚  β€’ @schepta/adapter-vue             β”‚
β”‚  β€’ @schepta/adapter-vanilla         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Core Layer                β”‚
β”‚  Framework-agnostic engine          β”‚
β”‚  β€’ @schepta/core                    β”‚
β”‚  β€’ Component orchestration          β”‚
β”‚  β€’ Middleware system                β”‚
β”‚  β€’ Schema validation                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Installation

# Using pnpm (recommended)
pnpm install

# Build all packages
pnpm build

Usage Examples

React

import { FormFactory } from '@schepta/factory-react';
import type { FormSchema } from '@schepta/core';

const schema: FormSchema = {
  type: 'object',
  properties: {
    firstName: {
      type: 'string',
      'x-component': 'InputText',
      'x-component-props': {
        label: 'First Name',
        placeholder: 'Enter your first name'
      }
    }
  }
};

function MyForm() {
  const handleSubmit = (values: any) => {
    console.log('Form submitted:', values);
  };

  return (
    <FormFactory
      schema={schema}
      onSubmit={handleSubmit}
    />
  );
}

Vue

<script setup lang="ts">
import { FormFactory } from '@schepta/factory-vue';
import type { FormSchema } from '@schepta/core';

const schema: FormSchema = {
  type: 'object',
  properties: {
    firstName: {
      type: 'string',
      'x-component': 'InputText',
      'x-component-props': {
        label: 'First Name',
        placeholder: 'Enter your first name'
      }
    }
  }
};

const handleSubmit = (values: any) => {
  console.log('Form submitted:', values);
};
</script>

<template>
  <FormFactory
    :schema="schema"
    :on-submit="handleSubmit"
  />
</template>

Vanilla JavaScript

import { createFormFactory } from '@schepta/factory-vanilla';
import type { FormSchema } from '@schepta/core';

const schema: FormSchema = {
  type: 'object',
  properties: {
    firstName: {
      type: 'string',
      'x-component': 'InputText',
      'x-component-props': {
        label: 'First Name',
        placeholder: 'Enter your first name'
      }
    }
  }
};

const container = document.getElementById('form-container');

const factory = createFormFactory({
  schema,
  container,
  onSubmit: (values) => {
    console.log('Form submitted:', values);
  }
});

🎯 Core Concepts

Schema-Driven UI

Define your forms using JSON schemas with custom extensions:

  • x-component: Specify which component to render
  • x-component-props: Pass props to the component
  • x-ui: UI-specific configuration (order, visibility, etc.)
  • x-content: Static content for non-input components

Custom Components

Extend Schepta with your own components:

// React
const customComponents = {
  MyCustomInput: createComponentSpec({
    id: 'MyCustomInput',
    type: 'field',
    component: () => MyCustomInputComponent
  })
};

<FormFactory
  schema={schema}
  customComponents={customComponents}
/>

Middleware System

Transform schemas and add business logic:

const myMiddleware: MiddlewareFn = (node, context) => {
  // Transform node based on context
  if (context.formValues.userType === 'admin') {
    node.props.disabled = false;
  }
  return node;
};

<FormFactory
  schema={schema}
  middlewares={[myMiddleware]}
/>

Template Expressions

Use JEXL expressions for conditional logic:

{
  "properties": {
    "showField": {
      "x-ui": {
        "visible": "{{formValues.userType == 'admin'}}"
      }
    }
  }
}

πŸ“¦ Packages

Core

  • @schepta/core: Framework-agnostic rendering engine
    • Component orchestration
    • Middleware system
    • Schema validation (AJV)
    • Template expressions (JEXL)

Adapters

Framework-specific runtime implementations:

  • @schepta/adapter-react: React runtime with hooks
  • @schepta/adapter-vue: Vue runtime with Composition API
  • @schepta/adapter-vanilla: Vanilla JS runtime with EventEmitter

Factories

Complete form solutions:

  • @schepta/factory-react: React form factory with default components
  • @schepta/factory-vue: Vue form factory with default components
  • @schepta/factory-vanilla: Vanilla JS form factory with default components

πŸŽͺ Live Examples

Visit schepta.org to see Schepta in action with live, interactive examples:

  • React Basic: Native Schepta forms with custom components
  • React + Material UI: Integration with MUI components
  • React + Chakra UI: Integration with Chakra UI
  • React Hook Form: Integration with react-hook-form
  • Formik: Integration with Formik
  • Vue Basic: Native Schepta forms with custom components
  • Vue + Vuetify: Integration with Vuetify
  • Vanilla JS: Pure JavaScript implementation

πŸ§ͺ Testing

Comprehensive E2E test suite using Playwright:

# Run all E2E tests (26 tests)
pnpm test:e2e

# Run specific framework tests
npx playwright test tests/e2e/react.spec.ts
npx playwright test tests/e2e/vue.spec.ts
npx playwright test tests/e2e/vanilla.spec.ts

# Run with UI mode
pnpm test:e2e:ui

# Run unit tests
pnpm test

Test Coverage

  • βœ… React: 11 E2E tests (including RHF and Formik integrations)
  • βœ… Vue: 8 E2E tests
  • βœ… Vanilla: 7 E2E tests

πŸ“š Documentation

Full documentation is available at schepta.org

Documentation includes:

  • πŸ“– Getting Started guides
  • πŸ”§ API reference
  • πŸ—οΈ Architecture overview
  • πŸ”Œ Integration guides
  • πŸ“ Examples and recipes
  • 🎯 Best practices

πŸ› οΈ Development

Quick Start

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run type checking
pnpm type-check

# Run linting
pnpm lint

Package Development

# Watch mode for a specific package
cd packages/core && pnpm dev
cd packages/adapters/react && pnpm dev
cd packages/factories/react && pnpm dev

# Clean build artifacts
pnpm clean

For detailed contribution guidelines, visit the documentation.

πŸ“ Project Structure

schepta/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/                    # Framework-agnostic core
β”‚   β”œβ”€β”€ adapters/
β”‚   β”‚   β”œβ”€β”€ react/              # React adapter
β”‚   β”‚   β”œβ”€β”€ vue/                # Vue adapter
β”‚   β”‚   └── vanilla/            # Vanilla JS adapter
β”‚   └── factories/
β”‚       β”œβ”€β”€ react/              # React form factory
β”‚       β”œβ”€β”€ vue/                # Vue form factory
β”‚       └── vanilla/            # Vanilla JS form factory
β”œβ”€β”€ tests/                      # E2E tests with Playwright
β”‚   β”œβ”€β”€ e2e/                   # Test specs
β”‚   └── playwright.config.ts   # Playwright configuration
β”œβ”€β”€ instances/                  # Shared schema instances
β”‚   └── form/                  # Form schemas
β”œβ”€β”€ docs/                       # Documentation site (VitePress)
β”‚   β”œβ”€β”€ .vitepress/
β”‚   β”‚   └── showcases/         # Interactive showcases (React, Vue, Vanilla)
β”‚   β”‚       β”œβ”€β”€ react/         # React examples (basic, MUI, Chakra, RHF, Formik)
β”‚   β”‚       β”œβ”€β”€ vue/           # Vue examples (basic, Vuetify)
β”‚   β”‚       └── vanilla/       # Vanilla JS examples
β”‚   β”œβ”€β”€ en-US/showcases/       # Showcase pages (English)
β”‚   β”œβ”€β”€ pt-BR/showcases/       # Showcase pages (Portuguese)
β”‚   └── es-ES/showcases/       # Showcase pages (Spanish)
└── scripts/                    # Build and publish scripts

πŸ”§ Integration Examples

React Hook Form

import { FormFactory } from '@schepta/factory-react';
import { useForm } from 'react-hook-form';

function RHFForm() {
  const methods = useForm();
  
  return (
    <FormFactory
      schema={schema}
      renderers={{
        field: createRHFFieldRenderer(methods)
      }}
      onSubmit={methods.handleSubmit(onSubmit)}
    />
  );
}

Material UI

import { FormFactory } from '@schepta/factory-react';
import { TextField, Select } from '@mui/material';

const muiComponents = {
  InputText: createComponentSpec({
    id: 'InputText',
    type: 'field',
    component: () => ({ label, ...props }) => (
      <TextField label={label} {...props} />
    )
  })
};

<FormFactory
  schema={schema}
  components={muiComponents}
/>

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

πŸ“„ License

Schepta Non-Commercial License (SNCL)

Schepta is free to use for:

  • βœ… Personal projects
  • βœ… Educational purposes
  • βœ… Research and academic projects
  • βœ… Non-profit organizations
  • βœ… Open-source projects

Commercial use requires a separate license.

For commercial licensing inquiries, please contact us at: https://github.com/guynikan/schepta

See LICENSE for full terms.


Built with ❀️ using TypeScript, Turbo, and PNPM

About

Framework-agnostic rendering engine for server-driven UI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors