# aadhil728/quoteflowapp architecture

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

- Interactive diagram: https://gitdiagram.com/aadhil728/quoteflowapp
- Repository: https://github.com/aadhil728/quoteflowapp

## Overview

#### Purpose and Entry Points
QuoteFlow AI is a Laravel server-rendered business application for multi-workspace quotation creation, public customer acceptance, invoice conversion, and payment reconciliation. HTTP begins at `public/index.php`, is composed in `bootstrap/app.php`, and routes through `routes/web.php` and `routes/auth.php`. CLI installation is exposed through `artisan` and `app/Console/Commands/InstallApplicationCommand.php`.

#### Application Boundary and Tenancy
Authenticated requests resolve a current workspace, then enforce role/permission-scoped access before reaching workspace-owned resources. `app/Http/Middleware/ResolveWorkspace.php` establishes tenant context via `app/Support/WorkspaceContext.php`; `app/Http/Middleware/RequireWorkspacePermission.php` protects operations. The tenancy persistence model centers on `app/Models/Workspace.php`, `app/Models/WorkspaceMembership.php`, and `app/Models/User.php`.

#### Workspace Business Catalogue
Each workspace manages customers, services/categories, templates, branding/settings, and invitations—the source data for quotations. Controllers provide the HTML workflow boundary, notably `app/Http/Controllers/CustomerController.php`, `app/Http/Controllers/ServiceController.php`, and `app/Http/Controllers/TemplateController.php`. Core records include `app/Models/Customer.php`, `app/Models/Service.php`, and `app/Models/TemplateVersion.php`.

#### Quotation Authoring and Lifecycle
Quotation authoring is the central domain flow: build sections/items/options, calculate monetary values, version/revise, and record lifecycle events/comments. `app/Http/Controllers/QuotationController.php` drives internal screens; `app/Domain/Quotations/MoneyCalculator.php` owns calculation logic. Aggregate persistence spans `app/Models/Quotation.php`, `app/Models/QuotationItem.php`, and `app/Models/QuotationRevision.php`, with statuses represented by `app/Enums/QuotationStatus.php`.

#### Public Customer Decision Flow
Externally shared quotations use secure public tokens rather than the authenticated workspace surface. `app/Http/Controllers/PublicQuotationController.php` serves the public document and decision actions, guarded by `app/Http/Middleware/SecurePublicDocument.php`. Acceptance, option selections, comments, and public-token state are persisted in `app/Models/QuotationAcceptance.php`, `app/Models/QuotationOptionalSelection.php`, and `app/Models/QuotationPublicToken.php`. Public and internal rendering use Blade views under `resources/views/public/` and `resources/views/quotations/`.

#### Invoice, Payments, and Webhooks
An accepted quotation can be converted into an invoice by `app/Actions/ConvertQuotationToInvoice.php`; invoices and line items live in `app/Models/Invoice.php` and `app/Models/InvoiceItem.php`. Payment lifecycle handling is action-oriented: `app/Actions/RecordManualPayment.php`, `app/Actions/ProcessPaymentWebhook.php`, and `app/Actions/ReconcileInvoice.php`. Provider webhook ingress is `app/Http/Controllers/PaymentWebhookController.php`; deduplication/audit state is represented by `app/Models/PaymentProviderEvent.php` and `app/Models/Payment.php`.

#### External Integrations and Runtime Infrastructure
PHP/Laravel, Eloquent migrations, session/auth, cache, queues, mail, filesystem storage, and database connections are configured under `config/`. Payments are abstracted by `app/Contracts/PaymentGateway.php`, selected through `app/Support/PaymentGatewayRegistry.php`, with Stripe and PayPal implementations at `app/Infrastructure/Payments/StripeGateway.php` and `app/Infrastructure/Payments/PayPalGateway.php`; provider settings reside in `config/payments.php`. PDFs are isolated behind `app/Contracts/PdfRenderer.php` with Dompdf at `app/Infrastructure/Pdf/DompdfRenderer.php`. The frontend is Blade plus Vite-managed CSS/JS (`resources/views/`, `resources/css/`, `resources/js/app.js`).

Main entry points: [`app/Http/Controllers/QuotationController.php`](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/QuotationController.php) (Quotation authoring), [`app/Http/Middleware/ResolveWorkspace.php`](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Middleware/ResolveWorkspace.php) (Workspace access gate), [`app/Actions/ProcessPaymentWebhook.php`](https://github.com/aadhil728/quoteflowapp/blob/main/app/Actions/ProcessPaymentWebhook.php) (Payment lifecycle), [`app/Models/Quotation.php`](https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Quotation.php) (Quotation aggregate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP Application"]
  node_public_entry(("Public entry point<br/>Laravel entry<br/>[index.php]"))
  node_app_bootstrap["Application bootstrap<br/>Laravel composition<br/>[app.php]"]
  node_web_routes["Web and auth routes<br/>route definitions<br/>[web.php]"]
  node_blade_ui["Blade user interface<br/>server-rendered views"]
  node_installer["Application installer<br/>CLI command"]
end

subgraph group_workspace["Workspace Domain"]
  node_workspace_middleware["Workspace access gate<br/>tenant middleware"]
  node_workspace_context["Workspace context<br/>tenant context"]
  node_workspace_identity[("Workspace membership<br/>Eloquent models<br/>[Workspace.php]")]
  node_catalogue_controllers["Workspace catalogue<br/>HTML controllers"]
  node_catalogue_records[("Catalogue records<br/>Eloquent models<br/>[Customer.php]")]
end

subgraph group_quotations["Quotation Flow"]
  node_quotation_controller["Quotation authoring<br/>HTML controller"]
  node_quotation_domain[("Quotation aggregate<br/>domain models<br/>[Quotation.php]")]
  node_money_calculator["Money calculator<br/>domain service"]
  node_public_quotation["Public quotation decision<br/>public controller"]
  node_public_document_guard["Public token guard<br/>security middleware"]
end

subgraph group_billing["Billing &amp; Payments"]
  node_invoice_conversion["Invoice conversion<br/>application action"]
  node_invoice_records[("Invoices<br/>Eloquent models<br/>[Invoice.php]")]
  node_payment_webhook["Payment webhook ingress<br/>webhook controller"]
  node_payment_actions["Payment lifecycle<br/>application actions"]
  node_payment_records[("Payment audit records<br/>Eloquent models")]
end

subgraph group_integrations["Integration Adapters"]
  node_payment_gateway{{"Payment gateway registry<br/>provider abstraction"}}
  node_pdf_renderer{{"PDF renderer<br/>provider abstraction<br/>[PdfRenderer.php]"}}
end

node_public_entry -->|"boots"| node_app_bootstrap
node_app_bootstrap -->|"registers"| node_web_routes
node_web_routes -->|"authenticated requests"| node_workspace_middleware
node_workspace_middleware -->|"establishes"| node_workspace_context
node_workspace_context -->|"loads tenant"| node_workspace_identity
node_workspace_middleware -->|"authorizes"| node_catalogue_controllers
node_workspace_middleware -->|"authorizes"| node_quotation_controller
node_catalogue_controllers -->|"manages"| node_catalogue_records
node_catalogue_records -.->|"supplies source data"| node_quotation_controller
node_quotation_controller -->|"authors and revises"| node_quotation_domain
node_quotation_controller -->|"calculates totals"| node_money_calculator
node_quotation_controller -->|"renders"| node_blade_ui
node_public_quotation -->|"guarded by"| node_public_document_guard
node_public_document_guard -->|"validates token access"| node_quotation_domain
node_public_quotation -->|"records decisions"| node_quotation_domain
node_quotation_domain -->|"accepted quotation"| node_invoice_conversion
node_invoice_conversion -->|"creates"| node_invoice_records
node_payment_webhook -->|"dispatches"| node_payment_actions
node_payment_actions -->|"records and deduplicates"| node_payment_records
node_payment_actions -->|"reconciles"| node_invoice_records
node_payment_actions -->|"uses provider"| node_payment_gateway
node_quotation_controller -.->|"renders PDFs"| node_pdf_renderer

click node_public_entry "https://github.com/aadhil728/quoteflowapp/blob/main/public/index.php"
click node_app_bootstrap "https://github.com/aadhil728/quoteflowapp/blob/main/bootstrap/app.php"
click node_web_routes "https://github.com/aadhil728/quoteflowapp/blob/main/routes/web.php"
click node_workspace_middleware "https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Middleware/ResolveWorkspace.php"
click node_workspace_context "https://github.com/aadhil728/quoteflowapp/blob/main/app/Support/WorkspaceContext.php"
click node_workspace_identity "https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Workspace.php"
click node_catalogue_controllers "https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/CustomerController.php"
click node_catalogue_records "https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Customer.php"
click node_quotation_controller "https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/QuotationController.php"
click node_quotation_domain "https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Quotation.php"
click node_money_calculator "https://github.com/aadhil728/quoteflowapp/blob/main/app/Domain/Quotations/MoneyCalculator.php"
click node_public_quotation "https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/PublicQuotationController.php"
click node_public_document_guard "https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Middleware/SecurePublicDocument.php"
click node_invoice_conversion "https://github.com/aadhil728/quoteflowapp/blob/main/app/Actions/ConvertQuotationToInvoice.php"
click node_invoice_records "https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Invoice.php"
click node_payment_webhook "https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/PaymentWebhookController.php"
click node_payment_actions "https://github.com/aadhil728/quoteflowapp/blob/main/app/Actions/ProcessPaymentWebhook.php"
click node_payment_records "https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/PaymentProviderEvent.php"
click node_payment_gateway "https://github.com/aadhil728/quoteflowapp/blob/main/app/Support/PaymentGatewayRegistry.php"
click node_pdf_renderer "https://github.com/aadhil728/quoteflowapp/blob/main/app/Contracts/PdfRenderer.php"
click node_installer "https://github.com/aadhil728/quoteflowapp/blob/main/app/Console/Commands/InstallApplicationCommand.php"

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_app_bootstrap,node_web_routes,node_blade_ui,node_installer toneBlue
class node_workspace_middleware,node_workspace_context,node_workspace_identity,node_catalogue_controllers,node_catalogue_records toneAmber
class node_quotation_controller,node_quotation_domain,node_money_calculator,node_public_quotation,node_public_document_guard toneMint
class node_invoice_conversion,node_invoice_records,node_payment_webhook,node_payment_actions,node_payment_records toneRose
class node_payment_gateway,node_pdf_renderer toneIndigo
```

## Components

### HTTP Application

- [Public entry point](https://github.com/aadhil728/quoteflowapp/blob/main/public/index.php): Laravel entry · `public/index.php`
- [Application bootstrap](https://github.com/aadhil728/quoteflowapp/blob/main/bootstrap/app.php): Laravel composition · `bootstrap/app.php`
- [Web and auth routes](https://github.com/aadhil728/quoteflowapp/blob/main/routes/web.php): route definitions · `routes/web.php`
- **Blade user interface**: server-rendered views · Internal quotations and public document views.
- [Application installer](https://github.com/aadhil728/quoteflowapp/blob/main/app/Console/Commands/InstallApplicationCommand.php): CLI command · `app/Console/Commands/InstallApplicationCommand.php`

### Workspace Domain

- [Workspace access gate](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Middleware/ResolveWorkspace.php): tenant middleware · Resolves current workspace and enforces permissions. · `app/Http/Middleware/ResolveWorkspace.php`
- [Workspace context](https://github.com/aadhil728/quoteflowapp/blob/main/app/Support/WorkspaceContext.php): tenant context · `app/Support/WorkspaceContext.php`
- [Workspace membership](https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Workspace.php): Eloquent models · Workspace, membership, and user tenancy records. · `app/Models/Workspace.php`
- [Workspace catalogue](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/CustomerController.php): HTML controllers · Customers, services, and templates workflow. · `app/Http/Controllers/CustomerController.php`
- [Catalogue records](https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Customer.php): Eloquent models · Customers, services, and template versions. · `app/Models/Customer.php`

### Quotation Flow

- [Quotation authoring](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/QuotationController.php): HTML controller · `app/Http/Controllers/QuotationController.php`
- [Quotation aggregate](https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Quotation.php): domain models · Quotations, items, revisions, and lifecycle status. · `app/Models/Quotation.php`
- [Money calculator](https://github.com/aadhil728/quoteflowapp/blob/main/app/Domain/Quotations/MoneyCalculator.php): domain service · `app/Domain/Quotations/MoneyCalculator.php`
- [Public quotation decision](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/PublicQuotationController.php): public controller · Serves tokenized document, acceptance, options, and comments. · `app/Http/Controllers/PublicQuotationController.php`
- [Public token guard](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Middleware/SecurePublicDocument.php): security middleware · `app/Http/Middleware/SecurePublicDocument.php`

### Billing & Payments

- [Invoice conversion](https://github.com/aadhil728/quoteflowapp/blob/main/app/Actions/ConvertQuotationToInvoice.php): application action · Creates invoice from an accepted quotation. · `app/Actions/ConvertQuotationToInvoice.php`
- [Invoices](https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/Invoice.php): Eloquent models · Invoices and invoice line items. · `app/Models/Invoice.php`
- [Payment webhook ingress](https://github.com/aadhil728/quoteflowapp/blob/main/app/Http/Controllers/PaymentWebhookController.php): webhook controller · `app/Http/Controllers/PaymentWebhookController.php`
- [Payment lifecycle](https://github.com/aadhil728/quoteflowapp/blob/main/app/Actions/ProcessPaymentWebhook.php): application actions · Manual recording, webhook processing, and invoice reconciliation. · `app/Actions/ProcessPaymentWebhook.php`
- [Payment audit records](https://github.com/aadhil728/quoteflowapp/blob/main/app/Models/PaymentProviderEvent.php): Eloquent models · Payments and provider-event deduplication state. · `app/Models/PaymentProviderEvent.php`

### Integration Adapters

- [Payment gateway registry](https://github.com/aadhil728/quoteflowapp/blob/main/app/Support/PaymentGatewayRegistry.php): provider abstraction · Selects Stripe or PayPal gateway implementations. · `app/Support/PaymentGatewayRegistry.php`
- [PDF renderer](https://github.com/aadhil728/quoteflowapp/blob/main/app/Contracts/PdfRenderer.php): provider abstraction · Dompdf-backed document rendering boundary. · `app/Contracts/PdfRenderer.php`

## Connections

- Public entry point → Application bootstrap: boots
- Application bootstrap → Web and auth routes: registers
- Web and auth routes → Workspace access gate: authenticated requests
- Workspace access gate → Workspace context: establishes
- Workspace context → Workspace membership: loads tenant
- Workspace access gate → Workspace catalogue: authorizes
- Workspace access gate → Quotation authoring: authorizes
- Workspace catalogue → Catalogue records: manages
- Catalogue records → Quotation authoring: supplies source data
- Quotation authoring → Quotation aggregate: authors and revises
- Quotation authoring → Money calculator: calculates totals
- Quotation authoring → Blade user interface: renders
- Public quotation decision → Public token guard: guarded by
- Public token guard → Quotation aggregate: validates token access
- Public quotation decision → Quotation aggregate: records decisions
- Quotation aggregate → Invoice conversion: accepted quotation
- Invoice conversion → Invoices: creates
- Payment webhook ingress → Payment lifecycle: dispatches
- Payment lifecycle → Payment audit records: records and deduplicates
- Payment lifecycle → Invoices: reconciles
- Payment lifecycle → Payment gateway registry: uses provider
- Quotation authoring → PDF renderer: renders PDFs
