# agenciaego/egodesign-form architecture

> Architecture diagram of the GitHub repository agenciaego/egodesign-form, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agenciaego/egodesign-form
- Repository: https://github.com/agenciaego/egodesign-form

## Overview

##### Main Components
- Core Library (EgoForm Class): This is the primary export (src/egodesign.form.ts) that initializes the form and ties together all functionality.
- Validation Modules: Under src/modules you have components like ValidationClass.ts, tools.ts, and validationMessages.ts. These handle the validation logic, utility functions, and error messaging.
- Types and Interfaces: The src/types.d.ts file defines TypeScript types used throughout the library.
- Testing Suite: The tests directory (with files like egoform.test.ts, filters.test.ts, multisteps.test.ts) validates the library’s behaviors.
- Build and Configuration: The Rollup config (rollup.config.mjs), Vite config (vite.config.ts), tsconfig.json, and package.json indicate that the project uses a modern build system to transpile and bundle the library for distribution (dist folder).

##### Component Relationships and Data Flow
- At the entry point, the developer includes and instantiates the EgoForm class by passing configuration options and a DOM element representing the form.
- EgoForm then delegates to various modules:
- The Validation Module evaluates fields based on data attributes (e.g., data-type, min/max length) and applies built-in rules (like for text, email, URL, etc.) as well as any custom validations supplied via options.
- The Tools Module supports utility operations (for example, formatting input values).
- The Validation Messages Module supplies and customizes error messages that are shown in the UI.
- Event Handlers (onValidationError, onSubmitStart, onSubmitEnd, onSuccess, onError, etc.) are wired into these processes to notify the consumer about different states during the form submission lifecycle.
- The UI integration layer uses CSS classes (both required hard-coded classes and the customizable ones) to update the form’s visual state (e.g., adding error classes or indicating submission state).

##### Architectural Patterns and Design Principles
- Modular Design: The code is divided into a main core class and separate modules for validations and tools.
- Configuration-Driven Behavior: The library is highly customizable via options (for validations, classes, event callbacks, submission formats, etc.).
- Event-Driven Communication: Several callbacks are provided for hooking into the form’s lifecycle (e.g., step changes and submission events).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Client["Client Application / Developer"]:::client
    DOM["DOM Layer (UI Integration)"]:::ui
    Types["Types & Interfaces"]:::core
    Test["Testing Suite"]:::test

    %% EgoForm Core with sub-components
    subgraph "EgoForm Core"
        Core["EgoForm Core"]:::coreStyle
        VE["Validation Engine"]:::core
        VM["Validation Messages"]:::core
        TU["Tools & Utilities"]:::core
        EM["Event Manager"]:::core
        SH["Submission Handler"]:::core
    end

    %% Build Process Subgraph
    subgraph "Build Process"
        RC["Rollup Configuration"]:::build
        VC["Vite Configuration"]:::build
        TSC["TypeScript Configuration"]:::build
        PC["Package Configuration"]:::build
        BO["Bundled Output"]:::build
    end

    %% Connections
    Client -->|"instantiates"| Core
    Core -->|"delegates to"| VE
    Core -->|"delegates to"| TU
    Core -->|"delegates to"| EM
    Core -->|"handles"| SH
    VE -->|"uses"| VM
    VE -->|"returns validation"| DOM
    EM -->|"triggers events"| DOM
    SH -->|"updates state"| DOM
    Core -->|"references"| Types
    Test -->|"validates"| Core
    Core -->|"bundled via"| RC
    Core -->|"bundled via"| VC
    RC --> BO
    VC --> BO
    TSC --> BO
    PC --> BO

    %% Click Events
    click Core "https://github.com/agenciaego/egodesign-form/blob/master/src/egodesign.form.ts"
    click VE "https://github.com/agenciaego/egodesign-form/blob/master/src/modules/ValidationClass.ts"
    click TU "https://github.com/agenciaego/egodesign-form/blob/master/src/modules/tools.ts"
    click VM "https://github.com/agenciaego/egodesign-form/blob/master/src/modules/validationMessages.ts"
    click Types "https://github.com/agenciaego/egodesign-form/blob/master/src/types.d.ts"
    click Test "https://github.com/agenciaego/egodesign-form/tree/master/tests"
    click RC "https://github.com/agenciaego/egodesign-form/blob/master/rollup.config.mjs"
    click VC "https://github.com/agenciaego/egodesign-form/blob/master/vite.config.ts"
    click TSC "https://github.com/agenciaego/egodesign-form/blob/master/tsconfig.json"
    click PC "https://github.com/agenciaego/egodesign-form/blob/master/package.json"
    click BO "https://github.com/agenciaego/egodesign-form/tree/master/dist/"

    %% Styles
    classDef client fill:#ffdd99,stroke:#b58900,stroke-width:2px;
    classDef core fill:#cce5ff,stroke:#0d6efd,stroke-width:2px;
    classDef coreStyle fill:#99ccff,stroke:#0b5ed7,stroke-width:2px;
    classDef ui fill:#d1e7dd,stroke:#198754,stroke-width:2px;
    classDef build fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
    classDef test fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
