# dhanesh10war/invoice-app architecture

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

- Interactive diagram: https://gitdiagram.com/dhanesh10war/invoice-app
- Repository: https://github.com/dhanesh10war/invoice-app

## Overview

JCI Receipt WhatsApp Tool is a web app for creating and sending cash receipts. An administrator opens the dashboard, connects a WhatsApp account by QR, enters receipt details, then generates a receipt that is saved and sent to recipients. The backend also supports receipt history, contacts, preview, deletion, SVG viewing and PDF output. Source excerpts show the API orchestration and core services; some frontend and route details are incomplete, so omitted relationships are not inferred.

Main entry points: [`src/whatsapp.js`](https://github.com/dhanesh10war/invoice-app/blob/main/src/whatsapp.js) (WhatsApp session and delivery), [`src/routes.js`](https://github.com/dhanesh10war/invoice-app/blob/main/src/routes.js) (API and receipt routes), [`client/src/App.jsx`](https://github.com/dhanesh10war/invoice-app/blob/main/client/src/App.jsx) (Receipt dashboard), [`server.js`](https://github.com/dhanesh10war/invoice-app/blob/main/server.js) (HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Dashboard"]
  node_dashboard["Receipt dashboard<br/>[App.jsx]"]
end

subgraph group_api["Receipt API"]
  node_http["HTTP server<br/>[server.js]"]
  node_routes["API and receipt routes<br/>[routes.js]"]
end

subgraph group_services["Core Services"]
  node_receipt["Receipt validation and SVG<br/>[receipt.js]"]
  node_pdf["PDF conversion<br/>[pdf.js]"]
  node_whatsapp["WhatsApp session and delivery<br/>[whatsapp.js]"]
end

subgraph group_persistence["Persistent Data"]
  node_sqlite[("Receipt and contact database<br/>[db.js]")]
  node_receiptfiles["Generated receipt files<br/>[routes.js]"]
  node_authfiles["WhatsApp credentials<br/>[whatsapp.js]"]
end

node_admin(("Administrator"))
node_baileys["WhatsApp Web"]
node_cloudapi["WhatsApp Cloud API"]
node_recipients(("Receipt recipients"))

node_admin -->|"uses"| node_dashboard
node_dashboard -->|"requests APIs"| node_http
node_http -->|"mounts routes"| node_routes
node_routes -->|"checks session"| node_whatsapp
node_routes -->|"validates and builds"| node_receipt
node_routes -->|"converts SVG"| node_pdf
node_routes -->|"reads and writes"| node_sqlite
node_routes -->|"writes and serves"| node_receiptfiles
node_receipt -->|"normalizes phones"| node_whatsapp
node_whatsapp -->|"connects and sends"| node_baileys
node_whatsapp -->|"persists credentials"| node_authfiles
node_whatsapp -.->|"fallback delivery"| node_cloudapi
node_whatsapp -->|"sends receipts"| node_recipients
node_admin -->|"scans login QR"| node_whatsapp

click node_dashboard "https://github.com/dhanesh10war/invoice-app/blob/main/client/src/App.jsx"
click node_http "https://github.com/dhanesh10war/invoice-app/blob/main/server.js"
click node_routes "https://github.com/dhanesh10war/invoice-app/blob/main/src/routes.js"
click node_receipt "https://github.com/dhanesh10war/invoice-app/blob/main/src/services/receipt.js"
click node_pdf "https://github.com/dhanesh10war/invoice-app/blob/main/src/services/pdf.js"
click node_whatsapp "https://github.com/dhanesh10war/invoice-app/blob/main/src/whatsapp.js"
click node_sqlite "https://github.com/dhanesh10war/invoice-app/blob/main/src/db.js"
click node_receiptfiles "https://github.com/dhanesh10war/invoice-app/blob/main/src/routes.js"
click node_authfiles "https://github.com/dhanesh10war/invoice-app/blob/main/src/whatsapp.js"

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_dashboard toneBlue
class node_http,node_routes toneAmber
class node_receipt,node_pdf,node_whatsapp,node_cloudapi toneMint
class node_sqlite,node_receiptfiles,node_authfiles toneRose
class node_admin,node_baileys,node_recipients toneIndigo
```

## Components

### Dashboard

- [Receipt dashboard](https://github.com/dhanesh10war/invoice-app/blob/main/client/src/App.jsx): `client/src/App.jsx`

### Receipt API

- [HTTP server](https://github.com/dhanesh10war/invoice-app/blob/main/server.js): `server.js`
- [API and receipt routes](https://github.com/dhanesh10war/invoice-app/blob/main/src/routes.js): `src/routes.js`

### Core Services

- [Receipt validation and SVG](https://github.com/dhanesh10war/invoice-app/blob/main/src/services/receipt.js): `src/services/receipt.js`
- [PDF conversion](https://github.com/dhanesh10war/invoice-app/blob/main/src/services/pdf.js): `src/services/pdf.js`
- [WhatsApp session and delivery](https://github.com/dhanesh10war/invoice-app/blob/main/src/whatsapp.js): `src/whatsapp.js`

### Persistent Data

- [Receipt and contact database](https://github.com/dhanesh10war/invoice-app/blob/main/src/db.js): `src/db.js`
- [Generated receipt files](https://github.com/dhanesh10war/invoice-app/blob/main/src/routes.js): `src/routes.js`
- [WhatsApp credentials](https://github.com/dhanesh10war/invoice-app/blob/main/src/whatsapp.js): `src/whatsapp.js`

### Other components

- **Administrator**
- **WhatsApp Web**
- **WhatsApp Cloud API**
- **Receipt recipients**

## Connections

- Administrator → Receipt dashboard: uses (evidence: `README.md`)
- Receipt dashboard → HTTP server: requests APIs (evidence: `client/src/App.jsx`)
- HTTP server → API and receipt routes: mounts routes (evidence: `server.js`)
- API and receipt routes → WhatsApp session and delivery: checks session (evidence: `src/routes.js`)
- API and receipt routes → Receipt validation and SVG: validates and builds (evidence: `src/routes.js`)
- API and receipt routes → PDF conversion: converts SVG (evidence: `src/routes.js`)
- API and receipt routes → Receipt and contact database: reads and writes (evidence: `src/routes.js`)
- API and receipt routes → Generated receipt files: writes and serves (evidence: `src/routes.js`)
- Receipt validation and SVG → WhatsApp session and delivery: normalizes phones (evidence: `src/services/receipt.js`)
- WhatsApp session and delivery → WhatsApp Web: connects and sends (evidence: `src/whatsapp.js`)
- WhatsApp session and delivery → WhatsApp credentials: persists credentials (evidence: `src/whatsapp.js`)
- WhatsApp session and delivery → WhatsApp Cloud API: fallback delivery (evidence: `src/whatsapp.js`)
- WhatsApp session and delivery → Receipt recipients: sends receipts (evidence: `README.md`)
- Administrator → WhatsApp session and delivery: scans login QR (evidence: `README.md`)
