# smartive/swiss-qr-bill-decoder architecture

> Architecture diagram of the GitHub repository smartive/swiss-qr-bill-decoder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/smartive/swiss-qr-bill-decoder
- Repository: https://github.com/smartive/swiss-qr-bill-decoder

## Overview

→ Input File → PDF Converter (if PDF) → QR Parser → Data Models → JSON Output

→ Raw QR Data → Structured QR Data Model → Address Model

##### Important Elements

- Swiss QR Bill Specification
- PDF Processing Libraries
- QR Code Reading Libraries

- Invalid input handling
- QR code detection failures
- Parsing errors

##### Architectural Notes

- Dual nature (library/binary) with a split view
- Test coverage areas (matching the tests/ directory structure)
- Docker container boundary (based on Dockerfile presence)

##### Input Processing
- File type detection
- Args parsing
- Initial validation

##### Core Processing
- PDF to image conversion (when needed)
- QR code location and extraction
- Data parsing and validation

##### Data Modeling
- QR data structure
- Address information handling
- Specification compliance

##### Output Generation
- JSON formatting
- Error reporting

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef input fill:#a8d1f0,stroke:#000
    classDef process fill:#90EE90,stroke:#000
    classDef model fill:#FFB347,stroke:#000
    classDef external fill:#D3D3D3,stroke:#000
    classDef error fill:#FFB6C1,stroke:#000

    %% Main Components
    subgraph Input
        CLI["Command-line Interface"]:::input
        IH["Input Handler"]:::input
        FD["File Detection"]:::input
    end

    subgraph Processing
        PC["PDF Converter"]:::process
        QP["QR Code Parser"]:::process
        VAL["Validation"]:::process
    end

    subgraph Models
        QD["QR Data Model"]:::model
        AD["Address Model"]:::model
    end

    subgraph Output
        JSON["JSON Output"]:::input
    end

    subgraph "External Dependencies"
        SQR["Swiss QR Bill Spec"]:::external
        PDF["PDF Libraries"]:::external
        QRL["QR Libraries"]:::external
    end

    subgraph "Error Handling"
        IE["Input Errors"]:::error
        PE["Processing Errors"]:::error
        VE["Validation Errors"]:::error
    end

    %% Relationships
    CLI --> IH
    IH --> FD
    FD --> PC
    FD --> QP
    PC --> QP
    QP --> VAL
    VAL --> QD
    QD --> AD
    AD --> JSON

    %% Error Flows
    IH -.-> IE
    PC -.-> PE
    QP -.-> PE
    VAL -.-> VE

    %% External Dependencies
    SQR -.-> VAL
    PDF -.-> PC
    QRL -.-> QP

    %% Click Events
    click CLI "https://github.com/smartive/swiss-qr-bill-decoder/blob/main/src/main.rs"
    click IH "https://github.com/smartive/swiss-qr-bill-decoder/blob/main/src/args.rs"
    click PC "https://github.com/smartive/swiss-qr-bill-decoder/blob/main/src/pdf_converter.rs"
    click QP "https://github.com/smartive/swiss-qr-bill-decoder/blob/main/src/qr_parser.rs"
    click QD "https://github.com/smartive/swiss-qr-bill-decoder/blob/main/src/models/qr_data.rs"
    click AD "https://github.com/smartive/swiss-qr-bill-decoder/blob/main/src/models/address.rs"
    click VAL "https://github.com/smartive/swiss-qr-bill-decoder/blob/main/tests/edge_cases.rs"
    click PE "https://github.com/smartive/swiss-qr-bill-decoder/tree/main/tests/"
    click IE "https://github.com/smartive/swiss-qr-bill-decoder/tree/main/tests/data/"

    %% Legend
    subgraph Legend
        L1["Input/Output"]:::input
        L2["Processing"]:::process
        L3["Data Models"]:::model
        L4["External"]:::external
        L5["Error Handling"]:::error
    end
```
