StockFlow is a local demonstration application for multi-warehouse inventory operations. It uses React + Vite, Express, and SQLite (through the portable sql.js WebAssembly runtime). Dashboard figures, tables, alerts, and history are queried from SQLite.
- Node.js 20 or newer and npm (or pnpm)
- Windows, macOS, or Linux
- Open this project folder in a terminal.
- Install packages:
npm install - Start both frontend and backend:
npm run dev - Open http://localhost:5173. The API runs at http://localhost:4000.
The database is created automatically at server/inventory.db with realistic sample data on first launch. To reset the demo data, stop the app and delete that database file; it will be recreated next start. This generated database is ignored by Git.
To verify a production frontend build, run npm run build. The Express API does not serve the built frontend; npm run dev is the simplest demo command.
- Live overview counts, movement chart, recent activity, and low-stock alerts
- Product catalog with add, edit, search, and reorder thresholds
- Warehouse list with stock totals and manager information
- Stock-in, stock-out, and inter-warehouse transfers
- Transaction audit history
- Supplier directory creation and basic purchase order creation
- SQLite foreign keys and constraints; inventory rows reject negative values and transfer operations execute atomically
Demo operator shown in history: Alex Morgan (Administrator). This is a local demonstration identity, not an authentication system. Do not expose the server publicly.
Schema is in server/schema.sql. Relationships are documented in docs/erd.mmd. API and architecture are in docs/API.md and docs/architecture.mmd.
Tables: users, suppliers, products, warehouses, inventory, stock_transactions, purchase_orders, purchase_order_items. SQLite enforces primary keys, foreign keys, checks, and unique constraints. Stock operations use a transaction to keep inventory and audit rows consistent.
The defaults work without an environment file. Copy .env.example to .env only if you need to change the local API port or database location. VITE_API_URL configures the frontend during Vite startup. Never store real credentials in .env; the example file contains no secrets.
Commit the source files and pnpm-lock.yaml (if generated). .gitignore excludes node_modules, build output, local SQLite files, and .env. Do not upload a real database or secrets.
- Show Overview and explain the database-backed total cards and low-stock panel.
- Open Products, search “scanner”, and edit a reorder level; use Add product to create another catalog item.
- Open Warehouses and create a location.
- In Stock operations, choose Stock in and add units; verify the updated overview and transaction history.
- Try a stock-out larger than the available quantity: the API rejects it and stock stays unchanged. Then stock out a valid amount.
- Choose Transfer, select a source warehouse and a different destination, and submit. Confirm paired transfer entries in Transactions.
- Create a supplier and purchase order under Purchase orders.
- If the page cannot connect to the API, confirm both processes started and port 4000 is free.
- If dependencies fail to install, check that Node/npm are installed and internet access to the npm registry is available.
- Sample state is local to
server/inventory.dband is not committed.