# ayon-biswas/contact-form-plugin architecture

> Architecture diagram of the GitHub repository ayon-biswas/contact-form-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayon-biswas/contact-form-plugin
- Repository: https://github.com/ayon-biswas/contact-form-plugin

## Overview

1. **Project type and boundary**
   - This is a **WordPress plugin** named `contact-form-pro`.
   - Its architecture sits inside the WordPress runtime and depends on WordPress hooks, shortcodes, admin pages, and the built-in content model rather than a separate app server or database layer.

2. **Bootstrap entry point**
   - `contact-form-pro.php` is the plugin root and likely the main loader.
   - It is the top-level integration point that wires together the includes under `includes/`, loads CSS assets, and registers the plugin’s hooks with WordPress.

3. **Frontend form rendering**
   - `includes/class-cfp-shortcode.php` provides the shortcode-based frontend entry point.
   - The `[cfp_form]` shortcode renders the contact form on a page or post, making the form presentation part of WordPress content rather than a separate route or template system.

4. **Submission processing pipeline**
   - `includes/class-submission-handler.php` is the main request-processing boundary for form POSTs.
   - It handles nonce/security checks, validation, and submission acceptance before data is persisted.
   - This is the key flow from browser form submit → WordPress request handling → storage.

5. **Persistence model**
   - `includes/class-cpt.php` registers the custom post type `cfp_submission`.
   - Form submissions are stored as WordPress content objects, not in a custom standalone table.
   - This means the plugin uses WordPress’s native storage and querying mechanisms as its persistence layer.

6. **Submission data object**
   - `includes/class-cfp-submission.php` likely represents a submission entity or helper around submission records.
   - It probably encapsulates the fields, storage mapping, and retrieval of submission data associated with the CPT.

7. **Admin dashboard subsystem**
   - `includes/class-cfp-admin.php` provides the WordPress admin-side experience.
   - This is the boundary for managing submissions in the dashboard, likely including listing, viewing, and any future export/filter/search features mentioned in the README.

8. **Assets and presentation**
   - `assets/frontend.css` styles the public-facing contact form.
   - `assets/admin.css` styles the admin UI.
   - The plugin keeps frontend and backend presentation separate, which is useful for diagramming the UI surfaces independently.

9. **End-to-end data flow**
   - A visitor loads a page with `[cfp_form]` → the shortcode renders the form → the user submits it → the submission handler validates and checks nonce → the submission is saved as `cfp_submission` → the admin subsystem exposes that record inside WordPress.
   - The primary data path is therefore **frontend form → handler → CPT storage → admin review**.

10. **Architectural characteristics**
   - The plugin is organized in a simple layered way: **bootstrap**, **frontend render**, **submission processing**, **persistence**, and **admin management**.
   - There are no external APIs or services in the current repository; the only major dependency is WordPress itself.
   - The README’s mention of upcoming CSV export/search/filter suggests future admin-side enhancements, but those are not yet part of the implemented architecture.

Main entry points: [`contact-form-pro.php`](https://github.com/ayon-biswas/contact-form-plugin/blob/main/contact-form-pro.php) (Plugin loader), [`includes/class-cfp-admin.php`](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-admin.php) (Admin dashboard), [`includes/class-submission-handler.php`](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-submission-handler.php) (Submit handler), [`includes/class-cfp-submission.php`](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-submission.php) (Submission object)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core plugin"]
  node_bootstrap["Plugin loader<br/>bootstrap"]
  node_shortcode["Form shortcode<br/>frontend entry"]
  node_handler["Submit handler<br/>request pipeline"]
  node_cpt[("Submission CPT<br/>storage model<br/>[class-cpt.php]")]
  node_submission["Submission object<br/>entity helper"]
  node_admin["Admin dashboard<br/>admin UI"]
end

subgraph group_ui["Presentation"]
  node_frontend_css["Frontend CSS<br/>style asset<br/>[frontend.css]"]
  node_admin_css["Admin CSS<br/>style asset<br/>[admin.css]"]
end

node_wordpress{{"WordPress<br/>runtime"}}

node_bootstrap -->|"hooks into"| node_wordpress
node_bootstrap -->|"loads"| node_shortcode
node_bootstrap -->|"loads"| node_handler
node_bootstrap -->|"loads"| node_cpt
node_bootstrap -->|"loads"| node_submission
node_bootstrap -->|"loads"| node_admin
node_bootstrap -->|"enqueues"| node_frontend_css
node_bootstrap -->|"enqueues"| node_admin_css
node_shortcode -->|"styles"| node_frontend_css
node_shortcode -->|"submits to"| node_handler
node_handler -->|"uses hooks"| node_wordpress
node_handler -->|"creates"| node_submission
node_submission -->|"persists as"| node_cpt
node_admin -->|"queries"| node_cpt
node_admin -->|"displays"| node_submission
node_admin -->|"styles"| node_admin_css

click node_bootstrap "https://github.com/ayon-biswas/contact-form-plugin/blob/main/contact-form-pro.php"
click node_shortcode "https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-shortcode.php"
click node_handler "https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-submission-handler.php"
click node_cpt "https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cpt.php"
click node_submission "https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-submission.php"
click node_admin "https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-admin.php"
click node_frontend_css "https://github.com/ayon-biswas/contact-form-plugin/blob/main/assets/frontend.css"
click node_admin_css "https://github.com/ayon-biswas/contact-form-plugin/blob/main/assets/admin.css"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bootstrap,node_shortcode,node_handler,node_cpt,node_submission,node_admin toneBlue
class node_frontend_css,node_admin_css toneAmber
class node_wordpress toneNeutral
```

## Components

### Core plugin

WordPress plugin bootstrap, frontend entry point, submission pipeline, storage, and admin integration.

- [Plugin loader](https://github.com/ayon-biswas/contact-form-plugin/blob/main/contact-form-pro.php): bootstrap · Main plugin entry point that wires the plugin into WordPress. · `contact-form-pro.php`
- [Form shortcode](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-shortcode.php): frontend entry · Shortcode handler that renders the public contact form inside post or page content. · `includes/class-cfp-shortcode.php`
- [Submit handler](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-submission-handler.php): request pipeline · Processes form POSTs, checks security, validates input, and accepts submissions. · `includes/class-submission-handler.php`
- [Submission CPT](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cpt.php): storage model · Registers the cfp_submission custom post type used to persist submissions in WordPress. · `includes/class-cpt.php`
- [Submission object](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-submission.php): entity helper · Represents or wraps a single submission record and its mapped fields. · `includes/class-cfp-submission.php`
- [Admin dashboard](https://github.com/ayon-biswas/contact-form-plugin/blob/main/includes/class-cfp-admin.php): admin UI · WordPress admin-side management surface for reviewing stored submissions. · `includes/class-cfp-admin.php`

### Presentation

Public and admin styling for the plugin UI surfaces.

- [Frontend CSS](https://github.com/ayon-biswas/contact-form-plugin/blob/main/assets/frontend.css): style asset · Styles the public contact form presentation. · `assets/frontend.css`
- [Admin CSS](https://github.com/ayon-biswas/contact-form-plugin/blob/main/assets/admin.css): style asset · Styles the admin submission management screens. · `assets/admin.css`

### Other components

- **WordPress**: runtime · Host runtime providing hooks, shortcodes, admin pages, and custom post types.

## Connections

- Plugin loader → WordPress: hooks into · Registers the plugin with WordPress and its runtime APIs.
- Plugin loader → Form shortcode: loads · Initializes the shortcode-based frontend entry point.
- Plugin loader → Submit handler: loads · Registers the submission processing boundary.
- Plugin loader → Submission CPT: loads · Registers the submission storage model.
- Plugin loader → Submission object: loads · Makes the submission helper available to the plugin runtime.
- Plugin loader → Admin dashboard: loads · Registers the admin management surface.
- Plugin loader → Frontend CSS: enqueues · Attaches public-facing styles for the form UI.
- Plugin loader → Admin CSS: enqueues · Attaches admin-side styles for dashboard screens.
- Form shortcode → Frontend CSS: styles · Uses the frontend stylesheet for form presentation.
- Form shortcode → Submit handler: submits to · Form submissions are sent into the request-processing pipeline.
- Submit handler → WordPress: uses hooks · Relies on WordPress request handling, nonce checks, and validation APIs.
- Submit handler → Submission object: creates · Builds or populates a submission record after validation.
- Submission object → Submission CPT: persists as · Maps submission data onto the custom post type storage layer.
- Admin dashboard → Submission CPT: queries · Reads stored submissions from WordPress content objects.
- Admin dashboard → Submission object: displays · Formats individual submission records for review in the dashboard.
- Admin dashboard → Admin CSS: styles · Uses the admin stylesheet for dashboard presentation.
