# ahmaddaghlas55/supermarketsys architecture

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

- Interactive diagram: https://gitdiagram.com/ahmaddaghlas55/supermarketsys
- Repository: https://github.com/ahmaddaghlas55/supermarketsys

## Overview

This is a supermarket point-of-sale and back-office application: browser pages support checkout and store administration, while a Go HTTP server exposes authenticated APIs. The clearest shown workflow is checkout: staff scan and select products, assemble a cart, optionally assign a customer, then submit a sale through the API. The repository also contains distinct catalog, purchasing, cash/operations, promotions, reporting, and audit areas. Source excerpts establish only some backend wiring, so unsampled relationships are not asserted.

Main entry points: [`cmd/server/main.go`](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/cmd/server/main.go) (HTTP server), [`internal/web/frontend/js/pages/checkout.js`](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/checkout.js) (Checkout page), [`internal/web/frontend/js/core/api.js`](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/core/api.js) (API client), [`internal/web/frontend/js/pages/cash-register.js`](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/cash-register.js) (Cash register page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser app"]
  node_checkout["Checkout page<br/>[checkout.js]"]
  node_cartline["Cart line<br/>[CartLine.js]"]
  node_customerpicker["Customer picker<br/>[CustomerPicker.js]"]
  node_weightpicker["Weight picker<br/>[WeightPicker.js]"]
  node_barcode["Barcode listener<br/>[barcodeListener.js]"]
  node_api["API client<br/>[api.js]"]
  node_browserauth["Browser auth<br/>[auth.js]"]
  node_cashpage["Cash register page<br/>[cash-register.js]"]
  node_productspage["Products page<br/>[products.js]"]
end

subgraph group_http["HTTP server"]
  node_frontend["Embedded frontend<br/>[embed.go]"]
  node_server["HTTP server<br/>[main.go]"]
  node_middleware["Auth middleware<br/>[auth.go]"]
  node_authhandler["Auth handlers<br/>[auth.go]"]
  node_inventoryhandler["Inventory handlers<br/>[inventory.go]"]
  node_operationshandler["Operations handlers<br/>[operations.go]"]
  node_purchasinghandler["Purchasing handlers<br/>[purchasing.go]"]
  node_promotionhandler["Promotion handlers<br/>[promotions.go]"]
  node_reporthandler["Report handlers<br/>[reports.go]"]
  node_audithandler["Audit handlers<br/>[audit.go]"]
end

subgraph group_domain["Business services"]
  node_authservice["Authentication service<br/>[auth.go]"]
  node_catalogservice["Catalog service<br/>[catalog.go]"]
  node_operationsservice["Operations service<br/>[operations.go]"]
  node_purchasingservice["Purchasing service<br/>[purchasing.go]"]
  node_promotionservice["Promotion service<br/>[promotions.go]"]
  node_reportservice["Reporting service<br/>[reports.go]"]
  node_auditservice["Audit service<br/>[audit.go]"]
  node_models["Domain models"]
end

subgraph group_data["Persistence"]
  node_repositories["SQL repositories"]
  node_sqlite[("SQLite database")]
end

node_staff(("Staff user"))
node_admin(("Administrator"))

node_staff -->|"uses"| node_checkout
node_checkout -->|"renders"| node_cartline
node_checkout -->|"opens"| node_customerpicker
node_checkout -->|"uses"| node_weightpicker
node_checkout -->|"starts"| node_barcode
node_checkout -->|"requests"| node_api
node_productspage -->|"requests"| node_api
node_cashpage -->|"requests"| node_api
node_api -->|"reads token"| node_browserauth
node_checkout -->|"checks access"| node_browserauth
node_staff -.->|"uses"| node_cashpage
node_admin -.->|"uses"| node_productspage
node_server -->|"serves assets"| node_frontend
node_server -->|"routes auth"| node_authhandler
node_server -->|"routes catalog"| node_inventoryhandler
node_server -->|"routes operations"| node_operationshandler
node_server -->|"protects routes"| node_middleware
node_server -->|"constructs handler"| node_promotionhandler
node_authhandler -->|"calls"| node_authservice
node_server -->|"constructs"| node_authservice
node_purchasinghandler -.->|"uses"| node_purchasingservice
node_promotionhandler -.->|"uses"| node_promotionservice
node_reporthandler -.->|"uses"| node_reportservice
node_audithandler -.->|"uses"| node_auditservice
node_inventoryhandler -.->|"uses"| node_catalogservice
node_operationshandler -.->|"uses"| node_operationsservice
node_server -->|"opens"| node_sqlite
node_server -.->|"constructs repositories"| node_repositories

click node_checkout "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/checkout.js"
click node_cartline "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/components/CartLine.js"
click node_customerpicker "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/components/CustomerPicker.js"
click node_weightpicker "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/components/WeightPicker.js"
click node_barcode "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/core/barcodeListener.js"
click node_api "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/core/api.js"
click node_browserauth "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/core/auth.js"
click node_cashpage "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/cash-register.js"
click node_productspage "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/products.js"
click node_frontend "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/embed.go"
click node_server "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/cmd/server/main.go"
click node_middleware "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/middleware/auth.go"
click node_authhandler "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/auth.go"
click node_inventoryhandler "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/inventory.go"
click node_operationshandler "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/operations.go"
click node_purchasinghandler "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/purchasing.go"
click node_promotionhandler "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/promotions.go"
click node_reporthandler "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/reports.go"
click node_audithandler "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/audit.go"
click node_authservice "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/auth.go"
click node_catalogservice "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/catalog.go"
click node_operationsservice "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/operations.go"
click node_purchasingservice "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/purchasing.go"
click node_promotionservice "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/promotions.go"
click node_reportservice "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/reports.go"
click node_auditservice "https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/audit.go"
click node_models "https://github.com/ahmaddaghlas55/supermarketsys/tree/main/internal/models"
click node_repositories "https://github.com/ahmaddaghlas55/supermarketsys/tree/main/internal/repository"

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_checkout,node_cartline,node_customerpicker,node_weightpicker,node_barcode,node_api,node_browserauth,node_cashpage,node_productspage,node_staff toneBlue
class node_frontend,node_server,node_middleware,node_authhandler,node_inventoryhandler,node_operationshandler,node_purchasinghandler,node_promotionhandler,node_reporthandler,node_audithandler toneAmber
class node_authservice,node_catalogservice,node_operationsservice,node_purchasingservice,node_promotionservice,node_reportservice,node_auditservice,node_models toneMint
class node_repositories,node_sqlite toneRose
class node_admin toneIndigo
```

## Components

### Browser app

- [Checkout page](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/checkout.js): `internal/web/frontend/js/pages/checkout.js`
- [Cart line](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/components/CartLine.js): `internal/web/frontend/js/components/CartLine.js`
- [Customer picker](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/components/CustomerPicker.js): `internal/web/frontend/js/components/CustomerPicker.js`
- [Weight picker](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/components/WeightPicker.js): `internal/web/frontend/js/components/WeightPicker.js`
- [Barcode listener](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/core/barcodeListener.js): `internal/web/frontend/js/core/barcodeListener.js`
- [API client](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/core/api.js): `internal/web/frontend/js/core/api.js`
- [Browser auth](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/core/auth.js): `internal/web/frontend/js/core/auth.js`
- [Cash register page](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/cash-register.js): `internal/web/frontend/js/pages/cash-register.js`
- [Products page](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/frontend/js/pages/products.js): `internal/web/frontend/js/pages/products.js`

### HTTP server

- [Embedded frontend](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/web/embed.go): `internal/web/embed.go`
- [HTTP server](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [Auth middleware](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/middleware/auth.go): `internal/middleware/auth.go`
- [Auth handlers](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/auth.go): `internal/handlers/auth.go`
- [Inventory handlers](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/inventory.go): `internal/handlers/inventory.go`
- [Operations handlers](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/operations.go): `internal/handlers/operations.go`
- [Purchasing handlers](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/purchasing.go): `internal/handlers/purchasing.go`
- [Promotion handlers](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/promotions.go): `internal/handlers/promotions.go`
- [Report handlers](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/reports.go): `internal/handlers/reports.go`
- [Audit handlers](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/handlers/audit.go): `internal/handlers/audit.go`

### Business services

- [Authentication service](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/auth.go): `internal/services/auth.go`
- [Catalog service](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/catalog.go): `internal/services/catalog.go`
- [Operations service](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/operations.go): `internal/services/operations.go`
- [Purchasing service](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/purchasing.go): `internal/services/purchasing.go`
- [Promotion service](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/promotions.go): `internal/services/promotions.go`
- [Reporting service](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/reports.go): `internal/services/reports.go`
- [Audit service](https://github.com/ahmaddaghlas55/supermarketsys/blob/main/internal/services/audit.go): `internal/services/audit.go`
- [Domain models](https://github.com/ahmaddaghlas55/supermarketsys/tree/main/internal/models): `internal/models`

### Persistence

- [SQL repositories](https://github.com/ahmaddaghlas55/supermarketsys/tree/main/internal/repository): `internal/repository`
- **SQLite database**

### Other components

- **Staff user**
- **Administrator**

## Connections

- Staff user → Checkout page: uses
- Checkout page → Cart line: renders (evidence: `internal/web/frontend/js/pages/checkout.js`)
- Checkout page → Customer picker: opens (evidence: `internal/web/frontend/js/pages/checkout.js`)
- Checkout page → Weight picker: uses (evidence: `internal/web/frontend/js/pages/checkout.js`)
- Checkout page → Barcode listener: starts (evidence: `internal/web/frontend/js/pages/checkout.js`)
- Checkout page → API client: requests (evidence: `internal/web/frontend/js/pages/checkout.js`)
- Products page → API client: requests (evidence: `internal/web/frontend/js/pages/products.js`)
- Cash register page → API client: requests (evidence: `internal/web/frontend/js/pages/cash-register.js`)
- API client → Browser auth: reads token (evidence: `internal/web/frontend/js/core/api.js`)
- Checkout page → Browser auth: checks access (evidence: `internal/web/frontend/js/pages/checkout.js`)
- Staff user → Cash register page: uses
- Administrator → Products page: uses
- HTTP server → Embedded frontend: serves assets (evidence: `cmd/server/main.go`)
- HTTP server → Auth handlers: routes auth (evidence: `cmd/server/main.go`)
- HTTP server → Inventory handlers: routes catalog (evidence: `cmd/server/main.go`)
- HTTP server → Operations handlers: routes operations (evidence: `cmd/server/main.go`)
- HTTP server → Auth middleware: protects routes (evidence: `cmd/server/main.go`)
- HTTP server → Promotion handlers: constructs handler (evidence: `cmd/server/main.go`)
- Auth handlers → Authentication service: calls (evidence: `internal/handlers/auth.go`)
- HTTP server → Authentication service: constructs (evidence: `cmd/server/main.go`)
- Purchasing handlers → Purchasing service: uses
- Promotion handlers → Promotion service: uses
- Report handlers → Reporting service: uses
- Audit handlers → Audit service: uses
- Inventory handlers → Catalog service: uses
- Operations handlers → Operations service: uses
- HTTP server → SQLite database: opens (evidence: `cmd/server/main.go`)
- HTTP server → SQL repositories: constructs repositories
