3.4 KiB
3.4 KiB
Architecture Overview
Goal
Deliver a practical inventory and order management system that can run in a single Docker container on Unraid using SQLite for persistence.
System Shape
The application is a monolithic web app:
- Next.js handles UI rendering and server-side actions
- SQLite stores operational and accounting data
- Server actions execute the main workflows directly against SQLite
- The same process serves UI and API endpoints
- Auth is handled in-process with a bootstrap admin user and signed session cookies
Authentication
- The first user can be bootstrapped from
ADMIN_EMAILandADMIN_PASSWORD - Session cookies are signed with
AUTH_SECRET - Middleware protects application routes and redirects unauthenticated requests to
/login - This model is intentionally simple and suited to a single-container internal deployment
Domain Boundaries
Item Master
partsstores both stocked parts and assemblieskinddifferentiates simple stocked parts from buildable assemblies- Assemblies remain sellable as normal items
Bill of Materials
kit_componentsmaps assembly items to component parts- Building an assembly consumes component stock and creates finished stock
Inventory Ledger
inventory_transactionsis the stock source of truth- On-hand stock is derived through aggregation rather than directly edited balances
- Supported transaction types include manual adjustments, purchase receipts, sales shipments, and assembly builds
Sales
customersdrives customer master datasales_ordersandsales_order_linescapture outbound demand- Shipping can be partial at the line level through
shipped_quantity - Each shipment posts inventory movements and journal entries for only the quantity moved
- Each shipment also creates a customer invoice that can later be partially or fully paid
Purchasing
vendorsdrives vendor master datapurchase_ordersandpurchase_order_linescapture replenishment demand- Receiving can be partial at the line level through
received_quantity - Each receipt posts inventory movements and journal entries for only the quantity received
- Each receipt also creates a vendor bill that can later be partially or fully paid
Accounting
journal_entriesandjournal_linesprovide a lightweight operational journalaccountsprovides a small chart of accounts for system-posted and manual entries- Purchase receipts debit inventory and credit accounts payable
- Sales shipments debit accounts receivable and cost of goods sold, then credit sales revenue and inventory
- Customer payments debit cash and credit accounts receivable
- Vendor payments debit accounts payable and credit cash
- Manual journals allow opening balances and non-operational bookkeeping adjustments
Replenishment Visibility
- Low-stock reporting is derived from current on-hand balances against item reorder points
- Suggested reorder quantity is calculated from the gap between on-hand and reorder point
- The purchase order screen surfaces these items to speed up restocking decisions
Deployment Notes
- Database file defaults to
/data/inven.sqlite - Next.js standalone output keeps container runtime simple
- A volume mount for
/datapreserves SQLite across container restarts
Near-Term Expansion
- Authentication and role permissions
- Partial receipts and shipments
- Invoices, payments, and vendor bill settlement
- Warehouse or location tracking
- Reporting and export workflows