# adobe-rnd/aem-boilerplate-forms architecture

> Architecture diagram of the GitHub repository adobe-rnd/aem-boilerplate-forms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adobe-rnd/aem-boilerplate-forms
- Repository: https://github.com/adobe-rnd/aem-boilerplate-forms

## Overview

##### Main System Components

a) Client-Side Layer:
- Forms Runtime Engine (blocks/form/*)
- UI Components (blocks/* - cards, columns, footer, header, hero)
- Form Components (models/form-components/*)
- Client-side Scripts (scripts/*)

b) Rules Engine Layer:
- Rule Compiler (blocks/form/rules-doc/RuleCompiler.js)
- Rule Engine (blocks/form/rules-doc/RuleEngine.js)
- Formula Parser (blocks/form/rules-doc/parser/*)

c) Integration Layer:
- ReCAPTCHA Integration (blocks/form/integrations/recaptcha.js)
- AEM Backend Integration (scripts/aem.js)

##### Component Relationships

**[Client Browser] → [Forms Runtime Engine]**
- ↓
**[UI Components] ← [Rules Engine] → [Formula Parser]**
- ↓
**[Form Components] → [Integration Layer] → [External Services]**

##### Specific Implementation Details

Architectural patterns:
- Component-based architecture (shown by blocks/ structure)
- Event-driven form processing (blocks/form/rules/model/afb-events.js)
- Worker-based rule processing (blocks/form/rules/RuleEngineWorker.js)

##### Key Architectural Elements

Highlight:
- Form Component Registry (component-definition.json)
- Model Definitions (models/*)
- Integration Points (blocks/form/integrations/*)
- Test Infrastructure (test/*)

##### Development Infrastructure

Include:
- CI/CD Pipeline (.circleci/*)
- Testing Framework (test/*)
- Build System (rollup/*)

- The modular nature of the form components
- The separation between the rules engine and UI components
- The integration points with AEM and external services
- The build and deployment pipeline

Keep the abstraction level focused on the architectural components while showing the relationships between the form runtime, rules engine, and integration layers. This will help developers understand both the high-level structure and the detailed interactions between components.

This architecture represents a modern, component-based forms solution with a strong emphasis on client-side processing and rule evaluation, integrated with AEM's edge delivery services.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Client Browser"]
    end

    subgraph FormRuntime["Forms Runtime Layer"]
        FRE["Forms Runtime Engine"]:::runtime
        click FRE "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/blocks/form/form.js"
        
        subgraph UIComponents["UI Components"]
            Cards["Cards"]:::ui
            Columns["Columns"]:::ui
            Footer["Footer"]:::ui
            Header["Header"]:::ui
            Hero["Hero"]:::ui
            click Cards "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/blocks/cards/"
            click Columns "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/blocks/columns/"
            click Footer "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/blocks/footer/"
            click Header "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/blocks/header/"
            click Hero "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/blocks/hero/"
        end

        subgraph FormComponents["Form Components"]
            CompModels["Component Models"]:::component
            CompImpl["Component Implementations"]:::component
            click CompModels "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/models/form-components/"
            click CompImpl "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/blocks/form/components/"
        end
    end

    subgraph RulesLayer["Rules Engine Layer"]
        RuleCompiler["Rule Compiler"]:::rules
        RuleEngine["Rule Engine"]:::rules
        FormulaParser["Formula Parser"]:::rules
        RuleWorker["Rule Engine Worker"]:::rules
        click RuleCompiler "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/blocks/form/rules-doc/RuleCompiler.js"
        click RuleEngine "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/blocks/form/rules-doc/RuleEngine.js"
        click FormulaParser "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/blocks/form/rules-doc/parser/"
        click RuleWorker "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/blocks/form/rules/RuleEngineWorker.js"
    end

    subgraph EventSystem["Event System"]
        EventHandler["Event Handler"]:::events
        click EventHandler "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/blocks/form/rules/model/afb-events.js"
    end

    subgraph Integration["Integration Layer"]
        ReCaptcha["ReCAPTCHA Integration"]:::integration
        AEMBackend["AEM Backend Integration"]:::integration
        click ReCaptcha "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/blocks/form/integrations/recaptcha.js"
        click AEMBackend "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/scripts/aem.js"
    end

    subgraph Models["Form Models"]
        CompDefs["Component Definitions"]:::model
        FormCommon["Form Common Models"]:::model
        FormCompModels["Form Component Models"]:::model
        click CompDefs "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/component-definition.json"
        click FormCommon "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/models/form-common/"
        click FormCompModels "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/models/form-components/"
    end

    subgraph Infrastructure["Development Infrastructure"]
        Testing["Testing Infrastructure"]:::infra
        BuildSystem["Build System"]:::infra
        CICD["CI/CD Pipeline"]:::infra
        click Testing "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/test/"
        click BuildSystem "https://github.com/adobe-rnd/aem-boilerplate-forms/tree/main/rollup/"
        click CICD "https://github.com/adobe-rnd/aem-boilerplate-forms/blob/main/.circleci/config.yml"
    end

    %% Relationships
    Browser --> FRE
    FRE --> UIComponents
    FRE --> FormComponents
    FormComponents --> RulesLayer
    RulesLayer --> EventSystem
    EventSystem --> UIComponents
    FormComponents --> Integration
    Integration --> External["External Services"]:::external
    Models --> FormComponents
    RulesLayer --> FormulaParser

    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef runtime fill:#1976D2,stroke:#0D47A1,color:white
    classDef component fill:#42A5F5,stroke:#1565C0,color:white
    classDef rules fill:#4CAF50,stroke:#2E7D32,color:white
    classDef events fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef integration fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9E9E9E,stroke:#424242,color:white
    classDef model fill:#673AB7,stroke:#4527A0,color:white
    classDef infra fill:#795548,stroke:#3E2723,color:white
```
