Appendix — Backend Models Index
CEO Summary
Models map to database tables. Core business: orgs, tenants, users, products, POS carts, invoices. Key conventions: orgId/tenantId for tenant scope; priceCents for money; items/payments JSON in carts.
Core Business
| Model | Table | Purpose |
|---|---|---|
| org.model.js | Organizations | Tenant/org metadata |
| tenant.model.js | Tenants | Tenant records (master DB) |
| user.model.js, User.js | Users | Platform users |
| staff.model.js | Staff | Staff members (tenant DB) |
| customer.model.js | Customers | Customer records |
| product.model.js | Products | Product catalog |
| category.model.js | Categories | Product categories |
| modifier.model.js | Modifiers | Modifiers for products |
| catalog.model.js | Catalogs | Catalog containers |
| menu.model.js | Menus | Menu definitions |
| menuAssignment.model.js | MenuAssignments | Menu-to-location assignments |
POS & Invoicing
| Model | Table | Purpose |
|---|---|---|
| posCart.model.js | pos_carts | POS cart (items, payments, status) |
| invoice.model.js | Invoices | Invoices (lines JSON, paymentMethod, crypto fields) |
| order.model.js | Orders | Orders |
| payment.model.js | Payments | Payment records |
| unifiedPayment.model.js | UnifiedPayments | Unified payment tracking |
| tx.model.js | Transactions | Transaction records |
| charge.model.js | Charges | Charge records |
| dispute.model.js | Disputes | Dispute records |
Crypto
| Model | Table | Purpose |
|---|---|---|
| cryptoConfig.model.js | CryptoConfigs | DOGE/LTC/BTC config per org |
| cryptoInvoice.model.js | CryptoInvoices | Crypto payment invoices |
| wallet.model.js | Wallets | Wallet accounts |
| walletAccount.model.js | WalletAccounts | Wallet sub-accounts |
| walletAddress.model.js | WalletAddresses | Addresses |
| walletPolicy.model.js | WalletPolicies | Policy config |
| hdAccount.model.js | HDAccounts | HD wallet accounts |
| hdAddress.model.js | HDAddresses | HD addresses |
Inventory
| Model | Table | Purpose |
|---|---|---|
| inventoryItem.model.js | InventoryItems | Items (variations, barcode, domain) |
| inventoryLedger.model.js | inventory_ledger | Ledger entries |
| inventoryLevel.model.js | InventoryLevels | Stock levels |
| inventoryLot.model.js | InventoryLots | Lot tracking |
| inventorySerial.model.js | InventorySerials | Serial tracking |
| inventoryMove.model.js | InventoryMoves | Move records |
| inventoryDomain.model.js | InventoryDomains | Domains (retail, etc.) |
| inventoryAttr.model.js | InventoryAttrs | Attributes |
| stockLedger.model.js | StockLedger | Stock ledger |
| vendor.model.js | Vendors | Vendors |
| purchaseOrder.model.js | PurchaseOrders | POs |
| purchaseOrderLine.model.js | PurchaseOrderLines | PO lines |
| binLocation.model.js | BinLocations | Bin locations |
KDS & Kitchen
| Model | Table | Purpose |
|---|---|---|
| kitchenTicket.model.js | kitchen_tickets | Kitchen tickets |
| preparable.model.js | Preparables | Preparable items |
| recipe.model.js | Recipes | Recipes |
| seatingLayout.model.js | seating_layouts | Floor layouts |
HR & Payroll
| Model | Table | Purpose |
|---|---|---|
| timesheet.model.js | Timesheets | Time entries |
| shift.model.js | Shifts | Shift records |
| payrun.model.js | PayRuns | Payroll runs |
| permissionSet.model.js | PermissionSets | Permission sets |
| staffPermissions.model.js | StaffPermissions | Staff permissions |
Gift Cards & Loyalty
| Model | Table | Purpose |
|---|---|---|
| giftCard.model.js | GiftCards | Gift card records |
| giftCardProgram.model.js | GiftCardPrograms | Program config |
| giftCardTxn.model.js | GiftCardTxns | Gift card transactions |
| giftcardBatch.model.js | GiftCardBatches | Batch issuance |
| loyaltyProgram.model.js | LoyaltyPrograms | Loyalty programs |
| loyaltyAccount.model.js | LoyaltyAccounts | Customer loyalty accounts |
| loyaltyEvent.model.js | LoyaltyEvents | Loyalty events |
Devices & Bridge
| Model | Table | Purpose |
|---|---|---|
| device.model.js | Devices | Device records; JSON metadata: posModules / pos_modules (backend/utils/posModules.js; e.g. fuel); fuelSite forecourt config (backend/utils/fuelSite.js, normalized on admin save) |
| deviceProfile.model.js | DeviceProfiles | Device profiles |
| deviceSession.model.js | DeviceSessions | Device sessions |
| deviceHeartbeat.model.js | DeviceHeartbeats | Heartbeats |
| deviceCode.model.js | DeviceCodes | Claim codes |
| deviceCatalog.model.js | DeviceCatalog | Payment terminals, printers |
| printerProfile.model.js | PrinterProfiles | Printer config |
| posMode.model.js | PosModes | POS mode config |
Tickets & Appointments
| Model | Table | Purpose |
|---|---|---|
| ticket.model.js | Tickets | Ticket records |
| ticketCounter.model.js | TicketCounters | Ticket numbering |
| mysql/Ticket.js | tickets | MySQL tickets |
| mysql/TicketWorkflow.js | TicketWorkflows | Workflows |
| mysql/TicketSystem.js | TicketSystems | System config |
| mysql/TicketSettings.js | TicketSettings | Settings |
| mysql/TicketCategory.js | TicketCategories | Categories |
| mysql/TicketComment.js | TicketComments | Comments |
| mysql/Appointment.js | Appointments | Appointments |
| mysql/AppointmentStaff.js | AppointmentStaff | Staff assignments |
Payments & Integrations
| Model | Table | Purpose |
|---|---|---|
| paymentProvider.model.js | PaymentProviders | Coinbase, CoinGate, etc. |
| paymentHub.model.js | PaymentHub | Hub config |
| merchant.model.js | Merchants | Merchant records |
| cardToken.model.js | CardTokens | Card tokens |
| apiKey.model.js | ApiKeys | API keys |
| webhookEndpoint.model.js | WebhookEndpoints | Webhook config |
| webhookDelivery.model.js | WebhookDeliveries | Delivery logs |
| integrationHub.model.js | IntegrationHub | Integration config |
System & Audit
| Model | Table | Purpose |
|---|---|---|
| systemSetting.model.js | SystemSettings | System settings |
| orgSettings.model.js | OrgSettings | Org settings |
| orgRules.model.js | OrgRules | Org rules |
| taxSettings.model.js | TaxSettings | Tax config |
| receiptTemplate.model.js | ReceiptTemplates | Receipt templates |
| brandingSettings.model.js | BrandingSettings | Branding |
| auditEvent.model.js | AuditEvents | Audit log |
| session.model.js | Sessions | Sessions |
| idempotency.model.js | IdempotencyKeys | Idempotency |
| idempotencyKey.model.js | IdempotencyKeys | Idempotency keys |
Analytics & Reporting
| Model | Table | Purpose |
|---|---|---|
| staffAnalytics.model.js | StaffAnalytics | Staff analytics |
| customerAnalytics.model.js | CustomerAnalytics | Customer analytics |
| transactionTracking.model.js | TransactionTracking | Transaction tracking |
| offlineTransaction.model.js | OfflineTransactions | Offline txns |
MySQL-Specific (Sequelize)
| Model | Table | Purpose |
|---|---|---|
| mysql/Tenant.js | Tenants | Master tenants |
| mysql/Organization.js | Organizations | Master orgs |
| mysql/User.js | Users | Master users |
| mysql/DatabaseConfig.js | DatabaseConfigs | DB config |
| mysql/PasswordResetToken.js | PasswordResetTokens | Reset tokens |
Customer Auth
| Model | Table | Purpose |
|---|---|---|
| customer-auth.model.js | CustomerAuth | Customer login/auth |
Key Field Conventions
- orgId — Organization/tenant ID (tenant-scoped tables)
- tenantId — Same as orgId in many contexts
- priceCents — All monetary amounts in cents
- items (JSON) — Cart line items: { productId, name, priceCents, qty, modifierCents }
- payments (JSON) — Cart payments: { method, amountCents, status, paymentId }
- status — open, awaiting_payment, paid, voided, refunded (POS); draft, paid (Invoice)