How optimajet/formengine works
1. This repository is a monorepo for FormEngine, split into a free/community codebase and a premium/examples codebase. The architectural center is a JSON-driven form runtime: form structure is described in JSON or generated from code, then rendered through a viewer/runtime plus a UI theme package.
2. The community/src/packages/core package is the main engine. It contains the form viewer runtime, form JSON builder, validation, localization, event handling, modal/repeater/template support, and the internal state/store layer. If you are diagramming the system, this is the hub that coordinates data, UI metadata, validation rules, and emitted actions.
3. The core runtime is intentionally UI-agnostic. It exposes abstract component definitions and a viewer API, but delegates actual controls to theme/view packages. The main data flow is: form definition in JSON or builder output -> core store/model -> viewer render tree -> component-specific props/events/validation -> user interaction back into store/actions.
4. The community/src/packages/views/* packages are the concrete UI adapters. There are separate packages for Mantine, Material UI, RSuite, and Uploader, each implementing component definitions, wrappers, localized descriptions, and theme-specific behaviors. These packages map core abstractions like buttons, inputs, dialogs, and containers onto each design system.
5. The view packages also define the “catalog” of supported components for each theme. That means the architecture has a clear boundary between engine and presentation: core owns semantics and runtime behavior, while views own component bindings, styling, and theme-specific props.
6. JSON schema generation is a separate subsystem. Packages like json-schema-generator and the per-theme public/schemas/*.json assets produce schema files for forms and component definitions. These are used by tooling, validation, and example apps to load or author forms consistently without coupling to runtime internals.
7. Localization is built into both core and view packages. Core ships language resources and a Fluent-based localization engine, while each theme package supplies its own UI text and component descriptions. In the runtime, localization is part of the rendering layer rather than an external concern.
8. Validation is another first-class pipeline. The core validation subsystem supports schema-driven validation rules, Zod integration, custom rules, and error rendering. Validation results flow back into the viewer/store so components can display field-level errors and control submission or custom actions.
9. The repository also contains example applications that demonstrate end-to-end consumption paths. Community examples include example-viewer, formdata, bundle-size, and a small file-upload server; these show how the core/view packages are embedded in real apps, how form JSON is loaded, and how file upload or bundle analysis is handled around the engine.
10. The community/examples/bundle-size area is a benchmarking harness, not a product feature. It compares different stacks and themes through separate mini-apps, plus build/report scripts that measure JS/CSS output and generate console/CSV/HTML/MDX/JSON reports. This subsystem is useful for architecture because it shows the library’s modular packaging and build boundaries.
11. The premium/examples tree demonstrates the commercial designer workflow and framework integrations. It includes separate example apps for React/Formik, Angular forms, Next.js, and Remix, all reusing shared JSON form definitions and validators. This shows the same core form model being adapted into different host frameworks and rendering environments.
12. Build and packaging are organized per package with Vite/TypeScript configs and package-local publish settings. The repo is structured as independently buildable packages rather than one monolith, which matters for architecture diagrams: each package has its own entrypoints, public assets, and schema artifacts, while the shared runtime contracts come from core.
Main entry points: core Core · form-viewer Viewer · common Common app · mantine Mantine
Components 23
Premium
Commercial examples and framework integrations.
- Premium demo · Premium React example showing form builder and viewer consumption paths.
premium/examples/formengine - Angular forms · Stepwise Angular examples that move from native forms to FormEngine and designer integration.
premium/examples/with-angular-forms - Formik · React/Formik example embedding shared JSON form definitions and validators.
premium/examples/with-formik - Next.js · Next.js example with shared form model, builder, viewer, and actions.
premium/examples/with-nextjs - Remix · Remix example with client/server viewer and builder entrypoints around shared form JSON.
premium/examples/with-remix
Examples
Standalone demo and benchmarking applications.
- Common app · Shared example-app shell for theme picking, persistent state, and loading forms from JSON.
community/src/packages/apps/common - Example viewer · End-to-end viewer app that switches between themes and renders sample forms.
community/src/packages/apps/example-viewer - Formdata · Vite example that loads sample form JSON and embeds the viewer runtime.
community/examples/formdata - Bundle size · Multi-stack performance and bundle-size comparison suite with reporting scripts.
community/examples/bundle-size - Upload server · Small file-upload server used by uploader-oriented examples.
community/examples/file-upload-server
Runtime
Core form engine and its main supporting subsystems.
- Core · JSON-driven form engine with viewer, builder, validation, localization, events, modal/repeater/template support, and store/state management.
community/src/packages/core - Store · Central form state, component state, persisted form, and localization stores.
community/src/packages/core/src/stores - Viewer · FormViewer, viewer wrapper, component tree rendering, and viewer store/provider plumbing.
community/src/packages/core/src/features/form-viewer - Validation · Schema-driven validation, Zod rules, custom rules, and error rendering.
community/src/packages/core/src/features/validation - Localization · Fluent-based localization engine, language resources, and viewer localization provider.
community/src/packages/core/src/features/localization - Events · Action definitions, event handlers, and event-to-store coordination for user interactions.
community/src/packages/core/src/features/event - Form builder · Builder for generating form JSON and metadata from code.
community/src/packages/core/src/features/form-json-builder
Views
Theme-specific UI adapters and component catalogs.
- Mantine · Mantine component bindings, viewer wrappers, localized descriptions, and theme-specific behaviors.
community/src/packages/views/mantine - Material UI · Material UI component bindings, wrappers, and catalog definitions for the form runtime.
community/src/packages/views/material-ui - RSuite · RSuite component bindings, wrappers, localization, and CSS assets for the runtime.
community/src/packages/views/rsuite - Uploader · Uploader-focused component package and schema catalog.
community/src/packages/views/uploader
Tools
Schema generation and packaging utilities.
- Schema gen · Generates JSON schemas from core types and form metadata.
community/src/packages/json-schema-generator - Viewer bundle · Package entry for bundling the viewer runtime for consumers.
community/src/packages/viewer-bundle
Connections 33
- Form builder → Core: builds form JSON · Produces runtime form definitions consumed by the core viewer and store.
- Core → Store: owns state · Core coordinates store/state, persisted form data, and component model updates.
- Core → Viewer: drives render · Core exposes the viewer API and render tree used by apps and theme packages.
- Core → Validation: validates · Validation results flow back into the viewer/store for field errors and submission control.
- Core → Localization: localizes · Localization is part of the rendering/runtime layer.
- Core → Events: emits actions · User interaction is converted into named actions and event handlers.
- Viewer → Mantine: adapts to theme · Viewer uses theme-specific component bindings and wrappers.
- Viewer → Material UI: adapts to theme · Viewer uses theme-specific component bindings and wrappers.
- Viewer → RSuite: adapts to theme · Viewer uses theme-specific component bindings and wrappers.
- Viewer → Uploader: adapts to theme · Viewer uses uploader-specific component bindings and wrappers.
- Mantine → Localization: supplies text · Theme package contributes localized descriptions and UI strings.
- Material UI → Localization: supplies text · Theme package contributes localized descriptions and UI strings.
- RSuite → Localization: supplies text · Theme package contributes localized descriptions and UI strings.
- Uploader → Localization: supplies text · Theme package contributes localized descriptions and UI strings.
- Schema gen → Material UI: generates schema · Produces theme component schema assets for tooling and authoring.
- Schema gen → RSuite: generates schema · Produces theme component schema assets for tooling and authoring.
- Schema gen → Uploader: generates schema · Produces theme component schema assets for tooling and authoring.
- Common app → Core: uses core · Shared app shell loads forms and renders via the runtime.
- Common app → Mantine: uses theme · Theme picker and form rendering use Mantine bindings.
- Common app → Material UI: uses theme · Theme picker and form rendering use Material UI bindings.
- Common app → RSuite: uses theme · Theme picker and form rendering use RSuite bindings.
- Example viewer → Common app: reuses shell · Example viewer is built on shared app utilities and form loading helpers.
- Formdata → Core: embeds viewer · Loads sample JSON and renders through the core form viewer.
- Bundle size → Core: benchmarks · Compares stack and theme packaging costs against the core runtime.
- Bundle size → Mantine: benchmarks · Measures bundle size impact for theme bindings.
- Bundle size → Material UI: benchmarks · Measures bundle size impact for theme bindings.
- Upload server → Uploader: supports uploads · Provides backend counterpart for uploader-themed flows.
- Premium demo → Core: uses core · Premium demo consumes the shared runtime and JSON model.
- Premium demo → Mantine: uses theme · Premium demo renders through a concrete UI adapter.
- Angular forms → Core: integrates runtime · Angular steps reuse the shared form model and validation layer.
- Formik → Core: integrates runtime · Formik example binds the shared form JSON and validation into React forms.
- Next.js → Core: integrates runtime · Next.js example wires shared JSON definitions into app routes and actions.
- Remix → Core: integrates runtime · Remix example wires shared JSON definitions into client/server routes.