# yasblha/proquote_symfony architecture

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

- Interactive diagram: https://gitdiagram.com/yasblha/proquote_symfony
- Repository: https://github.com/yasblha/proquote_symfony

## Overview

1. **Repository shape**
   - This is a **Symfony 6.4 monolith** built around classic MVC boundaries: `Controller` for HTTP entry points, `Entity`/`Repository` for persistence, `Service` for business logic, `Form` for request validation/input, and Twig templates for rendering.
   - The app is centered on **quote/invoice management**, with supporting modules for clients, products/services, stock, payments, interactions, and user/account security.

2. **Core domain model**
   - The main persistent entities are `Client`, `Devis` (quote), `QuoteItem`, `Invoice`, `InvoiceItem`, `Payment`, `Interaction`, `Product`, `Service`, and `User`.
   - This implies a domain where a client can have quotes, invoices, payments, and interaction history, while products/services are catalog inputs for line items and stock-related operations.

3. **Request/response layer**
   - Controllers are separated by feature: `DashboardController`, `ClientController`, `DevisController`, `InvoiceController`, `PaymentController`, `ProductController`, `ServiceController`, `StockController`, `InteractionController`, `ExportController`, plus auth/account controllers (`Security`, `Registration`, `ResetPassword`, `JWT`).
   - `MainController` and `AdminController` likely provide landing/admin entry points, while `ApiController` and `JWTController` expose machine-oriented endpoints.

4. **Business logic boundary**
   - Most non-trivial rules are extracted into services rather than staying in controllers.
   - Key services are:
     - `DevisWorkflowService` for quote lifecycle and conversion behavior
     - `PaymentService` and `PaymentDataService` for payment processing/representation
     - `InvoicePdfService` and `PdfGenerator` for document creation
     - `ExportService` for report exports
     - `ReminderService` and the reminder commands for scheduled follow-up
     - `DashboardStatsService` for KPI aggregation
     - `ReferenceGenerator` for document numbering/reference rules
     - `EmailService` for outbound mail coordination

5. **Primary business flow: quote to invoice**
   - The most important data flow is: **create/edit quote → validate by client via tokenized link → accept/reject/expire → optionally convert to invoice**.
   - The repo includes dedicated validation pages under `templates/devis/validation/*` and a `DevisValidationController`, which makes client-side quote approval a distinct boundary from internal administration.

6. **Billing and payment flow**
   - Invoices are a first-class aggregate, with line-item templates and PDF output.
   - Payments are modeled separately from invoices, and a `DataTransformer/PaymentDataTransformer.php` suggests form/UI input is normalized before persistence or further processing.
   - This separation supports a flow of **invoice issuance → payment capture/recording → status tracking → reminders**.

7. **Presentation layer**
   - UI rendering is Twig-based, with feature folders for `dashboard`, `client`, `devis`, `invoice`, `payment`, `product`, `service`, `stock`, `export`, and account flows.
   - Reusable UI is organized under `templates/components` and `src/Twig/Components`, indicating a componentized server-rendered UI.
   - Frontend behavior is lightweight and mostly incremental: `assets/` and `public/js/controllers` contain JavaScript controllers, with Symfony UX-style wiring (`controllers.json`, `ux_live_component` route).

8. **Realtime and async infrastructure**
   - The app is configured with **Mercure**, **Messenger**, **Mailer**, and **Notifier**, so the architecture supports event-like updates, queued/background tasks, and outbound notifications.
   - `templates/broadcast/Invoice.stream.html.twig` strongly suggests live invoice updates are broadcast to the UI, likely for dashboard or document stream refreshes.

9. **Security and identity**
   - Authentication is handled by Symfony Security with a custom authenticator (`AppAuthenticator`) and a JWT path (`LexikJWTAuthenticationBundle`, `JWTController`).
   - The repo also includes registration and password reset flows, plus validation utilities like a custom `Siret` constraint, which shows business-specific input validation is part of the security/data integrity boundary.

10. **Stock, catalog, and operational data**
   - `Product`, `Service`, and `StockController` indicate the app is not just billing; it also manages catalog items and stock movements/alerts.
   - The stock feature appears operationally separate from invoicing, but connected via shared product data and likely used to reflect inventory impact when items are sold or moved.

11. **Exports, PDFs, and document generation**
   - There is a dedicated export path (`config/routes/export.yaml`, `templates/export/*`, `docs/EXPORTS.md`) and dedicated PDF templates for quotes, invoices, and financial reports.
   - Document generation is therefore a distinct subsystem: **domain data → Twig document template → PDF/export service → downloadable artifact or emailed document**.

12. **Infrastructure and runtime**
   - The repo is containerized with **Docker**, **Caddy**, and **PHP-FPM**, and uses **Doctrine migrations** against a relational database (README indicates PostgreSQL).
   - Build/runtime tooling includes Composer, Node tooling for assets, Tailwind CSS, and Symfony’s asset pipeline configuration (`asset_mapper`, `webpack_encore`, `symfonycasts_tailwind`), which means the frontend is assembled from a mix of server-rendered Twig and compiled/static assets.

13. **Background jobs and maintenance**
   - Console commands such as `LoadFixturesCommand`, `SendRemindersCommand`, and `SendDevisRemindersCommand` show that data seeding and reminder dispatch are scheduled/operational workflows rather than request-time logic.
   - This separates interactive user actions from periodic maintenance and notification automation.

14. **Testing and observability**
   - There are controller-level tests under `tests/Controller`, plus a Symfony test bootstrap and PHPUnit config.
   - `web_profiler`, debug config, and flash-message partials imply the app is designed for iterative admin workflow with local inspection and diagnostics during development.

Main entry points: [`templates/base.html.twig`](https://github.com/yasblha/proquote_symfony/blob/main/templates/base.html.twig) (Twig UI), [`src/Service/DevisWorkflowService.php`](https://github.com/yasblha/proquote_symfony/blob/main/src/Service/DevisWorkflowService.php) (Quote Workflow), [`src/Entity/Invoice.php`](https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Invoice.php) (Invoice Model), [`src/Controller/DevisController.php`](https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/DevisController.php) (Quotes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_dashboard_controller["Dashboard<br/>controller"]
  node_client_controller["Clients<br/>controller"]
  node_devis_controller["Quotes<br/>controller"]
  node_devis_validation_controller["Validate Quote<br/>controller"]
  node_invoice_controller["Invoices<br/>controller"]
  node_payment_controller["Payments<br/>controller"]
  node_catalog_controllers["Catalog Ops<br/>controllers"]
  node_auth_controllers["Auth Flow<br/>controllers"]
  node_twig_ui["Twig UI<br/>presentation<br/>[base.html.twig]"]
end

subgraph group_domain["Domain"]
  node_devis_entity[("Quote Model<br/>entity<br/>[Devis.php]")]
  node_invoice_entity[("Invoice Model<br/>entity<br/>[Invoice.php]")]
  node_payment_entity[("Payment Model<br/>entity<br/>[Payment.php]")]
  node_client_entity[("Client Model<br/>entity<br/>[Client.php]")]
  node_catalog_entities[("Catalog Model<br/>entities<br/>[Product.php]")]
end

subgraph group_application["Application"]
  node_devis_workflow_service{{"Quote Workflow"}}
  node_payment_service{{"Payment Service<br/>[PaymentService.php]"}}
  node_billing_services{{"Billing Docs<br/>services"}}
  node_export_and_reminders{{"Exports & Reminders<br/>services"}}
  node_dashboard_stats_service{{"Stats"}}
end

subgraph group_infrastructure["Infrastructure"]
  node_security_stack["Security Stack"]
  node_async_runtime["Async Runtime<br/>messaging<br/>[messenger.yaml]"]
end

node_dashboard_controller -->|"reads KPIs"| node_dashboard_stats_service
node_dashboard_controller -->|"renders"| node_twig_ui
node_client_controller -->|"manages"| node_client_entity
node_client_controller -->|"renders"| node_twig_ui
node_devis_controller -->|"manages"| node_devis_entity
node_devis_controller -->|"orchestrates"| node_devis_workflow_service
node_devis_controller -->|"renders"| node_twig_ui
node_devis_validation_controller -->|"validates"| node_devis_workflow_service
node_devis_validation_controller -->|"renders"| node_twig_ui
node_invoice_controller -->|"manages"| node_invoice_entity
node_invoice_controller -->|"creates docs"| node_billing_services
node_invoice_controller -->|"renders"| node_twig_ui
node_payment_controller -->|"manages"| node_payment_entity
node_payment_controller -->|"delegates"| node_payment_service
node_payment_controller -->|"renders"| node_twig_ui
node_catalog_controllers -->|"manages"| node_catalog_entities
node_catalog_controllers -->|"renders"| node_twig_ui
node_auth_controllers -->|"authenticates"| node_security_stack
node_auth_controllers -->|"renders"| node_twig_ui
node_devis_workflow_service -->|"updates"| node_devis_entity
node_devis_workflow_service -->|"converts"| node_invoice_entity
node_payment_service -->|"persists"| node_payment_entity
node_billing_services -->|"uses"| node_invoice_entity
node_billing_services -->|"uses"| node_catalog_entities
node_billing_services -->|"builds documents"| node_twig_ui
node_export_and_reminders -->|"runs on"| node_async_runtime
node_export_and_reminders -->|"renders"| node_twig_ui
node_dashboard_stats_service -->|"reads"| node_invoice_entity
node_dashboard_stats_service -->|"reads"| node_payment_entity

click node_dashboard_controller "https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/DashboardController.php"
click node_client_controller "https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/ClientController.php"
click node_devis_controller "https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/DevisController.php"
click node_devis_validation_controller "https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/DevisValidationController.php"
click node_invoice_controller "https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/InvoiceController.php"
click node_payment_controller "https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/PaymentController.php"
click node_devis_entity "https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Devis.php"
click node_invoice_entity "https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Invoice.php"
click node_payment_entity "https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Payment.php"
click node_client_entity "https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Client.php"
click node_catalog_entities "https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Product.php"
click node_devis_workflow_service "https://github.com/yasblha/proquote_symfony/blob/main/src/Service/DevisWorkflowService.php"
click node_payment_service "https://github.com/yasblha/proquote_symfony/blob/main/src/Service/PaymentService.php"
click node_dashboard_stats_service "https://github.com/yasblha/proquote_symfony/blob/main/src/Service/DashboardStatsService.php"
click node_security_stack "https://github.com/yasblha/proquote_symfony/blob/main/src/Security/AppAuthenticator.php"
click node_async_runtime "https://github.com/yasblha/proquote_symfony/blob/main/config/packages/messenger.yaml"
click node_twig_ui "https://github.com/yasblha/proquote_symfony/blob/main/templates/base.html.twig"

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_dashboard_controller,node_client_controller,node_devis_controller,node_devis_validation_controller,node_invoice_controller,node_payment_controller,node_catalog_controllers,node_auth_controllers,node_twig_ui toneBlue
class node_devis_entity,node_invoice_entity,node_payment_entity,node_client_entity,node_catalog_entities toneAmber
class node_devis_workflow_service,node_payment_service,node_billing_services,node_export_and_reminders,node_dashboard_stats_service toneMint
class node_security_stack,node_async_runtime toneRose
```

## Components

### Presentation

HTTP entry points and Twig rendering

- [Dashboard](https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/DashboardController.php): controller · Admin KPI landing page · `src/Controller/DashboardController.php`
- [Clients](https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/ClientController.php): controller · Client CRUD entry point · `src/Controller/ClientController.php`
- [Quotes](https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/DevisController.php): controller · Quote lifecycle entry point · `src/Controller/DevisController.php`
- [Validate Quote](https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/DevisValidationController.php): controller · Client-facing quote approval flow · `src/Controller/DevisValidationController.php`
- [Invoices](https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/InvoiceController.php): controller · Invoice CRUD and document views · `src/Controller/InvoiceController.php`
- [Payments](https://github.com/yasblha/proquote_symfony/blob/main/src/Controller/PaymentController.php): controller · Payment capture and listing · `src/Controller/PaymentController.php`
- **Catalog Ops**: controllers · Products, services, stock, interaction, export, and settings entry points
- **Auth Flow**: controllers · Security, registration, password reset, JWT, and test mail
- [Twig UI](https://github.com/yasblha/proquote_symfony/blob/main/templates/base.html.twig): presentation · Server-rendered views and reusable components · `templates/base.html.twig`

### Domain

Core billing and catalog model

- [Quote Model](https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Devis.php): entity · Devis and quote items · `src/Entity/Devis.php`
- [Invoice Model](https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Invoice.php): entity · Invoice and invoice items · `src/Entity/Invoice.php`
- [Payment Model](https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Payment.php): entity · Payments linked to billing · `src/Entity/Payment.php`
- [Client Model](https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Client.php): entity · Customer records and history · `src/Entity/Client.php`
- [Catalog Model](https://github.com/yasblha/proquote_symfony/blob/main/src/Entity/Product.php): entities · Products and services used in line items and stock · `src/Entity/Product.php`

### Application

Business workflows and orchestration

- [Quote Workflow](https://github.com/yasblha/proquote_symfony/blob/main/src/Service/DevisWorkflowService.php): service · Quote lifecycle, acceptance, and conversion · `src/Service/DevisWorkflowService.php`
- [Payment Service](https://github.com/yasblha/proquote_symfony/blob/main/src/Service/PaymentService.php): service · Payment processing coordination · `src/Service/PaymentService.php`
- **Billing Docs**: services · PDF generation, reference rules, and payment data shaping
- **Exports & Reminders**: services · Financial export, reminders, and email delivery
- [Stats](https://github.com/yasblha/proquote_symfony/blob/main/src/Service/DashboardStatsService.php): service · Dashboard KPI aggregation · `src/Service/DashboardStatsService.php`

### Infrastructure

Security, async, export, and runtime support

- [Security Stack](https://github.com/yasblha/proquote_symfony/blob/main/src/Security/AppAuthenticator.php): security · Authenticator and JWT authentication · `src/Security/AppAuthenticator.php`
- [Async Runtime](https://github.com/yasblha/proquote_symfony/blob/main/config/packages/messenger.yaml): messaging · Messenger, Mercure, Mailer, and notifier-backed workflows · `config/packages/messenger.yaml`

## Connections

- Dashboard → Stats: reads KPIs · Dashboard page is built from aggregated statistics
- Dashboard → Twig UI: renders · Uses Twig dashboard and shared components
- Clients → Client Model: manages · CRUD around client records
- Clients → Twig UI: renders · Client pages and forms
- Quotes → Quote Model: manages · Quote persistence and editing
- Quotes → Quote Workflow: orchestrates · Delegates lifecycle transitions and conversion
- Quotes → Twig UI: renders · Quote forms, lists, and PDFs
- Validate Quote → Quote Workflow: validates · Tokenized client approval flow
- Validate Quote → Twig UI: renders · Public validation pages
- Invoices → Invoice Model: manages · Invoice CRUD and line items
- Invoices → Billing Docs: creates docs · Invoice PDF generation and reference handling
- Invoices → Twig UI: renders · Invoice views and templates
- Payments → Payment Model: manages · Payment records and status
- Payments → Payment Service: delegates · Business rules for payment handling
- Payments → Twig UI: renders · Payment screens
- Catalog Ops → Catalog Model: manages · Products, services, stock, and interactions share catalog data
- Catalog Ops → Twig UI: renders · Catalog, stock, export, and settings pages
- Auth Flow → Security Stack: authenticates · Login, registration, reset, and JWT paths
- Auth Flow → Twig UI: renders · Authentication and account views
- Quote Workflow → Quote Model: updates · Transitions quote state and acceptance
- Quote Workflow → Invoice Model: converts · Creates invoices from accepted quotes
- Payment Service → Payment Model: persists · Coordinates payment domain changes
- Billing Docs → Invoice Model: uses · Invoice PDF and numbering depend on billing model
- Billing Docs → Catalog Model: uses · Line items and documents reference catalog data
- Billing Docs → Twig UI: builds documents · Twig templates drive PDFs and exports
- Exports & Reminders → Async Runtime: runs on · Background mail, messenger, and scheduled jobs
- Exports & Reminders → Twig UI: renders · Export and email templates
- Stats → Invoice Model: reads · Aggregates billing activity
- Stats → Payment Model: reads · Aggregates payment activity
