# leoneville/pyboleto architecture

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

- Interactive diagram: https://gitdiagram.com/leoneville/pyboleto
- Repository: https://github.com/leoneville/pyboleto

## Overview

pyboleto is a Python library for creating Brazilian bank boletos. An application creates a bank-specific boleto object, whose adapter supplies bank rules on top of shared boleto data; an HTML or PDF renderer then formats that object for output. The tree includes adapters for multiple banks and both output formats. The README content is empty, so capabilities and relationships here are based on the sampled source and SOURCE INDEX; the bank package is grouped because several adapters were not excerpted.

Main entry points: [`pyboleto/bank`](https://github.com/leoneville/pyboleto/tree/main/pyboleto/bank) (Bank adapters), [`pyboleto/html.py`](https://github.com/leoneville/pyboleto/blob/main/pyboleto/html.py) (HTML renderer), [`pyboleto/pdf.py`](https://github.com/leoneville/pyboleto/blob/main/pyboleto/pdf.py) (PDF renderer), [`pyboleto/data.py`](https://github.com/leoneville/pyboleto/blob/main/pyboleto/data.py) (Shared boleto data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bank["Bank rules"]
  node_bank_adapters["Bank adapters"]
end

subgraph group_core["Boleto data"]
  node_boleto_data["Shared boleto data<br/>[data.py]"]
end

subgraph group_render["Output rendering"]
  node_html_renderer["HTML renderer<br/>[html.py]"]
  node_pdf_renderer["PDF renderer<br/>[pdf.py]"]
  node_html_templates["HTML templates"]
end

subgraph group_examples["Usage examples"]
  node_html_example["HTML sample"]
  node_pdf_example["PDF sample"]
  node_memory_example["In-memory PDF sample"]
end

node_application(("Application code"))

node_bank_adapters -->|"inherit and extend"| node_boleto_data
node_boleto_data -->|"provides fields"| node_html_renderer
node_boleto_data -->|"provides fields"| node_pdf_renderer
node_html_renderer -->|"loads templates"| node_html_templates
node_application -->|"creates boleto"| node_bank_adapters
node_application -->|"renders HTML"| node_html_renderer
node_application -->|"renders PDF"| node_pdf_renderer
node_html_example -->|"instantiates"| node_bank_adapters
node_html_example -->|"calls renderer"| node_html_renderer
node_pdf_example -->|"instantiates"| node_bank_adapters
node_pdf_example -->|"calls renderer"| node_pdf_renderer
node_memory_example -->|"uses renderer"| node_pdf_renderer

click node_bank_adapters "https://github.com/leoneville/pyboleto/tree/main/pyboleto/bank"
click node_boleto_data "https://github.com/leoneville/pyboleto/blob/main/pyboleto/data.py"
click node_html_renderer "https://github.com/leoneville/pyboleto/blob/main/pyboleto/html.py"
click node_pdf_renderer "https://github.com/leoneville/pyboleto/blob/main/pyboleto/pdf.py"
click node_html_templates "https://github.com/leoneville/pyboleto/tree/main/pyboleto/templates"
click node_html_example "https://github.com/leoneville/pyboleto/blob/main/bin/html_pyboleto_sample.py"
click node_pdf_example "https://github.com/leoneville/pyboleto/blob/main/bin/pdf_pyboleto_sample.py"
click node_memory_example "https://github.com/leoneville/pyboleto/blob/main/bin/pdf_pyboleto_in_memory_sample.py"

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_bank_adapters toneBlue
class node_boleto_data toneAmber
class node_html_renderer,node_pdf_renderer,node_html_templates toneMint
class node_html_example,node_pdf_example,node_memory_example toneRose
class node_application toneIndigo
```

## Components

### Bank rules

- [Bank adapters](https://github.com/leoneville/pyboleto/tree/main/pyboleto/bank): `pyboleto/bank`

### Boleto data

- [Shared boleto data](https://github.com/leoneville/pyboleto/blob/main/pyboleto/data.py): `pyboleto/data.py`

### Output rendering

- [HTML renderer](https://github.com/leoneville/pyboleto/blob/main/pyboleto/html.py): `pyboleto/html.py`
- [PDF renderer](https://github.com/leoneville/pyboleto/blob/main/pyboleto/pdf.py): `pyboleto/pdf.py`
- [HTML templates](https://github.com/leoneville/pyboleto/tree/main/pyboleto/templates): `pyboleto/templates`

### Usage examples

- [HTML sample](https://github.com/leoneville/pyboleto/blob/main/bin/html_pyboleto_sample.py): `bin/html_pyboleto_sample.py`
- [PDF sample](https://github.com/leoneville/pyboleto/blob/main/bin/pdf_pyboleto_sample.py): `bin/pdf_pyboleto_sample.py`
- [In-memory PDF sample](https://github.com/leoneville/pyboleto/blob/main/bin/pdf_pyboleto_in_memory_sample.py): `bin/pdf_pyboleto_in_memory_sample.py`

### Other components

- **Application code**

## Connections

- Bank adapters → Shared boleto data: inherit and extend (evidence: `pyboleto/bank/bancodobrasil.py`)
- Shared boleto data → HTML renderer: provides fields (evidence: `pyboleto/html.py`)
- Shared boleto data → PDF renderer: provides fields (evidence: `pyboleto/pdf.py`)
- HTML renderer → HTML templates: loads templates (evidence: `pyboleto/html.py`)
- Application code → Bank adapters: creates boleto
- Application code → HTML renderer: renders HTML
- Application code → PDF renderer: renders PDF
- HTML sample → Bank adapters: instantiates (evidence: `bin/html_pyboleto_sample.py`)
- HTML sample → HTML renderer: calls renderer (evidence: `bin/html_pyboleto_sample.py`)
- PDF sample → Bank adapters: instantiates (evidence: `bin/pdf_pyboleto_sample.py`)
- PDF sample → PDF renderer: calls renderer (evidence: `bin/pdf_pyboleto_sample.py`)
- In-memory PDF sample → PDF renderer: uses renderer (evidence: `bin/pdf_pyboleto_in_memory_sample.py`)
