How bpmn-io/form-js works
Based on our review of the complete file tree and the README, this project is a modular form library that provides three main packages—a form viewer for displaying forms, an editor for creating and editing forms, and a playground for simulating forms with actual data. In addition, several supporting packages (such as the core library itself, JSON schema definitions, integration utilities, and styling modules) complement the three main components. The project is organized as a monorepo (using Lerna) and follows a modular architecture that emphasizes clear separation of responsibilities.
Main Components
• Form Viewer: (Found in packages/form-js-viewer) Responsible for rendering forms based on a provided JSON schema and data.
• Form Editor: (Found in packages/form-js-editor) Provides a visually interactive interface to build and modify form schemas.
• Form Playground: (Found in packages/form-js-playground) Simulates form behavior by allowing both input and output of data and uses the viewer/editor functionalities.
• Core Library & Utilities: (Found in packages/form-js) Contains shared functionalities, including the getSchemaVariables utility and common logic.
• JSON Schema Definitions: (Found in packages/form-json-schema) Offers standardized definitions, rules, and validation for form schemas.
• Additional Modules: Modules like form-js-integrations and form-js-carbon-styles handle integrations and theming respectively.
Relationships and Interactions
• Displaying a Form: The Form Viewer imports schemas and data to render forms.
• Building/Editing a Form: The Form Editor leverages core functionalities (e.g., event bus, field registry) along with JSON schema definitions to allow manipulation of form elements.
• Simulating Forms: The Form Playground acts as a thin layer that combines aspects of both viewer and editor, basically letting you test user input and see outputs.
• Shared Logic: The core library (packages/form-js) functions as a backbone used by all the above packages; utilities like getSchemaVariables represent functional connectors that extract schema details.
• Integration with CI/CD & Build Tools: Outline that the project utilizes GitHub Workflows (CI/CD automation) and build configurations (Rollup, Vite) that influence how components are bundled and deployed.
Important Architectural Patterns and Design Principles
• Monorepo Structure: Emphasize that the project is managed as a single repository with multiple packages. Show each package as an autonomous module, yet interconnected via dependency relationships.
• Separation of Concerns: Distinguish between core functionality (form schema management and utility functions) and component-specific implementations (viewer, editor, playground).
• Modular and Extensible Design: Note that additional packages (like integrations, styling, or even testing frameworks) can be added as extensions.
• Test and Build Infrastructure: Include the automated testing (e2e, unit tests) and CI/CD pipelines (under .github/workflows) as supportive components around the main modules.
Relevant Technologies, Frameworks, and Libraries
• Node.js (version 16 as noted), npm, and likely a bundler (Rollup and Vite) for building libraries.
• Testing frameworks like Karma and Playwright are signaled by configuration files and test directories.
• Styling frameworks (SCSS for Carbon styles) and the integration of prettierrc and ESLint for code quality.
Instructing the Principal Software Engineer
– Label them clearly (e.g., “Form Viewer (UI Rendering)”, “Form Editor (Schema Builder)”, “Form Playground (Simulation)”, “Form JS Core (Shared Logic)”, “Form JSON Schema (Schema Definitions)”).
– Illustrate how “Form Playground” uses both “Form Editor” and “Form Viewer”.
– Core libraries and schema definitions can use another.
• Importance of detailing internal modules where necessary—for example, the editor has features for modeling, palette, and properties panel which can be grouped as sub-components if additional depth is needed.