# yasblha/proquote architecture

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

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

## Overview

##### Project type and purpose
- This is a full-stack, monolithic web application built on Symfony 6.4.
- Purpose: manage quotes (“devis”), invoices, clients, payments, reminders, exports and dashboard statistics—all in one system.

##### File structure
- Top-level directories:
– src/: Symfony PHP code (Controllers, Entities, Repositories, Services, Forms, Validators, Commands)
– templates/: Twig views for all UI screens (dashboard, quotes, invoices, clients, emails, etc.)
– public/: compiled assets (CSS/JS), index.php bootstrap
– assets/: source JS (Alpine.js, vanilla JS controllers), CSS (Tailwind)
– config/, migrations/, docker/: framework config, database migrations, Docker setup
- Key patterns:
– MVC (Controller → Service → Repository → Entity → Twig)
– Service layer for business logic (PdfGenerator, DashboardStatsService, DevisWorkflowService, ReminderService)
– Doctrine ORM with custom repositories, migrations, data fixtures
– Event-driven reminders via Messenger + Mercure
– JWT API endpoints for headless access

##### README for additional insights
- Backend: Symfony MVC, Doctrine, custom services, JWT, security, validation
- Frontend: Twig, TailwindCSS, Chart.js, Alpine.js, vanilla JS
- Infrastructure: Docker Compose (PHP-FPM, Caddy web server, PostgreSQL, Mercure, Mailer), SMTP service
- External integrations: email/SMS reminders, Mercure hub for real-time, optional payment gateway

##### Main components and their interactions
a. User Agents (Browsers, REST clients)
b. Ingress / Web Server (Caddy container)
c. PHP-FPM / Symfony App
– HTTP Kernel → Controllers → Services → Repositories → Database
– Services emit Events → Messenger bus → Worker processes
– Mercure hub publishes real-time updates
d. Asset pipeline
– Webpack Encore / importmap → compiles TailwindCSS & JS → serves via public/
e. Database (PostgreSQL)
f. Cache & Session (Redis or filesystem – configured in cache.yaml)
g. Message broker (default Doctrine transport or Redis/RabbitMQ if configured)
h. Mercure Hub (real‐time push)
i. Mailer (SMTP or third‐party) for notifications & reminders
j. External services (e.g., SMS gateway if enabled)

##### Architectural patterns & design principles
- MVC separation: Controllers (HTTP) vs Twig (View) vs Services/Entities (Model)
- Service layer encapsulates business rules (PDF generation, workflow, reminders)
- Repository pattern for data access
- Event-driven processing via Messenger (asynchronous tasks)
- Real-time updates via Mercure
- Configuration-as-Code (YAML in config/) and containerization (Docker)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients"
        direction TB
        Browser["Browser / REST Client"]:::external
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Caddy["Caddy Web Server"]:::compute
        PHPFPM["PHP-FPM / Symfony App"]:::compute
        MessageQueue["Message Queue"]:::queue
        MercureHub["Mercure Hub"]:::broker
    end

    %% Application
    subgraph "Symfony Monolith"
        direction TB
        Entry["public/index.php"]:::compute
        HTTPKernel["HTTP Kernel"]:::compute
        Controllers["HTTP Controllers"]:::compute
        subgraph "Business Services"
            direction TB
            PdfGen["PdfGenerator"]:::compute
            InvPdf["InvoicePdfService"]:::compute
            Stats["DashboardStatsService"]:::compute
            Workflow["DevisWorkflowService"]:::compute
            Reminder["ReminderService"]:::compute
            EmailService["EmailService"]:::compute
            ExportSvc["ExportService"]:::compute
            PaymentSvc["PaymentService"]:::compute
            PaymentData["PaymentDataService"]:::compute
            RefGen["ReferenceGenerator"]:::compute
        end
        Repos["Repositories"]:::compute
    end

    %% Asset Pipeline
    subgraph "Asset Pipeline"
        direction TB
        Webpack["Webpack Encore / Importmap"]:::compute
        AssetsSrc["assets/ (CSS/JS)"]:::compute
        PublicAssets["public/css/, public/js/"]:::compute
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Postgres["PostgreSQL"]:::storage
        Cache["Cache & Session (Redis)"]:::storage
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SMTP["SMTP / Mailer"]:::external
        SMS["SMS Gateway"]:::external
    end

    %% Connections
    Browser -->|HTTP/HTTPS| Caddy
    Browser -->|WebSocket| MercureHub
    Browser -->|Assets| PublicAssets

    Caddy -->|FastCGI| PHPFPM
    PHPFPM -->|bootstrap| Entry
    Entry -->|handle| HTTPKernel
    HTTPKernel -->|route| Controllers
    Controllers -->|invoke| PdfGen
    Controllers -->|invoke| InvPdf
    Controllers -->|invoke| Stats
    Controllers -->|invoke| Workflow
    Controllers -->|invoke| Reminder
    Controllers -->|invoke| ExportSvc
    Controllers -->|invoke| PaymentSvc
    Controllers -->|invoke| RefGen
    Controllers -->|use| Repos
    Controllers -->|use| HTTPKernel

    PdfGen -->|use| Repos
    InvPdf -->|use| Repos
    Stats -->|use| Repos
    Workflow -->|use| Repos
    Reminder -->|dispatch Event| MessageQueue
    ExportSvc -->|use| Repos
    PaymentSvc -->|use| Repos
    PaymentData -->|use| Repos
    RefGen -->|use| Repos

    MessageQueue -->|consume| Reminder
    MessageQueue -->|consume| EmailService
    MessageQueue -->|consume| ExportSvc
    MessageQueue -->|consume| PaymentSvc

    Reminder -->|send| SMTP
    EmailService -->|send| SMTP
    MessageQueue -->|publish| MercureHub
    MercureHub -->|real-time| Browser

    Repos -->|SQL| Postgres
    HTTPKernel -->|cache/session| Cache

    Webpack -->|compile| PublicAssets
    AssetsSrc -->|input| Webpack

    %% Click Events
    click Entry "https://github.com/yasblha/proquote/blob/develop/public/index.php"
    click Controllers "https://github.com/yasblha/proquote/tree/develop/src/Controller/"
    click PdfGen "https://github.com/yasblha/proquote/blob/develop/src/Service/PdfGenerator.php"
    click InvPdf "https://github.com/yasblha/proquote/blob/develop/src/Service/InvoicePdfService.php"
    click Stats "https://github.com/yasblha/proquote/blob/develop/src/Service/DashboardStatsService.php"
    click Workflow "https://github.com/yasblha/proquote/blob/develop/src/Service/DevisWorkflowService.php"
    click Reminder "https://github.com/yasblha/proquote/blob/develop/src/Service/ReminderService.php"
    click EmailService "https://github.com/yasblha/proquote/blob/develop/src/Service/EmailService.php"
    click ExportSvc "https://github.com/yasblha/proquote/blob/develop/src/Service/ExportService.php"
    click PaymentSvc "https://github.com/yasblha/proquote/blob/develop/src/Service/PaymentService.php"
    click PaymentData "https://github.com/yasblha/proquote/blob/develop/src/Service/PaymentDataService.php"
    click RefGen "https://github.com/yasblha/proquote/blob/develop/src/Service/ReferenceGenerator.php"

    %% Styles
    classDef compute fill:#D6EAF8,stroke:#3498DB,stroke-width:1px
    classDef storage fill:#D5F5E3,stroke:#1E8449,stroke-width:1px
    classDef external fill:#F2F3F4,stroke:#7F8C8D,stroke-width:1px
    classDef broker fill:#FCF3CF,stroke:#F1C40F,stroke-width:1px
    classDef queue fill:#FDEBD0,stroke:#CA6F1E,stroke-width:1px
```
