Two main views: POS screen for cashiers and back-office dashboard for the owner. Harder than the invoice system — multi-role access, product variants with individual stock counts, atomic stock operations under concurrency, and a POS interface that needs to be fast enough for daily use.
What to Build
- Roles: Owner/Admin (full access) and Cashier (POS only)
- Products: name, SKU, category, cost price, selling price, stock count, reorder level, supplier, variants (size/color with individual stock)
- POS interface: search products, add to cart, adjust qty, apply discounts, calculate total, process sale, generate receipt view
- Stock operations: auto-deduct on sale, manual adjustments with reason (damaged, returned, restocked), full audit trail
- Purchase orders: create orders to suppliers, mark received to auto-update stock
- Low stock alerts: configurable threshold per product, dashboard highlights items below level
- Reports: revenue by period, top sellers, revenue by category, profit margins, sales by cashier
- Audit trail: every stock change (sale, adjustment, restock) logged with timestamp and user
Phases
1Schema design: Product (with variants), Sale (with line items), StockAdjustment, PurchaseOrder, User. Think hard about variants — "Blue T-Shirt Size M" needs its own stock count but shares a product page.
2Backend: Product CRUD, sale processing (deduct stock atomically — what if stock hits 0 mid-transaction?), stock adjustment logging, purchase order workflow, report aggregation endpoints.
3POS frontend: fast, keyboard-friendly. Search by name or SKU, cart management, checkout. Needs to be snappy.
4Admin frontend: product management, inventory overview, alerts, purchase orders, reports with charts. Deploy.
Decisions You'll Make
How to model variants (separate docs? embedded array? Variant collection referencing Product?). How to prevent stock going negative during concurrent sales (transactions? optimistic concurrency?). How to structure POS cart state (useReducer: ADD_ITEM, REMOVE_ITEM, SET_QTY, APPLY_DISCOUNT, CLEAR). How to build fast product search for cashiers. How to calculate profit margins using aggregation.
Stack
React
Express
MongoDB
Mongoose
JWT
React Router
React Query
useReducer
useContext
Redux Toolkit
Custom Hooks
Vitest
SuperTest