# juan804041/sifen architecture

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

- Interactive diagram: https://gitdiagram.com/juan804041/sifen
- Repository: https://github.com/juan804041/sifen

## Overview

This is a PHP class for generating and submitting Paraguayan SIFEN electronic invoices. The documented workflow accepts invoice data as JSON, generates and signs XML with `generar_xml()`, submits it with `enviar_xml()`, and saves the server response. The graph separates invoice construction, signing/QR support, and submission/response handling. The README documents the end-to-end workflow; sampled source confirms XML calculations, signing-related code, and QR generation via the barcode library. Some internal call sequence is not visible in the excerpts.

Main entry points: [`sifen.php`](https://github.com/juan804041/sifen/blob/main/sifen.php) (XML generation), [`lib/barcode-master/barcode.php`](https://github.com/juan804041/sifen/blob/main/lib/barcode-master/barcode.php) (Barcode generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_invoice["Invoice generation"]
  node_generation["XML generation<br/>[sifen.php]"]
  node_calculations["Invoice calculations<br/>[sifen.php]"]
end

subgraph group_document["Document signing"]
  node_signing["XML signing<br/>[sifen.php]"]
  node_qr["QR generation<br/>[sifen.php]"]
  node_barcode["Barcode generator<br/>[barcode.php]"]
end

subgraph group_submission["Submission and results"]
  node_submission["SIFEN submission<br/>[sifen.php]"]
  node_response["Response storage<br/>[sifen.php]"]
end

node_user(("Integrating application"))
node_sifen{{"SIFEN service"}}

node_user -->|"provides JSON"| node_generation
node_generation -->|"calculates totals"| node_calculations
node_generation -->|"returns signed XML"| node_signing
node_signing -->|"generates QR"| node_qr
node_qr -->|"renders image"| node_barcode
node_user -->|"submits document ID"| node_submission
node_submission -->|"sends document"| node_sifen
node_sifen -->|"returns response"| node_response

click node_generation "https://github.com/juan804041/sifen/blob/main/sifen.php"
click node_calculations "https://github.com/juan804041/sifen/blob/main/sifen.php"
click node_signing "https://github.com/juan804041/sifen/blob/main/sifen.php"
click node_qr "https://github.com/juan804041/sifen/blob/main/sifen.php"
click node_barcode "https://github.com/juan804041/sifen/blob/main/lib/barcode-master/barcode.php"
click node_submission "https://github.com/juan804041/sifen/blob/main/sifen.php"
click node_response "https://github.com/juan804041/sifen/blob/main/sifen.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_generation,node_calculations toneBlue
class node_signing,node_qr,node_barcode toneAmber
class node_submission,node_response toneMint
class node_user,node_sifen toneIndigo
```

## Components

### Invoice generation

- [XML generation](https://github.com/juan804041/sifen/blob/main/sifen.php): `sifen.php`
- [Invoice calculations](https://github.com/juan804041/sifen/blob/main/sifen.php): `sifen.php`

### Document signing

- [XML signing](https://github.com/juan804041/sifen/blob/main/sifen.php): `sifen.php`
- [QR generation](https://github.com/juan804041/sifen/blob/main/sifen.php): `sifen.php`
- [Barcode generator](https://github.com/juan804041/sifen/blob/main/lib/barcode-master/barcode.php): `lib/barcode-master/barcode.php`

### Submission and results

- [SIFEN submission](https://github.com/juan804041/sifen/blob/main/sifen.php): `sifen.php`
- [Response storage](https://github.com/juan804041/sifen/blob/main/sifen.php): `sifen.php`

### Other components

- **Integrating application**
- **SIFEN service**

## Connections

- Integrating application → XML generation: provides JSON (evidence: `README.md`)
- XML generation → Invoice calculations: calculates totals (evidence: `sifen.php`)
- XML generation → XML signing: returns signed XML (evidence: `README.md`)
- XML signing → QR generation: generates QR (evidence: `sifen.php`)
- QR generation → Barcode generator: renders image (evidence: `sifen.php`)
- Integrating application → SIFEN submission: submits document ID (evidence: `README.md`)
- SIFEN submission → SIFEN service: sends document (evidence: `README.md`)
- SIFEN service → Response storage: returns response (evidence: `README.md`)
