# jushazen/bentatrack architecture

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

- Interactive diagram: https://gitdiagram.com/jushazen/bentatrack
- Repository: https://github.com/jushazen/bentatrack

## Overview

Bentatrack is a browser-based retail inventory and point-of-sale application. A cashier searches or scans products, builds a cart, and records a sale; sales, refunds, and restocks can be queued locally and synced to the server. The broader product includes catalog and stock management, reporting, supplier and category administration, and staff access controls. The graph follows documented imports and the sampled offline-sync/API path; several unsampled feature connections are intentionally not asserted.

Main entry points: [`src/features/sales/checkout-form.tsx`](https://github.com/jushazen/bentatrack/blob/main/src/features/sales/checkout-form.tsx) (Checkout form), [`src/app/api/sync/route.ts`](https://github.com/jushazen/bentatrack/blob/main/src/app/api/sync/route.ts) (Sync endpoint), [`src/app/(app)/dashboard/page.tsx`](https://github.com/jushazen/bentatrack/blob/main/src/app/(app)/dashboard/page.tsx) (Dashboard), [`src/lib/offline/sync.ts`](https://github.com/jushazen/bentatrack/blob/main/src/lib/offline/sync.ts) (Offline sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["App interface"]
  node_app_shell["App shell<br/>[app-shell.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
end

subgraph group_commerce["Sales and refunds"]
  node_checkout_ui["Checkout form<br/>[checkout-form.tsx]"]
  node_sales_cart["Sales cart<br/>[cart.ts]"]
  node_sale_actions["Sale actions<br/>[actions.ts]"]
  node_sale_records["Sales history<br/>[queries.ts]"]
  node_refunds["Refunds<br/>[actions.ts]"]
  node_refund_records["Refund records<br/>[queries.ts]"]
end

subgraph group_catalog["Catalog and stock"]
  node_product_search["Product search<br/>[product-search.tsx]"]
  node_search_queries["Product lookup<br/>[queries.ts]"]
  node_products["Product management<br/>[actions.ts]"]
  node_inventory["Inventory management<br/>[actions.ts]"]
  node_inventory_history["Stock history<br/>[history-list.tsx]"]
end

subgraph group_operations["Business operations"]
  node_categories["Categories<br/>[actions.ts]"]
  node_suppliers["Suppliers<br/>[actions.ts]"]
  node_reports["Reports<br/>[queries.ts]"]
  node_staff["Staff management<br/>[actions.ts]"]
end

subgraph group_platform["Identity and offline"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_permissions["Role permissions<br/>[permissions.ts]"]
  node_offline_sync["Offline sync<br/>[sync.ts]"]
  node_outbox[("Command outbox<br/>[outbox.ts]")]
  node_sync_api["Sync endpoint<br/>[route.ts]"]
end

node_cashier(("Cashier"))

node_cashier -->|"uses"| node_checkout_ui
node_checkout_ui -->|"searches"| node_product_search
node_checkout_ui -->|"uses"| node_sales_cart
node_product_search -->|"looks up"| node_search_queries
node_checkout_ui -->|"submits commands"| node_offline_sync
node_offline_sync -->|"queues and replays"| node_outbox
node_offline_sync -->|"sends commands"| node_sync_api
node_sync_api -->|"dispatches sales"| node_sale_actions
node_sync_api -->|"dispatches refunds"| node_refunds
node_sync_api -->|"dispatches restocks"| node_inventory
node_auth -->|"checks roles"| node_permissions
node_dashboard -.->|"renders within"| node_app_shell
node_dashboard -.->|"summarizes sales"| node_sale_records
node_dashboard -.->|"shows stock status"| node_products

click node_app_shell "https://github.com/jushazen/bentatrack/blob/main/src/components/layout/app-shell.tsx"
click node_dashboard "https://github.com/jushazen/bentatrack/blob/main/src/app/(app)/dashboard/page.tsx"
click node_checkout_ui "https://github.com/jushazen/bentatrack/blob/main/src/features/sales/checkout-form.tsx"
click node_product_search "https://github.com/jushazen/bentatrack/blob/main/src/features/search/product-search.tsx"
click node_search_queries "https://github.com/jushazen/bentatrack/blob/main/src/features/search/queries.ts"
click node_sales_cart "https://github.com/jushazen/bentatrack/blob/main/src/features/sales/cart.ts"
click node_sale_actions "https://github.com/jushazen/bentatrack/blob/main/src/features/sales/actions.ts"
click node_sale_records "https://github.com/jushazen/bentatrack/blob/main/src/features/sales/queries.ts"
click node_refunds "https://github.com/jushazen/bentatrack/blob/main/src/features/refunds/actions.ts"
click node_refund_records "https://github.com/jushazen/bentatrack/blob/main/src/features/refunds/queries.ts"
click node_products "https://github.com/jushazen/bentatrack/blob/main/src/features/products/actions.ts"
click node_inventory "https://github.com/jushazen/bentatrack/blob/main/src/features/inventory/actions.ts"
click node_inventory_history "https://github.com/jushazen/bentatrack/blob/main/src/features/inventory/history-list.tsx"
click node_categories "https://github.com/jushazen/bentatrack/blob/main/src/features/categories/actions.ts"
click node_suppliers "https://github.com/jushazen/bentatrack/blob/main/src/features/suppliers/actions.ts"
click node_reports "https://github.com/jushazen/bentatrack/blob/main/src/features/reports/queries.ts"
click node_staff "https://github.com/jushazen/bentatrack/blob/main/src/features/users/actions.ts"
click node_auth "https://github.com/jushazen/bentatrack/blob/main/src/lib/auth.ts"
click node_permissions "https://github.com/jushazen/bentatrack/blob/main/src/lib/permissions.ts"
click node_offline_sync "https://github.com/jushazen/bentatrack/blob/main/src/lib/offline/sync.ts"
click node_outbox "https://github.com/jushazen/bentatrack/blob/main/src/lib/offline/outbox.ts"
click node_sync_api "https://github.com/jushazen/bentatrack/blob/main/src/app/api/sync/route.ts"

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_shell,node_dashboard toneBlue
class node_checkout_ui,node_sales_cart,node_sale_actions,node_sale_records,node_refunds,node_refund_records toneAmber
class node_product_search,node_search_queries,node_products,node_inventory,node_inventory_history toneMint
class node_categories,node_suppliers,node_reports,node_staff toneRose
class node_auth,node_permissions,node_offline_sync,node_outbox,node_sync_api,node_cashier toneIndigo
```

## Components

### App interface

- [App shell](https://github.com/jushazen/bentatrack/blob/main/src/components/layout/app-shell.tsx): `src/components/layout/app-shell.tsx`
- [Dashboard](https://github.com/jushazen/bentatrack/blob/main/src/app/(app)/dashboard/page.tsx): `src/app/(app)/dashboard/page.tsx`

### Sales and refunds

- [Checkout form](https://github.com/jushazen/bentatrack/blob/main/src/features/sales/checkout-form.tsx): `src/features/sales/checkout-form.tsx`
- [Sales cart](https://github.com/jushazen/bentatrack/blob/main/src/features/sales/cart.ts): `src/features/sales/cart.ts`
- [Sale actions](https://github.com/jushazen/bentatrack/blob/main/src/features/sales/actions.ts): `src/features/sales/actions.ts`
- [Sales history](https://github.com/jushazen/bentatrack/blob/main/src/features/sales/queries.ts): `src/features/sales/queries.ts`
- [Refunds](https://github.com/jushazen/bentatrack/blob/main/src/features/refunds/actions.ts): `src/features/refunds/actions.ts`
- [Refund records](https://github.com/jushazen/bentatrack/blob/main/src/features/refunds/queries.ts): `src/features/refunds/queries.ts`

### Catalog and stock

- [Product search](https://github.com/jushazen/bentatrack/blob/main/src/features/search/product-search.tsx): `src/features/search/product-search.tsx`
- [Product lookup](https://github.com/jushazen/bentatrack/blob/main/src/features/search/queries.ts): `src/features/search/queries.ts`
- [Product management](https://github.com/jushazen/bentatrack/blob/main/src/features/products/actions.ts): `src/features/products/actions.ts`
- [Inventory management](https://github.com/jushazen/bentatrack/blob/main/src/features/inventory/actions.ts): `src/features/inventory/actions.ts`
- [Stock history](https://github.com/jushazen/bentatrack/blob/main/src/features/inventory/history-list.tsx): `src/features/inventory/history-list.tsx`

### Business operations

- [Categories](https://github.com/jushazen/bentatrack/blob/main/src/features/categories/actions.ts): `src/features/categories/actions.ts`
- [Suppliers](https://github.com/jushazen/bentatrack/blob/main/src/features/suppliers/actions.ts): `src/features/suppliers/actions.ts`
- [Reports](https://github.com/jushazen/bentatrack/blob/main/src/features/reports/queries.ts): `src/features/reports/queries.ts`
- [Staff management](https://github.com/jushazen/bentatrack/blob/main/src/features/users/actions.ts): `src/features/users/actions.ts`

### Identity and offline

- [Authentication](https://github.com/jushazen/bentatrack/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Role permissions](https://github.com/jushazen/bentatrack/blob/main/src/lib/permissions.ts): `src/lib/permissions.ts`
- [Offline sync](https://github.com/jushazen/bentatrack/blob/main/src/lib/offline/sync.ts): `src/lib/offline/sync.ts`
- [Command outbox](https://github.com/jushazen/bentatrack/blob/main/src/lib/offline/outbox.ts): `src/lib/offline/outbox.ts`
- [Sync endpoint](https://github.com/jushazen/bentatrack/blob/main/src/app/api/sync/route.ts): `src/app/api/sync/route.ts`

### Other components

- **Cashier**

## Connections

- Cashier → Checkout form: uses
- Checkout form → Product search: searches (evidence: `src/features/sales/checkout-form.tsx`)
- Checkout form → Sales cart: uses (evidence: `src/features/sales/checkout-form.tsx`)
- Product search → Product lookup: looks up (evidence: `src/features/search/product-search.tsx`)
- Checkout form → Offline sync: submits commands (evidence: `src/features/sales/checkout-form.tsx`)
- Offline sync → Command outbox: queues and replays (evidence: `src/lib/offline/sync.ts`)
- Offline sync → Sync endpoint: sends commands (evidence: `src/lib/offline/sync.ts`)
- Sync endpoint → Sale actions: dispatches sales (evidence: `src/app/api/sync/route.ts`)
- Sync endpoint → Refunds: dispatches refunds (evidence: `src/app/api/sync/route.ts`)
- Sync endpoint → Inventory management: dispatches restocks (evidence: `src/app/api/sync/route.ts`)
- Authentication → Role permissions: checks roles (evidence: `src/lib/auth.ts`)
- Dashboard → App shell: renders within
- Dashboard → Sales history: summarizes sales
- Dashboard → Product management: shows stock status
