How pkorchak/form-builder-ui works
Project Type and Purpose
• Type: Single‐Page Application (SPA) built with Angular.
• Purpose: JSON‐based dynamic form builder UI allowing users to create, edit, and render forms; communicates with a backend REST API via HTTP services.
File Structure
• Top‐Level Files:
– angular.json, tsconfig*.json, package.json – Angular build and configuration.
– proxy.config.json – dev‐time proxy to backend API.
• src/app:
– app.module.ts & app-routing.module.ts – root module & router.
– model/ – DTOs and form‐structure definitions.
– services/api/ – HTTP services (forms-http.service.ts, users-http.service.ts) for REST calls.
– services/ – factories and mappers for form elements.
– pages/ – feature modules (create-form, pre-built-forms) each with routing, components, and JSON templates.
– widgets/ – reusable component modules:
· auth – authentication UI
· form-container – top‐level wrapper
· form-editor – builder UI (drag & drop, settings panel)
· form-viewer – runtime form rendering
• src/assets & src/styles – static assets and global or component‐level styles.
• Testing: karma.conf.js (unit), cypress.config.ts (e2e).
Key Architectural Insights from README
• Uses ng-zorro-antd component library for UI.
• Provides dev server (localhost:4200) with live reload.
• Build produces a dist/ folder for deployment.
• E2E tests via Cypress, unit tests via Karma + Jasmine.
Main Components & Their Relationships
a. Browser / Client (Angular SPA)
– Core Modules: AppModule, Feature Modules (CreateFormModule, PreBuiltFormsModule)
– Shared Modules: Widget Modules (FormEditorModule, FormViewerModule, AuthModule)
– Model Layer: DTOs and FormStructure definitions
– Service Layer:
• HttpService – low‐level wrapper around HttpClient
• FormsHttpService – CRUD operations for forms
• UsersHttpService – registration/auth endpoints
• FormElementsFactory & FormStructureMapper – convert JSON ↔ component tree
b. External UI Library
– ng‐zorro‐antd components used within widgets for consistent look & feel
c. Backend REST API (external microservice)
– Endpoints: /forms, /users (proxied via proxy.config.json in dev)
d. Development Tooling
– Angular CLI (build, serve)
– Cypress & Karma for tests
– ESLint for linting
Architectural Patterns & Principles
• Component‐Based Architecture: UI broken into reusable, testable components bundled in feature & shared modules.
• Dependency Injection: Angular’s DI for services & factories.
• Separation of Concerns:
– Pages (routes) compose Widgets; Widgets encapsulate UI logic.
– Services handle data & HTTP.
– Model (DTOs) strictly typed contracts.
• Modularization: Lazy‐loaded feature modules for pages (via Angular Router).