# thefpiasta/buisnesspdf architecture

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

- Interactive diagram: https://gitdiagram.com/thefpiasta/buisnesspdf
- Repository: https://github.com/thefpiasta/buisnesspdf

## Overview

SimpleInvoice is a Go HTTP API that turns JSON requests into PDF documents. Clients POST invoice, delivery-note, or table-attachment data; the server selects a document handler, which generates a PDF and writes it to the response. Invoice and delivery-note generation use DIN 5008 A layout helpers, backed by a reusable PDF-generation layer. The README documents invoice and delivery-note endpoints; the sampled server also registers table attachments. Some handler internals are excerpted only partially, so unshown relationships are omitted.

Main entry points: [`generator/core.go`](https://github.com/thefpiasta/buisnesspdf/blob/develop/generator/core.go) (PDF generator), [`main.go`](https://github.com/thefpiasta/buisnesspdf/blob/develop/main.go) (HTTP server), [`norms/letter/din-5008-a/template.go`](https://github.com/thefpiasta/buisnesspdf/blob/develop/norms/letter/din-5008-a/template.go) (DIN 5008 layout), [`pdfType/pdfInvoice.go`](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfInvoice.go) (Invoice handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP service"]
  node_server["HTTP server<br/>[main.go]"]
end

subgraph group_documents["Document generation"]
  node_invoice["Invoice handler<br/>[pdfInvoice.go]"]
  node_delivery["Delivery handler<br/>[pdfDeliveryNode.go]"]
  node_attachment["Table attachment<br/>[tableAttachment.go]"]
  node_pdfcontract["PDF handler contract<br/>[def.go]"]
  node_invoiceinput["Invoice request data<br/>[pdfInvoice.go]"]
  node_deliveryinput["Delivery request data<br/>[pdfDeliveryNode.go]"]
  node_attachmentinput["Attachment request data<br/>[tableAttachment.go]"]
end

subgraph group_layout["DIN layout"]
  node_dinlayout["DIN 5008 layout<br/>[template.go]"]
  node_dinconstants["DIN layout constants<br/>[def.go]"]
  node_a4size["DIN A4 dimensions<br/>[def.go]"]
end

subgraph group_engine["PDF engine"]
  node_generator["PDF generator<br/>[core.go]"]
  node_generatorapi["Generator interface<br/>[def.go]"]
  node_generatormutators["PDF state controls<br/>[mutators.go]"]
end

node_client(("API client"))
node_gofpdf["gofpdf library"]
node_imagecdn["Remote image host"]
node_pdfresponse["PDF response"]

node_client -->|"POSTs JSON"| node_server
node_server -->|"routes invoice"| node_invoice
node_server -->|"routes delivery"| node_delivery
node_server -->|"routes attachment"| node_attachment
node_server -->|"dispatches handler"| node_pdfcontract
node_invoice -.->|"decodes request"| node_invoiceinput
node_delivery -.->|"decodes request"| node_deliveryinput
node_attachment -->|"decodes request"| node_attachmentinput
node_invoice -->|"creates PDF"| node_generator
node_delivery -->|"creates PDF"| node_generator
node_attachment -->|"creates PDF"| node_generator
node_invoice -->|"uses layout"| node_dinlayout
node_delivery -->|"uses layout"| node_dinlayout
node_attachment -->|"uses layout"| node_dinlayout
node_dinlayout -->|"draws page elements"| node_generator
node_dinconstants -->|"uses dimensions"| node_a4size
node_dinlayout -.->|"uses measurements"| node_dinconstants
node_generator -->|"wraps PDF engine"| node_gofpdf
node_generator -->|"fetches images"| node_imagecdn
node_generator -.->|"implements API"| node_generatorapi
node_generator -.->|"shares PDF state"| node_generatormutators
node_server -->|"writes PDF"| node_pdfresponse

click node_server "https://github.com/thefpiasta/buisnesspdf/blob/develop/main.go"
click node_invoice "https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfInvoice.go"
click node_delivery "https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfDeliveryNode.go"
click node_attachment "https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/tableAttachment.go"
click node_pdfcontract "https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/def.go"
click node_invoiceinput "https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfInvoice.go"
click node_deliveryinput "https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfDeliveryNode.go"
click node_attachmentinput "https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/tableAttachment.go"
click node_dinlayout "https://github.com/thefpiasta/buisnesspdf/blob/develop/norms/letter/din-5008-a/template.go"
click node_dinconstants "https://github.com/thefpiasta/buisnesspdf/blob/develop/norms/letter/din-5008-a/def.go"
click node_a4size "https://github.com/thefpiasta/buisnesspdf/blob/develop/norms/paperSize/din-a4/def.go"
click node_generator "https://github.com/thefpiasta/buisnesspdf/blob/develop/generator/core.go"
click node_generatorapi "https://github.com/thefpiasta/buisnesspdf/blob/develop/generator/def.go"
click node_generatormutators "https://github.com/thefpiasta/buisnesspdf/blob/develop/generator/mutators.go"

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_server,node_client toneBlue
class node_invoice,node_delivery,node_attachment,node_pdfcontract,node_invoiceinput,node_deliveryinput,node_attachmentinput toneAmber
class node_dinlayout,node_dinconstants,node_a4size toneMint
class node_generator,node_generatorapi,node_generatormutators toneRose
class node_gofpdf,node_imagecdn,node_pdfresponse toneIndigo
```

## Components

### HTTP service

- [HTTP server](https://github.com/thefpiasta/buisnesspdf/blob/develop/main.go): `main.go`

### Document generation

- [Invoice handler](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfInvoice.go): `pdfType/pdfInvoice.go`
- [Delivery handler](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfDeliveryNode.go): `pdfType/pdfDeliveryNode.go`
- [Table attachment](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/tableAttachment.go): `pdfType/tableAttachment.go`
- [PDF handler contract](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/def.go): `pdfType/def.go`
- [Invoice request data](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfInvoice.go): `pdfType/pdfInvoice.go`
- [Delivery request data](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/pdfDeliveryNode.go): `pdfType/pdfDeliveryNode.go`
- [Attachment request data](https://github.com/thefpiasta/buisnesspdf/blob/develop/pdfType/tableAttachment.go): `pdfType/tableAttachment.go`

### DIN layout

- [DIN 5008 layout](https://github.com/thefpiasta/buisnesspdf/blob/develop/norms/letter/din-5008-a/template.go): `norms/letter/din-5008-a/template.go`
- [DIN layout constants](https://github.com/thefpiasta/buisnesspdf/blob/develop/norms/letter/din-5008-a/def.go): `norms/letter/din-5008-a/def.go`
- [DIN A4 dimensions](https://github.com/thefpiasta/buisnesspdf/blob/develop/norms/paperSize/din-a4/def.go): `norms/paperSize/din-a4/def.go`

### PDF engine

- [PDF generator](https://github.com/thefpiasta/buisnesspdf/blob/develop/generator/core.go): `generator/core.go`
- [Generator interface](https://github.com/thefpiasta/buisnesspdf/blob/develop/generator/def.go): `generator/def.go`
- [PDF state controls](https://github.com/thefpiasta/buisnesspdf/blob/develop/generator/mutators.go): `generator/mutators.go`

### Other components

- **API client**
- **gofpdf library**
- **Remote image host**
- **PDF response**

## Connections

- API client → HTTP server: POSTs JSON (evidence: `README.md`)
- HTTP server → Invoice handler: routes invoice (evidence: `main.go`)
- HTTP server → Delivery handler: routes delivery (evidence: `main.go`)
- HTTP server → Table attachment: routes attachment (evidence: `main.go`)
- HTTP server → PDF handler contract: dispatches handler (evidence: `main.go`)
- Invoice handler → Invoice request data: decodes request (evidence: `pdfType/pdfInvoice.go`)
- Delivery handler → Delivery request data: decodes request (evidence: `pdfType/pdfDeliveryNode.go`)
- Table attachment → Attachment request data: decodes request (evidence: `pdfType/tableAttachment.go`)
- Invoice handler → PDF generator: creates PDF (evidence: `pdfType/pdfInvoice.go`)
- Delivery handler → PDF generator: creates PDF (evidence: `pdfType/pdfDeliveryNode.go`)
- Table attachment → PDF generator: creates PDF (evidence: `pdfType/tableAttachment.go`)
- Invoice handler → DIN 5008 layout: uses layout (evidence: `pdfType/pdfInvoice.go`)
- Delivery handler → DIN 5008 layout: uses layout (evidence: `pdfType/pdfDeliveryNode.go`)
- Table attachment → DIN 5008 layout: uses layout (evidence: `pdfType/tableAttachment.go`)
- DIN 5008 layout → PDF generator: draws page elements (evidence: `norms/letter/din-5008-a/template.go`)
- DIN layout constants → DIN A4 dimensions: uses dimensions (evidence: `norms/letter/din-5008-a/def.go`)
- DIN 5008 layout → DIN layout constants: uses measurements
- PDF generator → gofpdf library: wraps PDF engine
- PDF generator → Remote image host: fetches images (evidence: `generator/core.go`)
- PDF generator → Generator interface: implements API
- PDF generator → PDF state controls: shares PDF state
- HTTP server → PDF response: writes PDF (evidence: `main.go`)
