How yaser2us/dynamo works
Project type and purpose
• Type: This is a frontend‐focused UI library/engine for dynamic form/page generation, published as an NPM package (“dynamo”) and demonstrated via two sample clients (a React web app under example/ and a React Native mobile app under exampleRN/).
• Purpose: Provide a low-code, data-driven rendering engine that takes a JSON “items” array plus a components‐dictionary/renderer and produces dynamic, validated UI on web or mobile.
File structure
• Top-level modules:
• src/ – core engine source
– builder/ – FormBuilder versions (V1..V5), entry in index.js
– controller.js – orchestration of form state, refs, callbacks
– logic/ – pure functions: validation, value getters/setters, rendering decisions
– middleware/ – data/schema transformers & proxy setup
– tools/ – hooks (useHistory, transformer), utilities for runtime
– root hooks: useForm, useFormContext, useController, useFieldArray, etc.
– utils/ – generic helpers (deepMerge, debounce, jsonata integration, subjects/observables).
• dist/ – compiled outputs (index.js, index.modern.js + maps + CSS) consumed by clients
• Examples:
• example/ – React web demo (App.js + Components folder)
• exampleRN/ – React Native demo with full Android/iOS configs
• Configs: .gitignore, package.json, README.md, LICENSE.
README for architectural insights
• Data-driven model: JSON array → engine
• Component dictionary → rendering
• Rendering callback → optional container injection
• Managed callbacks → form-level actions (submit, getValues)
• Custom onChange override, runtime prop injection (field, item, error).
Main components & interactions (
a. Clients:
• React Web App (example/)
• React Native App (exampleRN/)
b. Dynamo Engine (npm package):
1. API Layer (DynoBuilder entrypoint)
• Accepts props: items (JSON schema), components (render fn), managedCallback
2. Builder Module (src/builder)
• Transforms JSON schema into form control definitions
3. Controller (src/controller.js)
• Manages form state, refs, effects, exposes getValues(), reset(), etc.
4. Logic Layer (src/logic)
• Validation routines, value extraction, visibility logic, preconditions
5. Middleware (src/middleware)
• Schema/data transformers, proxies for runtime enhancements
6. Render Pipeline
• For each element: apply middleware → builder output → lookup in componentsDictionary → wrap with container (optional) → render React element
7. Hooks & Tools (src/tools, root hooks)
• Provide React hooks (useForm, useWatch, etc.) for fine-grained state access
8. Utilities (src/utils)
• Shared helper functions (e.g., deepMerge, debounce, Subject for event pub/sub)
c. External Dependencies:
• React / React Native
• Third-party UI components (Button, Checkbox, Select, etc.)
• JSONATA (optional custom validation/resolvers)
d. Build & Distribution:
• Rollup/Babel build produces dist/ bundles
• CSS shipped as dist/index.css
Architectural patterns/design principles
• Inversion of Control: client supplies components / render callback
• Data-driven UI: JSON schema dictates structure
• Middleware Pipeline: transformations & proxies before rendering
• Separation of Concerns:
• Builder transforms schema → definitions
• Controller handles state & APIs
• Logic layer pure functions
• Render layer deals only with React elements
• Extensibility: multiple FormBuilder versions, inject custom middleware/hooks
Detailed capture of essential elements
• JSON “items” schema entering the pipeline, and form values exiting via getValues()