# yorchavez9/demo-sunat-html architecture

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

- Interactive diagram: https://gitdiagram.com/yorchavez9/demo-sunat-html
- Repository: https://github.com/yorchavez9/demo-sunat-html

## Overview

This is a browser-based Spanish-language electronic invoicing and small-business management SPA. Users register and configure SUNAT credentials, maintain a product and contact catalog, then issue invoices, receipts, credit/debit notes, or dispatch guides; they can also review summaries, cancellations, and inventory. The README documents local browser storage, SUNAT API connectivity, optional identity lookup, and JSON backup/restore. The graph preserves those capabilities; some page-to-service links are documented at product level rather than verified from sampled page code.

Main entry points: [`js/store/db.js`](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/store/db.js) (Local data layer), [`js/api.js`](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/api.js) (SUNAT API client), [`js/pages/comprobanteVenta.js`](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/comprobanteVenta.js) (Invoices and receipts), [`js/app.js`](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/app.js) (SPA shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application shell"]
  node_app["SPA shell<br/>[app.js]"]
  node_router["Hash router<br/>[router.js]"]
end

subgraph group_documents["Electronic documents"]
  node_sales["Invoices and receipts"]
  node_notes["Credit and debit notes<br/>[notaComprobante.js]"]
  node_dispatch["Dispatch guides"]
  node_summaries["Daily summaries<br/>[summaries.js]"]
  node_cancellations["Cancellations<br/>[anulaciones.js]"]
  node_documentlist["Document queries<br/>[documentList.js]"]
end

subgraph group_business["Business management"]
  node_purchases["Purchases<br/>[compras.js]"]
  node_inventory["Inventory<br/>[inventario.js]"]
  node_products["Products<br/>[productos.js]"]
  node_categories["Categories<br/>[categorias.js]"]
  node_contacts["Clients and suppliers<br/>[contactos.js]"]
  node_dashboard["Dashboard<br/>[dashboard.js]"]
  node_settings["Settings and backup<br/>[settings.js]"]
end

subgraph group_shared["Shared domain UI"]
  node_items["Invoice item totals<br/>[itemsTable.js]"]
  node_sunatui["SUNAT fields<br/>[sunat.js]"]
  node_clientpicker["Client selection<br/>[clientPicker.js]"]
  node_clientselector["Document lookup input<br/>[clientSelector.js]"]
  node_productpicker["Product selection<br/>[productPicker.js]"]
end

subgraph group_services["Data and integrations"]
  node_database["Local data layer<br/>[db.js]"]
  node_browserstore[("Browser localStorage")]
  node_api["SUNAT API client<br/>[api.js]"]
  node_identity["RUC/DNI lookup services"]
end

node_user(("Business user"))

node_user -->|"uses"| node_app
node_app -->|"creates"| node_router
node_user -->|"issues documents"| node_sales
node_user -->|"creates notes"| node_notes
node_user -->|"creates guides"| node_dispatch
node_user -->|"reviews summaries"| node_summaries
node_user -->|"manages cancellations"| node_cancellations
node_user -->|"queries documents"| node_documentlist
node_user -->|"records purchases"| node_purchases
node_user -->|"reviews stock"| node_inventory
node_user -->|"manages products"| node_products
node_user -->|"manages categories"| node_categories
node_user -->|"manages contacts"| node_contacts
node_user -->|"views overview"| node_dashboard
node_user -->|"configures system"| node_settings
node_sales -->|"binds item table"| node_items
node_sales -->|"opens picker"| node_productpicker
node_sales -->|"uses document fields"| node_sunatui
node_dispatch -->|"submits guide"| node_api
node_clientpicker -->|"looks up document"| node_api
node_clientselector -->|"looks up document"| node_api
node_api -->|"queries identity"| node_identity
node_sales -->|"sends comprobante"| node_api
node_notes -->|"sends notes"| node_api
node_database -->|"persists data"| node_browserstore
node_settings -->|"backs up data"| node_database
node_purchases -->|"updates business data"| node_database
node_inventory -->|"reads stock"| node_database
node_products -->|"manages catalog"| node_database
node_contacts -->|"manages contacts"| node_database

click node_app "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/app.js"
click node_router "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/router.js"
click node_sales "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/comprobanteVenta.js"
click node_notes "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/notaComprobante.js"
click node_dispatch "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/newDispatchGuide.js"
click node_summaries "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/summaries.js"
click node_cancellations "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/anulaciones.js"
click node_documentlist "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/documentList.js"
click node_purchases "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/compras.js"
click node_inventory "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/inventario.js"
click node_products "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/productos.js"
click node_categories "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/categorias.js"
click node_contacts "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/contactos.js"
click node_dashboard "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/dashboard.js"
click node_settings "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/settings.js"
click node_items "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/itemsTable.js"
click node_sunatui "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/sunat.js"
click node_clientpicker "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/clientPicker.js"
click node_clientselector "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/clientSelector.js"
click node_productpicker "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/productPicker.js"
click node_database "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/store/db.js"
click node_api "https://github.com/yorchavez9/demo-sunat-html/blob/main/js/api.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_app,node_router,node_user toneBlue
class node_sales,node_notes,node_dispatch,node_summaries,node_cancellations,node_documentlist toneAmber
class node_purchases,node_inventory,node_products,node_categories,node_contacts,node_dashboard,node_settings toneMint
class node_items,node_sunatui,node_clientpicker,node_clientselector,node_productpicker toneRose
class node_database,node_browserstore,node_api,node_identity toneIndigo
```

## Components

### Application shell

- [SPA shell](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/app.js): `js/app.js`
- [Hash router](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/router.js): `js/router.js`

### Electronic documents

- [Invoices and receipts](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/comprobanteVenta.js): `js/pages/comprobanteVenta.js`
- [Credit and debit notes](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/notaComprobante.js): `js/pages/notaComprobante.js`
- [Dispatch guides](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/newDispatchGuide.js): `js/pages/newDispatchGuide.js`
- [Daily summaries](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/summaries.js): `js/pages/summaries.js`
- [Cancellations](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/anulaciones.js): `js/pages/anulaciones.js`
- [Document queries](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/documentList.js): `js/pages/documentList.js`

### Business management

- [Purchases](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/compras.js): `js/pages/compras.js`
- [Inventory](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/inventario.js): `js/pages/inventario.js`
- [Products](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/productos.js): `js/pages/productos.js`
- [Categories](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/categorias.js): `js/pages/categorias.js`
- [Clients and suppliers](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/contactos.js): `js/pages/contactos.js`
- [Dashboard](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/dashboard.js): `js/pages/dashboard.js`
- [Settings and backup](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/pages/settings.js): `js/pages/settings.js`

### Shared domain UI

- [Invoice item totals](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/itemsTable.js): `js/components/itemsTable.js`
- [SUNAT fields](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/sunat.js): `js/components/sunat.js`
- [Client selection](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/clientPicker.js): `js/components/clientPicker.js`
- [Document lookup input](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/clientSelector.js): `js/components/clientSelector.js`
- [Product selection](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/components/productPicker.js): `js/components/productPicker.js`

### Data and integrations

- [Local data layer](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/store/db.js): `js/store/db.js`
- **Browser localStorage**
- [SUNAT API client](https://github.com/yorchavez9/demo-sunat-html/blob/main/js/api.js): `js/api.js`
- **RUC/DNI lookup services**

### Other components

- **Business user**

## Connections

- Business user → SPA shell: uses (evidence: `README.md`)
- SPA shell → Hash router: creates (evidence: `js/app.js`)
- Business user → Invoices and receipts: issues documents (evidence: `README.md`)
- Business user → Credit and debit notes: creates notes (evidence: `README.md`)
- Business user → Dispatch guides: creates guides (evidence: `README.md`)
- Business user → Daily summaries: reviews summaries (evidence: `README.md`)
- Business user → Cancellations: manages cancellations (evidence: `README.md`)
- Business user → Document queries: queries documents (evidence: `README.md`)
- Business user → Purchases: records purchases (evidence: `README.md`)
- Business user → Inventory: reviews stock (evidence: `README.md`)
- Business user → Products: manages products (evidence: `README.md`)
- Business user → Categories: manages categories (evidence: `README.md`)
- Business user → Clients and suppliers: manages contacts (evidence: `README.md`)
- Business user → Dashboard: views overview (evidence: `README.md`)
- Business user → Settings and backup: configures system (evidence: `README.md`)
- Invoices and receipts → Invoice item totals: binds item table (evidence: `js/pages/comprobanteVenta.js`)
- Invoices and receipts → Product selection: opens picker (evidence: `js/pages/comprobanteVenta.js`)
- Invoices and receipts → SUNAT fields: uses document fields (evidence: `README.md`)
- Dispatch guides → SUNAT API client: submits guide (evidence: `js/pages/newDispatchGuide.js`)
- Client selection → SUNAT API client: looks up document (evidence: `js/components/clientPicker.js`)
- Document lookup input → SUNAT API client: looks up document (evidence: `js/components/clientSelector.js`)
- SUNAT API client → RUC/DNI lookup services: queries identity (evidence: `README.md`)
- Invoices and receipts → SUNAT API client: sends comprobante (evidence: `README.md`)
- Credit and debit notes → SUNAT API client: sends notes (evidence: `README.md`)
- Local data layer → Browser localStorage: persists data (evidence: `README.md`)
- Settings and backup → Local data layer: backs up data (evidence: `README.md`)
- Purchases → Local data layer: updates business data (evidence: `README.md`)
- Inventory → Local data layer: reads stock (evidence: `README.md`)
- Products → Local data layer: manages catalog (evidence: `README.md`)
- Clients and suppliers → Local data layer: manages contacts (evidence: `README.md`)
