# dlop3zc/soma-punto-venta architecture

> Architecture diagram of the GitHub repository dlop3zc/soma-punto-venta, 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/dlop3zc/soma-punto-venta
- Repository: https://github.com/dlop3zc/soma-punto-venta

## Overview

SOMA is a bar/restaurant point-of-sale app for staff to manage table accounts, send items through kitchen preparation, take payment, and close shifts. The main workflow runs from menu selection and open orders through kitchen updates and checkout; inventory tracks availability and stock along the way. Admin capabilities include managing the menu and staff, reviewing analytics, and recording cash cuts. Firebase provides authentication and persistent data; ticket printing supports browser and direct ESC/POS modes. Relationships reflect the README and shown imports/calls; unsampled implementations are represented only where documented.

Main entry points: [`src/App.tsx`](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/App.tsx) (POS app), [`src/store/useCartStore.ts`](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useCartStore.ts) (Order state), [`src/firebase.ts`](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/firebase.ts) (Firebase setup), [`src/components/ProductCatalog.tsx`](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/ProductCatalog.tsx) (Product catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Order operations"]
  node_app["POS app<br/>[App.tsx]"]
  node_catalog["Product catalog<br/>[ProductCatalog.tsx]"]
  node_cart["Table accounts<br/>[Cart.tsx]"]
  node_orders["Order state<br/>[useCartStore.ts]"]
  node_kitchen["Kitchen queue<br/>[KitchenView.tsx]"]
  node_checkout["Checkout<br/>[CheckoutView.tsx]"]
  node_payment["Payment dialog<br/>[CheckoutModal.tsx]"]
  node_split["Split bill<br/>[SplitBillModal.tsx]"]
end

subgraph group_admin["Admin and reporting"]
  node_menu["Menu management<br/>[MenuEditorView.tsx]"]
  node_menu_state["Menu state<br/>[useMenuStore.ts]"]
  node_default_menu["Initial menu<br/>[defaultMenu.ts]"]
  node_inventory["Inventory management<br/>[InventoryView.tsx]"]
  node_inventory_state["Inventory state"]
  node_stock["Stock rules<br/>[stock.ts]"]
  node_analytics["Sales analytics<br/>[AnalyticsView.tsx]"]
  node_analytics_logic["Analytics calculations<br/>[analytics.ts]"]
  node_cashcut["Cash cut<br/>[CashCutModal.tsx]"]
  node_shift["Shift state<br/>[useShiftStore.ts]"]
  node_cut_logic["Shift calculations<br/>[cashCut.ts]"]
  node_users["Staff administration<br/>[AdminUsersView.tsx]"]
end

subgraph group_platform["Data and identity"]
  node_login["Sign in<br/>[LoginView.tsx]"]
  node_auth_state["Auth state<br/>[useAuthStore.ts]"]
  node_firebase["Firebase setup<br/>[firebase.ts]"]
end

subgraph group_printing["Ticket printing"]
  node_printer_settings["Printer settings"]
  node_printer_state["Printer state<br/>[usePrinterStore.ts]"]
  node_ticket_builder["Ticket builders<br/>[tickets.ts]"]
  node_escpos["ESC/POS encoding<br/>[escpos.ts]"]
  node_html_ticket["HTML ticket<br/>[htmlTicket.ts]"]
  node_transport["Printer transport<br/>[transport.ts]"]
  node_browser_print["Browser printing<br/>[browserPrint.ts]"]
end

node_staff(("Restaurant staff"))
node_firestore[("Firestore")]
node_firebase_auth["Firebase Authentication"]
node_printer["Receipt printer"]

node_staff -->|"uses"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_cart
node_app -->|"routes to"| node_kitchen
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_inventory
node_app -->|"routes to"| node_menu
node_catalog -->|"adds items"| node_orders
node_catalog -->|"reads menu"| node_menu_state
node_catalog -->|"checks stock"| node_inventory_state
node_cart -->|"updates accounts"| node_orders
node_kitchen -->|"updates preparation"| node_orders
node_checkout -->|"loads accounts"| node_orders
node_checkout -->|"opens"| node_payment
node_checkout -->|"opens"| node_split
node_menu -->|"edits"| node_menu_state
node_menu_state -->|"seeds from"| node_default_menu
node_inventory -->|"adjusts stock"| node_inventory_state
node_orders -->|"checks availability"| node_stock
node_analytics -->|"calculates reports"| node_analytics_logic
node_analytics -->|"reads sales"| node_orders
node_analytics -->|"reads stock"| node_inventory_state
node_cashcut -->|"closes shift"| node_shift
node_cashcut -->|"summarizes sales"| node_cut_logic
node_shift -->|"reads sales"| node_orders
node_shift -->|"computes totals"| node_cut_logic
node_users -->|"manages users"| node_auth_state
node_login -->|"signs in through"| node_auth_state
node_auth_state -->|"uses services"| node_firebase
node_auth_state -->|"authenticates"| node_firebase_auth
node_menu_state -->|"uses database"| node_firebase
node_orders -->|"uses database"| node_firebase
node_inventory_state -->|"uses database"| node_firebase
node_shift -->|"uses database"| node_firebase
node_firebase -->|"connects to"| node_firestore
node_firebase -->|"connects to"| node_firebase_auth
node_printer_settings -->|"configures"| node_printer_state
node_printer_state -->|"builds tickets"| node_ticket_builder
node_ticket_builder -->|"encodes"| node_escpos
node_ticket_builder -->|"renders"| node_html_ticket
node_printer_state -->|"sends through"| node_transport
node_printer_state -->|"prints via"| node_browser_print
node_transport -.->|"writes to"| node_printer
node_browser_print -.->|"prints to"| node_printer

click node_app "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/App.tsx"
click node_catalog "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/ProductCatalog.tsx"
click node_cart "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/Cart.tsx"
click node_orders "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useCartStore.ts"
click node_kitchen "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/KitchenView.tsx"
click node_checkout "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/CheckoutView.tsx"
click node_payment "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/CheckoutModal.tsx"
click node_split "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/SplitBillModal.tsx"
click node_menu "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/MenuEditorView.tsx"
click node_menu_state "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useMenuStore.ts"
click node_default_menu "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/data/defaultMenu.ts"
click node_inventory "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/InventoryView.tsx"
click node_inventory_state "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useInventoryStore.ts"
click node_stock "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/utils/stock.ts"
click node_analytics "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/AnalyticsView.tsx"
click node_analytics_logic "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/utils/analytics.ts"
click node_cashcut "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/CashCutModal.tsx"
click node_shift "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useShiftStore.ts"
click node_cut_logic "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/utils/cashCut.ts"
click node_users "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/AdminUsersView.tsx"
click node_login "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/LoginView.tsx"
click node_auth_state "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useAuthStore.ts"
click node_firebase "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/firebase.ts"
click node_printer_settings "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/PrinterSettingsView.tsx"
click node_printer_state "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/usePrinterStore.ts"
click node_ticket_builder "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/tickets.ts"
click node_escpos "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/escpos.ts"
click node_html_ticket "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/htmlTicket.ts"
click node_transport "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/transport.ts"
click node_browser_print "https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/browserPrint.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,node_catalog,node_cart,node_orders,node_kitchen,node_checkout,node_payment,node_split toneBlue
class node_menu,node_menu_state,node_default_menu,node_inventory,node_inventory_state,node_stock,node_analytics,node_analytics_logic,node_cashcut,node_shift,node_cut_logic,node_users,node_firestore toneAmber
class node_login,node_auth_state,node_firebase toneMint
class node_printer_settings,node_printer_state,node_ticket_builder,node_escpos,node_html_ticket,node_transport,node_browser_print toneRose
class node_staff,node_firebase_auth,node_printer toneIndigo
```

## Components

### Order operations

- [POS app](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/App.tsx): `src/App.tsx`
- [Product catalog](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/ProductCatalog.tsx): `src/components/ProductCatalog.tsx`
- [Table accounts](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/Cart.tsx): `src/components/Cart.tsx`
- [Order state](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useCartStore.ts): `src/store/useCartStore.ts`
- [Kitchen queue](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/KitchenView.tsx): `src/components/KitchenView.tsx`
- [Checkout](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/CheckoutView.tsx): `src/components/CheckoutView.tsx`
- [Payment dialog](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/CheckoutModal.tsx): `src/components/CheckoutModal.tsx`
- [Split bill](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/SplitBillModal.tsx): `src/components/SplitBillModal.tsx`

### Admin and reporting

- [Menu management](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/MenuEditorView.tsx): `src/components/MenuEditorView.tsx`
- [Menu state](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useMenuStore.ts): `src/store/useMenuStore.ts`
- [Initial menu](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/data/defaultMenu.ts): `src/data/defaultMenu.ts`
- [Inventory management](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/InventoryView.tsx): `src/components/InventoryView.tsx`
- [Inventory state](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useInventoryStore.ts): `src/store/useInventoryStore.ts`
- [Stock rules](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/utils/stock.ts): `src/utils/stock.ts`
- [Sales analytics](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/AnalyticsView.tsx): `src/components/AnalyticsView.tsx`
- [Analytics calculations](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/utils/analytics.ts): `src/utils/analytics.ts`
- [Cash cut](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/CashCutModal.tsx): `src/components/CashCutModal.tsx`
- [Shift state](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useShiftStore.ts): `src/store/useShiftStore.ts`
- [Shift calculations](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/utils/cashCut.ts): `src/utils/cashCut.ts`
- [Staff administration](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/AdminUsersView.tsx): `src/components/AdminUsersView.tsx`

### Data and identity

- [Sign in](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/LoginView.tsx): `src/components/LoginView.tsx`
- [Auth state](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/useAuthStore.ts): `src/store/useAuthStore.ts`
- [Firebase setup](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/firebase.ts): `src/firebase.ts`

### Ticket printing

- [Printer settings](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/components/PrinterSettingsView.tsx): `src/components/PrinterSettingsView.tsx`
- [Printer state](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/store/usePrinterStore.ts): `src/store/usePrinterStore.ts`
- [Ticket builders](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/tickets.ts): `src/printer/tickets.ts`
- [ESC/POS encoding](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/escpos.ts): `src/printer/escpos.ts`
- [HTML ticket](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/htmlTicket.ts): `src/printer/htmlTicket.ts`
- [Printer transport](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/transport.ts): `src/printer/transport.ts`
- [Browser printing](https://github.com/dlop3zc/soma-punto-venta/blob/main/src/printer/browserPrint.ts): `src/printer/browserPrint.ts`

### Other components

- **Restaurant staff**
- **Firestore**
- **Firebase Authentication**
- **Receipt printer**

## Connections

- Restaurant staff → POS app: uses
- POS app → Sign in: routes to (evidence: `src/App.tsx`)
- POS app → Product catalog: routes to (evidence: `src/App.tsx`)
- POS app → Table accounts: routes to (evidence: `src/App.tsx`)
- POS app → Kitchen queue: routes to (evidence: `src/App.tsx`)
- POS app → Checkout: routes to (evidence: `src/App.tsx`)
- POS app → Sales analytics: routes to (evidence: `src/App.tsx`)
- POS app → Inventory management: routes to (evidence: `src/App.tsx`)
- POS app → Menu management: routes to (evidence: `src/App.tsx`)
- Product catalog → Order state: adds items (evidence: `src/components/ProductCatalog.tsx`)
- Product catalog → Menu state: reads menu (evidence: `src/components/ProductCatalog.tsx`)
- Product catalog → Inventory state: checks stock (evidence: `src/components/ProductCatalog.tsx`)
- Table accounts → Order state: updates accounts (evidence: `src/components/Cart.tsx`)
- Kitchen queue → Order state: updates preparation (evidence: `src/components/KitchenView.tsx`)
- Checkout → Order state: loads accounts (evidence: `src/components/CheckoutView.tsx`)
- Checkout → Payment dialog: opens (evidence: `src/components/CheckoutView.tsx`)
- Checkout → Split bill: opens (evidence: `src/components/CheckoutView.tsx`)
- Menu management → Menu state: edits (evidence: `src/components/MenuEditorView.tsx`)
- Menu state → Initial menu: seeds from (evidence: `src/store/useMenuStore.ts`)
- Inventory management → Inventory state: adjusts stock (evidence: `src/components/InventoryView.tsx`)
- Order state → Stock rules: checks availability (evidence: `src/store/useCartStore.ts`)
- Sales analytics → Analytics calculations: calculates reports (evidence: `src/components/AnalyticsView.tsx`)
- Sales analytics → Order state: reads sales (evidence: `src/components/AnalyticsView.tsx`)
- Sales analytics → Inventory state: reads stock (evidence: `src/components/AnalyticsView.tsx`)
- Cash cut → Shift state: closes shift (evidence: `src/components/CashCutModal.tsx`)
- Cash cut → Shift calculations: summarizes sales (evidence: `src/components/CashCutModal.tsx`)
- Shift state → Order state: reads sales (evidence: `src/store/useShiftStore.ts`)
- Shift state → Shift calculations: computes totals (evidence: `src/store/useShiftStore.ts`)
- Staff administration → Auth state: manages users (evidence: `src/components/AdminUsersView.tsx`)
- Sign in → Auth state: signs in through (evidence: `src/components/LoginView.tsx`)
- Auth state → Firebase setup: uses services (evidence: `src/store/useAuthStore.ts`)
- Auth state → Firebase Authentication: authenticates (evidence: `src/store/useAuthStore.ts`)
- Menu state → Firebase setup: uses database (evidence: `src/store/useMenuStore.ts`)
- Order state → Firebase setup: uses database (evidence: `src/store/useCartStore.ts`)
- Inventory state → Firebase setup: uses database (evidence: `src/store/useInventoryStore.ts`)
- Shift state → Firebase setup: uses database (evidence: `src/store/useShiftStore.ts`)
- Firebase setup → Firestore: connects to (evidence: `src/firebase.ts`)
- Firebase setup → Firebase Authentication: connects to (evidence: `src/firebase.ts`)
- Printer settings → Printer state: configures (evidence: `src/components/PrinterSettingsView.tsx`)
- Printer state → Ticket builders: builds tickets (evidence: `src/store/usePrinterStore.ts`)
- Ticket builders → ESC/POS encoding: encodes (evidence: `src/printer/tickets.ts`)
- Ticket builders → HTML ticket: renders (evidence: `src/printer/tickets.ts`)
- Printer state → Printer transport: sends through (evidence: `src/store/usePrinterStore.ts`)
- Printer state → Browser printing: prints via (evidence: `src/store/usePrinterStore.ts`)
- Printer transport → Receipt printer: writes to
- Browser printing → Receipt printer: prints to
