# samber/invoice-as-a-service architecture

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

- Interactive diagram: https://gitdiagram.com/samber/invoice-as-a-service
- Repository: https://github.com/samber/invoice-as-a-service

## Overview

Invoice as a service accepts JSON over HTTP, validates invoice and optional delivery settings, calculates totals, renders a PDF, then returns it directly or uploads it to configured destinations. The diagram follows the documented API route and the sampled controller and storage code. PDF internals and the template’s connection are not shown in excerpts, so that relationship is marked unverified; optional external delivery targets are documented in the README.

Main entry points: [`app/Http/Controllers/InvoiceController.php`](https://github.com/samber/invoice-as-a-service/blob/master/app/Http/Controllers/InvoiceController.php) (Invoice endpoint), [`app/Helpers/Storage.php`](https://github.com/samber/invoice-as-a-service/blob/master/app/Helpers/Storage.php) (Upload handling), [`routes/api.php`](https://github.com/samber/invoice-as-a-service/blob/master/routes/api.php) (API routes), [`app/Helpers/PDF.php`](https://github.com/samber/invoice-as-a-service/blob/master/app/Helpers/PDF.php) (PDF builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["HTTP request"]
  node_api_routes["API routes<br/>[api.php]"]
  node_invoice_controller["Invoice endpoint"]
end

subgraph group_invoice["Invoice processing"]
  node_validation_rules["Custom validation"]
  node_pdf_builder["PDF builder<br/>[PDF.php]"]
  node_invoice_template["Invoice template<br/>[default.blade.php]"]
end

subgraph group_delivery["PDF delivery"]
  node_storage_helper["Upload handling<br/>[Storage.php]"]
  node_s3_service[("S3 storage")]
  node_ftp_server[("FTP server")]
  node_webhook_service["Webhook receiver"]
  node_zapier_service["Zapier hook"]
end

subgraph group_runtime["Laravel runtime"]
  node_http_entry["HTTP entry<br/>[index.php]"]
  node_app_bootstrap["App bootstrap<br/>[app.php]"]
  node_http_kernel["HTTP kernel<br/>[Kernel.php]"]
  node_route_provider["Route provider"]
end

node_client(("API client"))

node_client -->|"sends request"| node_http_entry
node_http_entry -->|"loads app"| node_app_bootstrap
node_app_bootstrap -->|"binds kernel"| node_http_kernel
node_http_kernel -.->|"loads routing"| node_route_provider
node_route_provider -->|"registers API"| node_api_routes
node_api_routes -->|"routes request"| node_invoice_controller
node_invoice_controller -->|"validates fields"| node_validation_rules
node_invoice_controller -->|"builds PDF"| node_pdf_builder
node_pdf_builder -.->|"renders template"| node_invoice_template
node_invoice_controller -->|"uploads PDF"| node_storage_helper
node_storage_helper -->|"uploads PDF"| node_s3_service
node_storage_helper -->|"uploads PDF"| node_ftp_server
node_storage_helper -->|"posts PDF"| node_webhook_service
node_storage_helper -->|"posts PDF"| node_zapier_service
node_invoice_controller -->|"returns PDF or status"| node_client

click node_http_entry "https://github.com/samber/invoice-as-a-service/blob/master/public/index.php"
click node_app_bootstrap "https://github.com/samber/invoice-as-a-service/blob/master/bootstrap/app.php"
click node_http_kernel "https://github.com/samber/invoice-as-a-service/blob/master/app/Http/Kernel.php"
click node_route_provider "https://github.com/samber/invoice-as-a-service/blob/master/app/Providers/RouteServiceProvider.php"
click node_api_routes "https://github.com/samber/invoice-as-a-service/blob/master/routes/api.php"
click node_invoice_controller "https://github.com/samber/invoice-as-a-service/blob/master/app/Http/Controllers/InvoiceController.php"
click node_validation_rules "https://github.com/samber/invoice-as-a-service/tree/master/app/Rules"
click node_pdf_builder "https://github.com/samber/invoice-as-a-service/blob/master/app/Helpers/PDF.php"
click node_invoice_template "https://github.com/samber/invoice-as-a-service/blob/master/resources/views/invoices/default.blade.php"
click node_storage_helper "https://github.com/samber/invoice-as-a-service/blob/master/app/Helpers/Storage.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_api_routes,node_invoice_controller,node_client toneBlue
class node_validation_rules,node_pdf_builder,node_invoice_template toneAmber
class node_storage_helper,node_s3_service,node_ftp_server,node_webhook_service,node_zapier_service toneMint
class node_http_entry,node_app_bootstrap,node_http_kernel,node_route_provider toneRose
```

## Components

### HTTP request

- [API routes](https://github.com/samber/invoice-as-a-service/blob/master/routes/api.php): `routes/api.php`
- [Invoice endpoint](https://github.com/samber/invoice-as-a-service/blob/master/app/Http/Controllers/InvoiceController.php): `app/Http/Controllers/InvoiceController.php`

### Invoice processing

- [Custom validation](https://github.com/samber/invoice-as-a-service/tree/master/app/Rules): `app/Rules`
- [PDF builder](https://github.com/samber/invoice-as-a-service/blob/master/app/Helpers/PDF.php): `app/Helpers/PDF.php`
- [Invoice template](https://github.com/samber/invoice-as-a-service/blob/master/resources/views/invoices/default.blade.php): `resources/views/invoices/default.blade.php`

### PDF delivery

- [Upload handling](https://github.com/samber/invoice-as-a-service/blob/master/app/Helpers/Storage.php): `app/Helpers/Storage.php`
- **S3 storage**
- **FTP server**
- **Webhook receiver**
- **Zapier hook**

### Laravel runtime

- [HTTP entry](https://github.com/samber/invoice-as-a-service/blob/master/public/index.php): `public/index.php`
- [App bootstrap](https://github.com/samber/invoice-as-a-service/blob/master/bootstrap/app.php): `bootstrap/app.php`
- [HTTP kernel](https://github.com/samber/invoice-as-a-service/blob/master/app/Http/Kernel.php): `app/Http/Kernel.php`
- [Route provider](https://github.com/samber/invoice-as-a-service/blob/master/app/Providers/RouteServiceProvider.php): `app/Providers/RouteServiceProvider.php`

### Other components

- **API client**

## Connections

- API client → HTTP entry: sends request
- HTTP entry → App bootstrap: loads app (evidence: `public/index.php`)
- App bootstrap → HTTP kernel: binds kernel (evidence: `bootstrap/app.php`)
- HTTP kernel → Route provider: loads routing
- Route provider → API routes: registers API (evidence: `app/Providers/RouteServiceProvider.php`)
- API routes → Invoice endpoint: routes request (evidence: `routes/api.php`)
- Invoice endpoint → Custom validation: validates fields (evidence: `app/Http/Controllers/InvoiceController.php`)
- Invoice endpoint → PDF builder: builds PDF (evidence: `app/Http/Controllers/InvoiceController.php`)
- PDF builder → Invoice template: renders template
- Invoice endpoint → Upload handling: uploads PDF (evidence: `app/Http/Controllers/InvoiceController.php`)
- Upload handling → S3 storage: uploads PDF
- Upload handling → FTP server: uploads PDF
- Upload handling → Webhook receiver: posts PDF
- Upload handling → Zapier hook: posts PDF
- Invoice endpoint → API client: returns PDF or status (evidence: `app/Http/Controllers/InvoiceController.php`)
