# brainstormforce/sureforms-public architecture

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

- Interactive diagram: https://gitdiagram.com/brainstormforce/sureforms-public
- Repository: https://github.com/brainstormforce/sureforms-public

## Overview

##### Project’s Purpose and Type
- This is a WordPress plugin that offers a no-code, drag-and-drop form building experience.
- Its core purpose is to allow website owners, designers, and developers to create responsive and visually appealing forms seamlessly within the WordPress ecosystem.
- The README emphasizes AI-powered form creation, integration with the native WordPress block editor (Gutenberg), and compatibility with external third-party services (e.g., reCAPTCHA, ipapi).

##### File Structure for Key Architectural Components
- Administrative and Core PHP Code:
– Look at top-level directories like “admin”, “inc”, “templates”, and “languages”. These house the backend logic, plugin initialization, AJAX endpoints, REST API handlers, and WordPress hooks.
– The “inc” folder contains core functionalities, database interactions, email notifications, and integration libraries such as action scheduler and analytics.
- Gutenberg and Block Modules:
– “modules/gutenberg” and “src/blocks” contain block definitions (PHP for block rendering, JSON configurations, and JavaScript/SCSS components) that integrate with WordPress’s native block editor.
- Frontend and Assets:
– Directories such as “assets”, “sass”, and “src” contain JavaScript assets, CSS/sass files, and components for both the frontend rendering of forms and admin UI elements.
- External Interfaces & Integrations:
– The “api” folder and various integration files show that the plugin interacts with external systems (e.g., IP detection, captcha) and supports AI features.
- Build and Testing Tools:
– Build scripts (Gruntfile.js, webpack.config.js, scripts, bin) indicate the presence of an automated build process, asset minification, and generation steps.
- Modular, Extensible Organization:
– The library components in “inc/lib” and separate module folders indicate a separation of concerns that allows for easier future extensions and maintenance.

##### Key Components
A. Admin/Backend Core:
– Core Plugin Loader (plugin-loader.php, inc/activator.php)
– Database & Entry Management (inc/database, inc/export.php, inc/forms-data.php)
– REST API / AJAX Endpoints (inc/admin-ajax.php, inc/rest-api.php)
– Global Helpers and Library Modules (inc/helper.php, inc/lib/ directories)
– Integration and scheduler libraries (action scheduler modules)
B. Gutenberg Blocks & Frontend Components:
– Gutenberg Block Definitions (modules/gutenberg and src/blocks)
– Block Attributes and Rendering (PHP and JavaScript based blocks)
– Frontend Asset Management (assets/js, assets/css, sass folders) used for styling and inline field validations.
C. Admin User Interface:
– Admin Dashboard and Settings (admin folder, src/admin components, templates for forms)
– Specialized modules for form editing, template selection, and single form settings (src/admin/single-form-settings)
D. External Services & Integrations:
– AI integration for form building (inc/ai-form-builder)
– External APIs: ipinfo, Google Fonts, ipapi, and reCAPTCHA.
E. Build and Testing Infrastructure:
– Automated build processes using Grunt/Webpack (Gruntfile.js, webpack.config.js)
– Testing layers including Playwright and PHP unit tests (tests folder)

##### Relationships and Flows
– From Admin UI to Core Plugin Loader, which in turn interacts with the database and external API modules.
– From Gutenberg block editor integrations (modules/gutenberg) to frontend rendering components under “assets” and “src/blocks.”
– Build tools feeding into asset creation for both frontend and admin interfaces.
- How the plugin separates concerns: UI logic (in JS/React components) is decoupled from backend processing (PHP and WordPress hooks).

##### Architectural Patterns or Design Principles
- Modular Architecture: Separation by directories (admin, inc, modules, src) to enable maintainability and future extension.
- Separation of Concerns: Clear boundaries between backend logic (PHP), frontend UI (JavaScript, SCSS), and Gutenberg block management.
- Integration-Friendly Design: Use of clean APIs, hooks, and external service integration with minimal coupling.
- Use of Automated Build & Testing Processes: Ensures consistency and performance in asset management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend Core Subgraph
    subgraph "Backend Core"
        CP["Core Plugin Loader"]:::backend
        DB["Database & Entry Management"]:::backend
        API["REST API / AJAX Endpoints"]:::backend
        GH["Global Helpers & Lib Modules"]:::backend
        SCH["Scheduler Libraries"]:::backend
    end

    %% Gutenberg & Frontend Assets Subgraph
    subgraph "Gutenberg & Frontend Assets"
        BD["Gutenberg Block Definitions"]:::frontend
        BA["Block Attributes & Rendering"]:::frontend
        FA["Frontend Asset Management"]:::frontend
    end

    %% Admin UI Subgraph
    subgraph "Admin UI"
        AD["Admin Dashboard & Settings"]:::ui
        FE["Form Editing & Template Selection"]:::ui
    end

    %% External Integrations Subgraph
    subgraph "External Integrations"
        AI["AI Form Builder"]:::external
    end

    %% Build & Testing Infrastructure Subgraph
    subgraph "Build & Testing"
        BP["Build Processes"]:::build
        TT["Testing Layers"]:::build
    end

    %% Relationships and Flows
    AD -->|"calls"| CP
    FE -->|"enhances"| AD
    BD -->|"sends_data"| CP
    FA -->|"supplies"| BD
    CP -->|"updates_DB"| DB
    CP -->|"calls_API"| API
    CP -->|"uses_helpers"| GH
    CP -->|"triggers_scheduler"| SCH
    AI -->|"integrates"| CP
    BP -->|"builds_assets"| FA
    BP -->|"builds_UI"| AD
    TT -->|"tests_backend"| CP
    TT -->|"tests_blocks"| BD
    TT -->|"tests_UI"| AD

    %% Styles
    classDef backend fill:#f4cccc,stroke:#cc0000,stroke-width:2px;
    classDef frontend fill:#c9daf8,stroke:#1155cc,stroke-width:2px;
    classDef ui fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef external fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef build fill:#ead1dc,stroke:#b85450,stroke-width:2px;

    %% Click Events
    click CP "https://github.com/brainstormforce/sureforms-public/blob/master/plugin-loader.php"
    click DB "https://github.com/brainstormforce/sureforms-public/tree/master/inc/database"
    click API "https://github.com/brainstormforce/sureforms-public/blob/master/inc/admin-ajax.php"
    click GH "https://github.com/brainstormforce/sureforms-public/blob/master/inc/helper.php"
    click SCH "https://github.com/brainstormforce/sureforms-public/tree/master/inc/lib/action-scheduler/"
    click BD "https://github.com/brainstormforce/sureforms-public/tree/master/modules/gutenberg"
    click BA "https://github.com/brainstormforce/sureforms-public/tree/master/inc/blocks"
    click FA "https://github.com/brainstormforce/sureforms-public/tree/master/assets/"
    click AD "https://github.com/brainstormforce/sureforms-public/tree/master/admin/"
    click FE "https://github.com/brainstormforce/sureforms-public/tree/master/src/admin/single-form-settings"
    click AI "https://github.com/brainstormforce/sureforms-public/tree/master/inc/ai-form-builder"
    click BP "https://github.com/brainstormforce/sureforms-public/blob/master/Gruntfile.js"
    click TT "https://github.com/brainstormforce/sureforms-public/tree/master/tests/"
```
