# drawleados-dotcom/drawleadweb architecture

> Architecture diagram of the GitHub repository drawleados-dotcom/drawleadweb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/drawleados-dotcom/drawleadweb
- Repository: https://github.com/drawleados-dotcom/drawleadweb

## Overview

#### Purpose and runtime
This is a PHP website/CMS for Drawlead: public marketing, service/industry/platform pages, blogs and case studies, plus interactive booking, WhatsApp, SEO analysis, and popup features. It is designed for an Apache-style PHP deployment, indicated by `.htaccess`, PHP entry files, and deployment workflow. Persistent content and feature state are database-backed through SQL schema/migrations.

Key runtime roots: `index.php`, `includes/bootstrap.php`, `.htaccess`.

#### Public site composition and routing
`index.php` is the public entry point and likely resolves requested pages/content before assembling shared layout and page-specific bodies. Templates separate reusable page chrome from content types, enabling database-managed pages alongside dedicated templates.

Architecture boundary: request/bootstrap → page/content selection → layout partials → rendered HTML.

Key paths: `index.php`, `templates/layout-start.php`, `templates/layout-end.php`.

#### Template and content model
The public presentation layer has explicit templates for homepage variants, blog lists/posts, case studies, booking, service solutions, industries, and platform modules. Shared navigation, footer, sidebar, popup, booking modal, and WhatsApp widget are independently composable partials.

This supports a hybrid content model: fixed template types populated by CMS/database records, rather than a single static-site build.

Key paths: `templates/home-body.php`, `templates/blog-post-body.php`, `templates/partials/nav.php`.

#### Administration CMS
The `/admin` application is the control plane for authentication, users, pages, blogs, case studies, calendar/booking configuration, WhatsApp flows, popups, analytics, and deployments. Edit/delete endpoints imply server-rendered CRUD workflows backed by the shared database and admin-specific assets.

The admin boundary should enforce authentication/session handling before accessing content or operational actions.

Key paths: `admin/index.php`, `admin/login.php`, `admin/page-edit.php`.

#### Interactive lead-capture APIs
Public JavaScript calls PHP API endpoints for booking availability/slots/submission and WhatsApp flow/submission. Browser widgets are decoupled from server endpoints, allowing the public templates to embed lead-capture experiences without exposing administration interfaces.

Primary flow: public widget → `assets/*.js` → `/api` endpoint → database and likely outbound notification/email.

Key paths: `api/booking-submit.php`, `api/whatsapp-flow.php`, `assets/booking.js`.

#### Shared application services
`includes/bootstrap.php` is the likely shared initialization boundary for configuration, database connectivity, sessions, and common helpers. The application also contains a mailer integration and an analysis feature with dedicated templates and admin support, making these cross-cutting services rather than isolated pages.

Key paths: `includes/bootstrap.php`, `includes/mailer.php`, `includes/analyze.php`.

#### Database evolution and operational state
The SQL schema establishes the baseline data model; ordered migrations add booking, WhatsApp bots, case studies/services, SEO fields, popups/triggers, service/platform/industry pages, page status/menu behavior, and analysis features. `admin/run-migrations.php` provides an in-application migration operation, so production migration access is an important operational/security boundary.

Key paths: `sql/schema.sql`, `sql/migrations/003_booking_system.sql`, `admin/run-migrations.php`.

#### Deployment and infrastructure
Deployment is automated through GitHub Actions, with repository deployment instructions available separately. Apache configuration is repository-managed via root and upload-directory `.htaccess` files; uploads are persistent application data and need writable storage plus access-control review.

Key paths: `.github/workflows/deploy.yml`, `DEPLOYMENT.md`, `uploads/.htaccess`.

Main entry points: [`sql/schema.sql`](https://github.com/drawleados-dotcom/drawleadweb/blob/main/sql/schema.sql) (CMS database), [`admin/index.php`](https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/index.php) (Admin control plane), [`index.php`](https://github.com/drawleados-dotcom/drawleadweb/blob/main/index.php) (Public entry), [`templates/layout-start.php`](https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/layout-start.php) (Layout start)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public Website"]
  node_public_entry["Public entry<br/>PHP entry point<br/>[index.php]"]
  node_content_selection["Page &amp; content selection<br/>CMS rendering"]
  node_layout_start["Layout start<br/>layout template<br/>[layout-start.php]"]
  node_page_templates["Content templates<br/>page templates<br/>[home-body.php]"]
  node_layout_end["Layout end<br/>layout template<br/>[layout-end.php]"]
  node_nav_partial["Navigation partial<br/>shared partial<br/>[nav.php]"]
  node_booking_widget["Booking widget<br/>browser JavaScript<br/>[booking.js]"]
  node_booking_api["Booking submission API<br/>PHP API endpoint<br/>[booking-submit.php]"]
  node_whatsapp_api["WhatsApp flow API<br/>PHP API endpoint<br/>[whatsapp-flow.php]"]
end

subgraph group_admin["Admin CMS"]
  node_admin_login["Admin authentication<br/>PHP login<br/>[login.php]"]
  node_admin_app["Admin control plane<br/>PHP admin application<br/>[index.php]"]
  node_page_editor["Page editor<br/>CMS CRUD<br/>[page-edit.php]"]
end

subgraph group_services["Shared Services &amp; Data"]
  node_bootstrap["Application bootstrap<br/>shared initialization<br/>[bootstrap.php]"]
  node_database[("CMS database<br/>persistent data<br/>[schema.sql]")]
  node_mailer["Mailer integration<br/>notification service<br/>[mailer.php]"]
  node_analysis["SEO analysis service<br/>application service<br/>[analyze.php]"]
end

subgraph group_ops["Operations"]
  node_apache{{"Apache routing<br/>web server<br/>[.htaccess]"}}
  node_migration["Migration operation<br/>admin operation<br/>[run-migrations.php]"]
  node_booking_migration["Booking schema migration<br/>SQL migration"]
  node_uploads[("Persistent uploads<br/>writable storage<br/>[.htaccess]")]
  node_deployment{{"Deployment workflow<br/>GitHub Actions<br/>[deploy.yml]"}}
  node_deployment_docs["Deployment instructions<br/>documentation<br/>[DEPLOYMENT.md]"]
end

node_apache -->|"routes public requests"| node_public_entry
node_public_entry -->|"initializes"| node_bootstrap
node_public_entry -->|"selects page"| node_content_selection
node_content_selection -->|"reads CMS content"| node_database
node_content_selection -->|"assembles"| node_layout_start
node_layout_start -->|"includes"| node_nav_partial
node_layout_start -->|"wraps"| node_page_templates
node_page_templates -->|"completes layout"| node_layout_end
node_booking_widget -->|"submits lead data"| node_booking_api
node_booking_api -->|"stores booking"| node_database
node_booking_api -.->|"sends notification"| node_mailer
node_whatsapp_api -->|"reads and stores flow state"| node_database
node_admin_login -->|"authorizes access"| node_admin_app
node_admin_app -->|"uses shared initialization"| node_bootstrap
node_admin_app -->|"opens CRUD workflow"| node_page_editor
node_page_editor -->|"updates content"| node_database
node_admin_app -->|"manages analysis"| node_analysis
node_analysis -->|"persists results"| node_database
node_migration -->|"applies changes"| node_database
node_booking_migration -->|"migration input"| node_migration
node_deployment -->|"deploys application"| node_apache
node_deployment_docs -.->|"documents"| node_deployment

click node_apache "https://github.com/drawleados-dotcom/drawleadweb/blob/main/.htaccess"
click node_public_entry "https://github.com/drawleados-dotcom/drawleadweb/blob/main/index.php"
click node_bootstrap "https://github.com/drawleados-dotcom/drawleadweb/blob/main/includes/bootstrap.php"
click node_layout_start "https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/layout-start.php"
click node_page_templates "https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/home-body.php"
click node_layout_end "https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/layout-end.php"
click node_nav_partial "https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/partials/nav.php"
click node_booking_widget "https://github.com/drawleados-dotcom/drawleadweb/blob/main/assets/booking.js"
click node_booking_api "https://github.com/drawleados-dotcom/drawleadweb/blob/main/api/booking-submit.php"
click node_whatsapp_api "https://github.com/drawleados-dotcom/drawleadweb/blob/main/api/whatsapp-flow.php"
click node_admin_login "https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/login.php"
click node_admin_app "https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/index.php"
click node_page_editor "https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/page-edit.php"
click node_database "https://github.com/drawleados-dotcom/drawleadweb/blob/main/sql/schema.sql"
click node_mailer "https://github.com/drawleados-dotcom/drawleadweb/blob/main/includes/mailer.php"
click node_analysis "https://github.com/drawleados-dotcom/drawleadweb/blob/main/includes/analyze.php"
click node_migration "https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/run-migrations.php"
click node_booking_migration "https://github.com/drawleados-dotcom/drawleadweb/blob/main/sql/migrations/003_booking_system.sql"
click node_uploads "https://github.com/drawleados-dotcom/drawleadweb/blob/main/uploads/.htaccess"
click node_deployment "https://github.com/drawleados-dotcom/drawleadweb/blob/main/.github/workflows/deploy.yml"
click node_deployment_docs "https://github.com/drawleados-dotcom/drawleadweb/blob/main/DEPLOYMENT.md"

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_public_entry,node_content_selection,node_layout_start,node_page_templates,node_layout_end,node_nav_partial,node_booking_widget,node_booking_api,node_whatsapp_api toneBlue
class node_admin_login,node_admin_app,node_page_editor toneAmber
class node_bootstrap,node_database,node_mailer,node_analysis toneMint
class node_apache,node_migration,node_booking_migration,node_uploads,node_deployment,node_deployment_docs toneRose
```

## Components

### Public Website

- [Public entry](https://github.com/drawleados-dotcom/drawleadweb/blob/main/index.php): PHP entry point · `index.php`
- **Page & content selection**: CMS rendering · Resolves database-managed content and its template type.
- [Layout start](https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/layout-start.php): layout template · `templates/layout-start.php`
- [Content templates](https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/home-body.php): page templates · Homepage, blog, case study, booking, service, industry, and platform bodies. · `templates/home-body.php`
- [Layout end](https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/layout-end.php): layout template · `templates/layout-end.php`
- [Navigation partial](https://github.com/drawleados-dotcom/drawleadweb/blob/main/templates/partials/nav.php): shared partial · `templates/partials/nav.php`
- [Booking widget](https://github.com/drawleados-dotcom/drawleadweb/blob/main/assets/booking.js): browser JavaScript · Embedded public lead-capture interaction. · `assets/booking.js`
- [Booking submission API](https://github.com/drawleados-dotcom/drawleadweb/blob/main/api/booking-submit.php): PHP API endpoint · `api/booking-submit.php`
- [WhatsApp flow API](https://github.com/drawleados-dotcom/drawleadweb/blob/main/api/whatsapp-flow.php): PHP API endpoint · `api/whatsapp-flow.php`

### Admin CMS

- [Admin authentication](https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/login.php): PHP login · Establishes the authenticated admin session boundary. · `admin/login.php`
- [Admin control plane](https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/index.php): PHP admin application · Manages content, users, lead features, analytics, and deployments. · `admin/index.php`
- [Page editor](https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/page-edit.php): CMS CRUD · `admin/page-edit.php`

### Shared Services & Data

- [Application bootstrap](https://github.com/drawleados-dotcom/drawleadweb/blob/main/includes/bootstrap.php): shared initialization · Initializes configuration, database access, sessions, and common helpers. · `includes/bootstrap.php`
- [CMS database](https://github.com/drawleados-dotcom/drawleadweb/blob/main/sql/schema.sql): persistent data · Stores content, users, feature state, bookings, and lead-flow data. · `sql/schema.sql`
- [Mailer integration](https://github.com/drawleados-dotcom/drawleadweb/blob/main/includes/mailer.php): notification service · `includes/mailer.php`
- [SEO analysis service](https://github.com/drawleados-dotcom/drawleadweb/blob/main/includes/analyze.php): application service · `includes/analyze.php`

### Operations

- [Apache routing](https://github.com/drawleados-dotcom/drawleadweb/blob/main/.htaccess): web server · Routes PHP requests and enforces repository-managed access rules. · `.htaccess`
- [Migration operation](https://github.com/drawleados-dotcom/drawleadweb/blob/main/admin/run-migrations.php): admin operation · Applies ordered database changes from the application. · `admin/run-migrations.php`
- [Booking schema migration](https://github.com/drawleados-dotcom/drawleadweb/blob/main/sql/migrations/003_booking_system.sql): SQL migration · `sql/migrations/003_booking_system.sql`
- [Persistent uploads](https://github.com/drawleados-dotcom/drawleadweb/blob/main/uploads/.htaccess): writable storage · Application-uploaded data with dedicated access rules. · `uploads/.htaccess`
- [Deployment workflow](https://github.com/drawleados-dotcom/drawleadweb/blob/main/.github/workflows/deploy.yml): GitHub Actions · `.github/workflows/deploy.yml`
- [Deployment instructions](https://github.com/drawleados-dotcom/drawleadweb/blob/main/DEPLOYMENT.md): documentation · `DEPLOYMENT.md`

## Connections

- Apache routing → Public entry: routes public requests
- Public entry → Application bootstrap: initializes
- Public entry → Page & content selection: selects page
- Page & content selection → CMS database: reads CMS content
- Page & content selection → Layout start: assembles
- Layout start → Navigation partial: includes
- Layout start → Content templates: wraps
- Content templates → Layout end: completes layout
- Booking widget → Booking submission API: submits lead data
- Booking submission API → CMS database: stores booking
- Booking submission API → Mailer integration: sends notification
- WhatsApp flow API → CMS database: reads and stores flow state
- Admin authentication → Admin control plane: authorizes access
- Admin control plane → Application bootstrap: uses shared initialization
- Admin control plane → Page editor: opens CRUD workflow
- Page editor → CMS database: updates content
- Admin control plane → SEO analysis service: manages analysis
- SEO analysis service → CMS database: persists results
- Migration operation → CMS database: applies changes
- Booking schema migration → Migration operation: migration input
- Deployment workflow → Apache routing: deploys application
- Deployment instructions → Deployment workflow: documents
