# tips-sa/facturacionelectronicapy-recibo-xmlgen architecture

> Architecture diagram of the GitHub repository tips-sa/facturacionelectronicapy-recibo-xmlgen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tips-sa/facturacionelectronicapy-recibo-xmlgen
- Repository: https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen

## Overview

##### Project type and purpose
- This is a Node.js library (an open-source tool) whose sole responsibility is to generate the XML “Recibo” file compliant with Paraguay’s SIFEN (SET) schema.
- It consumes a JSON data structure and produces a validated, standards-compliant XML payload to be sent later to the SET endpoint.

##### File structure
- Top-level:
- package.json, tsconfig.json, tslint.json – Node/TypeScript config and dependencies
- src/index.ts – library entry point
- src/services/… – collection of cohesive service modules, each encapsulating a logical piece of the XML generation process
- src/services/type.interface.ts – shared TypeScript interfaces for the JSON input structure
- The “services” folder shows a clear separation of concerns: utilities (FechaUtil, StringUtil, constants), JSON validation and transformation (JsonReciboValidate, JsonReciboDocumentoAsociado), XML-specific algorithms and assembly (reciboXmlAlgoritmos, reciboXmlTotales), and the orchestration layer (reciboXmlMain).

##### README for additional insights
- Describes the module’s purpose: XML generation from JSON for SIFEN
- Mentions companion packages for signing, QR generation, and API interaction, indicating that this is one component in a larger suite

##### Final advice
- Don’t group all services into one blob—each service is a separable component

## Diagram (Mermaid)

```mermaid
flowchart TD
    Consumer["Consumer / Application"]:::client
    Entry["src/index.ts\n(Index Entry Point)"]:::service
    Validate["JsonReciboValidate\n(Validation Layer)"]:::service
    Transform["JsonReciboDocumentoAsociado\n(Transformation Layer)"]:::service
    subgraph Utilities
        UtilDate["FechaUtil"]:::utility
        UtilString["StringUtil"]:::utility
        UtilConst["constants"]:::utility
    end
    Alg["reciboXmlAlgoritmos\n(XML Algorithms)"]:::service
    Totals["reciboXmlTotales\n(XML Totals)"]:::service
    Orchestrator["reciboXmlMain\n(Orchestrator)"]:::orchestrator
    SharedTypes["type.interface.ts\n(Shared Interfaces)"]:::types
    Output["Serialized XML Output"]:::output
    Companion["Companion Modules\n(xmlsign, qrgen, setapi)"]:::external

    Consumer -->|"calls generateRecibo(json)"| Entry
    Entry -->|"validateRecibo(json): boolean"| Validate
    Validate -->|"jsonValid"| Transform
    Transform -->|"normalizedJson"| Orchestrator
    Orchestrator -->|"use FechaUtil"| UtilDate
    Orchestrator -->|"use StringUtil"| UtilString
    Orchestrator -->|"use constants"| UtilConst
    Orchestrator -->|"build fragments"| Alg
    Orchestrator -->|"calculate totals"| Totals
    Alg -->|"fragmentXML"| Orchestrator
    Totals -->|"totalesXML"| Orchestrator
    Orchestrator -->|"finalXML"| Output
    Output -->|"pass to"| Companion

    Validate -.->|"uses types"| SharedTypes
    Transform -.->|"uses types"| SharedTypes
    Orchestrator -.->|"uses types"| SharedTypes
    Alg -.->|"uses types"| SharedTypes
    Totals -.->|"uses types"| SharedTypes

    click Entry "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/index.ts"
    click Validate "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/JsonReciboValidate.service.ts"
    click Transform "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/JsonReciboDocumentoAsociado.service.ts"
    click UtilDate "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/FechaUtil.service.ts"
    click UtilString "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/StringUtil.service.ts"
    click UtilConst "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/constants.service.ts"
    click Alg "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/reciboXmlAlgoritmos.service.ts"
    click Totals "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/reciboXmlTotales.service.ts"
    click Orchestrator "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/reciboXmlMain.service.ts"
    click SharedTypes "https://github.com/tips-sa/facturacionelectronicapy-recibo-xmlgen/blob/main/src/services/type.interface..ts"

    classDef client fill:#d0e0e3,stroke:#333,stroke-width:1px;
    classDef service fill:#cfe2f3,stroke:#333,stroke-width:1px;
    classDef orchestrator fill:#d9ead3,stroke:#333,stroke-width:1px;
    classDef utility fill:#fff2cc,stroke:#333,stroke-width:1px;
    classDef types fill:#ececec,stroke:#333,stroke-width:1px;
    classDef output fill:#d9d2e9,stroke:#333,stroke-width:1px;
    classDef external fill:#f4cccc,stroke:#333,stroke-width:1px;
```
