# bevia/printingreceipt architecture

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

- Interactive diagram: https://gitdiagram.com/bevia/printingreceipt
- Repository: https://github.com/bevia/printingreceipt

## Overview

##### Project type and purpose
- This is a Java-based JSON mapping utility/library. It ingests a JSON payload (e.g., from a REST API), parses out receipt/payment/order details, maps them into a HashMap (or domain objects), and then forwards the structured data for display or further processing (e.g., in an Android TextView or console).

##### File structure
- Top-level files: Gradle build scripts (`build.gradle.kts`, `settings.gradle.kts`), IDE config.
- `src/main/java/org/example/JSONExtractor.java` & `JSONExtractorWithRelatedTx.java`: classes that extract fields.
- `src/main/java/org/example/JSONMapper.java`: orchestrates parsing + mapping.
- `src/main/java/receipt/`: domain-model package containing `Data`, `Merchant`, `Order`, `Payment`, `PaymentDetails`, `RelatedTransaction`, plus helper classes (`JSONParser`, `JsonResponse`, `JsonUtils`, `ReceiptPrinter`).

##### README for additional insights
- Core flow: receive raw JSON → parse safely (handle missing/null) → extract specific keys (transaction IDs, merchant info, payment details) → store values in `HashMap` → print to console or hand off to UI.
- Dependencies: `org.json:json`.

- Use clear labels for each component (e.g., “JSONParser”, “Data Model”)

## Diagram (Mermaid)

```mermaid
flowchart TB
    A["JSON Source"]:::external

    subgraph "Parsing & Utilities"
        P1["JSONParser"]:::parsing
        P2["JsonUtils"]:::parsing
    end

    subgraph "Data Model"
        DM1["JsonResponse"]:::domain
        DM2["Data"]:::domain
        DM3["Merchant"]:::domain
        DM4["Order"]:::domain
        DM5["Payment"]:::domain
        DM6["PaymentDetails"]:::domain
        DM7["RelatedTransaction"]:::domain
    end

    subgraph "Extraction Layer"
        E1["JSONExtractor"]:::extract
        E2["JSONExtractorWithRelatedTx"]:::extract
    end

    M["JSONMapper"]:::extract
    R["ReceiptPrinter"]:::presentation

    A --> P1
    P1 --> P2
    P1 --> DM1
    DM1 --> DM2
    DM2 --> DM3
    DM2 --> DM4
    DM2 --> DM5
    DM5 --> DM6
    DM2 --> DM7
    DM1 --> E1
    DM1 --> E2
    E1 --> M
    E2 --> M
    M --> R

    click P1 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/JSONParser.java"
    click P2 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/JsonUtils.java"
    click DM1 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/JsonResponse.java"
    click DM2 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/Data.java"
    click DM3 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/Merchant.java"
    click DM4 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/Order.java"
    click DM5 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/Payment.java"
    click DM6 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/PaymentDetails.java"
    click DM7 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/RelatedTransaction.java"
    click E1 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/org/example/JSONExtractor.java"
    click E2 "https://github.com/bevia/printingreceipt/blob/main/src/main/java/org/example/JSONExtractorWithRelatedTx.java"
    click M "https://github.com/bevia/printingreceipt/blob/main/src/main/java/org/example/JSONMapper.java"
    click R "https://github.com/bevia/printingreceipt/blob/main/src/main/java/receipt/ReceiptPrinter.java"

    classDef parsing fill:#ADD8E6,stroke:#000
    classDef domain fill:#90EE90,stroke:#000
    classDef extract fill:#FFA500,stroke:#000
    classDef presentation fill:#DDA0DD,stroke:#000
    classDef external fill:#D3D3D3,stroke:#000
```
