How sampurnr/shopledger-legacy-workshop works
ShopLedger is a small-shop POS and bookkeeping application. A shop operator uses the browser UI to manage products and customers, preview pricing, and place or cancel orders; API routes coordinate inventory, pricing, coupon, and Khata accounting operations and persist changes. The application also exposes dashboard and GST-reconciliation reports and a printable invoice. Source excerpts show the server and core order/report flows; the browser-to-API wiring and some route implementations are not shown, so those links are marked unverified or omitted.
Main entry points: server.js Express server · orders.js Order routes · store.js JSON store · products.js Product routes
Components 20
Shop interface
- POS browser UI
public/js/app.js - Shop page
public/index.html
HTTP application
- Express server
server.js - Product routes
routes/products.js - Order routes
routes/orders.js - Customer routes
routes/customers.js - Report routes
routes/reports.js
Sales and inventory
- Inventory
lib/inventory.js - Pricing and tax
lib/pricing.js - Coupon rules
lib/coupons.js - GST slabs
lib/tax.js - Order lifecycle
lib/orders.js
Customer accounts
- Khata ledger
lib/ledger.js - Date utilities
lib/dates.js
Reporting and invoices
- Dashboard and GST
lib/reports.js - Invoice rendering
lib/invoice.js
Configuration and storage
- Shop configuration
config.js - JSON store
lib/store.js - Shop data
data/db.json
Other components
- Shop operator
Connections 40
- Shop operator → POS browser UI: uses
- POS browser UI → Shop page: displays
- POS browser UI → Express server: requests API
- Express server → Product routes: mounts routes
server.js - Express server → Order routes: mounts routes
server.js - Express server → Customer routes: mounts routes
server.js - Express server → Report routes: mounts routes
server.js - Express server → JSON store: reads order data
server.js - Express server → Order lifecycle: looks up orders
server.js - Express server → Invoice rendering: renders invoice
server.js - Product routes → JSON store: reads data
routes/products.js - Product routes → Inventory: calculates stock
routes/products.js - Product routes → GST slabs: gets GST slab
routes/products.js - Product routes → Coupon rules: lists coupons
routes/products.js - Order routes → JSON store: reads and writes
routes/orders.js - Order routes → Inventory: checks and reserves
routes/orders.js - Order routes → Pricing and tax: computes totals
routes/orders.js - Order routes → Coupon rules: validates codes
routes/orders.js - Order routes → Order lifecycle: creates orders
routes/orders.js - Order routes → Khata ledger: charges Khata
routes/orders.js - Customer routes → JSON store: reads and writes
routes/customers.js - Customer routes → Khata ledger: handles accounts
routes/customers.js - Report routes → JSON store: reads data
routes/reports.js - Report routes → Dashboard and GST: builds reports
routes/reports.js - Report routes → Pricing and tax: previews totals
routes/reports.js - Report routes → Coupon rules: validates preview
routes/reports.js - Dashboard and GST → Inventory: summarizes stock
lib/reports.js - Dashboard and GST → Khata ledger: lists customers
lib/reports.js - Dashboard and GST → Invoice rendering: reconciles totals
lib/reports.js - Order lifecycle → Date utilities: normalizes dates
lib/orders.js - Order lifecycle → Inventory: releases stock
lib/orders.js - Order lifecycle → Khata ledger: reverses debit
lib/orders.js - Khata ledger → Date utilities: dates settlements
lib/ledger.js - Pricing and tax → GST slabs: uses GST rules
lib/pricing.js - Pricing and tax → Coupon rules: calculates discount
lib/pricing.js - Inventory → Shop configuration: reads inventory defaults
lib/inventory.js - GST slabs → Shop configuration: reads GST slabs
lib/tax.js - Coupon rules → Shop configuration: reads coupon rules
lib/coupons.js - Invoice rendering → Shop configuration: reads shop and tax settings
lib/invoice.js - JSON store → Shop data: reads and writes JSON
lib/store.js