How devaprasanth1311-lang/stockflow works
Purpose and topology
StockFlow is a decoupled inventory-management dashboard: a React/Vite client presents inventory operations and analytics, while a Node.js/Express API owns authentication, products, and inventory persistence. MongoDB is the system database through Mongoose; Socket.IO is intended for live dashboard updates.
Runtime entry points
• Backend process: backend/server.js starts Express, connects infrastructure, and exposes API routes.
• Frontend bootstrap: frontend/src/main.jsx mounts the React application; frontend/src/App.jsx defines the application-level view/routing composition.
• The two runtimes are installed and started independently from backend/package.json and frontend/package.json.
Client shell and navigation
The client uses a dashboard-oriented shell, with persistent navigation framing page-level operational views.
• Layout boundary: frontend/src/layouts/DashboardLayout.jsx
• Navigation components: frontend/src/components/Sidebar.jsx, frontend/src/components/TopNav.jsx
• Primary functional screens: frontend/src/pages/Dashboard.jsx, frontend/src/pages/Products.jsx, frontend/src/pages/Movements.jsx
Dashboard and operational UI
Dashboard views surface KPIs, chart-based analytics, and activity; product and stock views support stock status and editing workflows. Supply-chain-oriented views cover suppliers and warehouse capacity.
• Analytics/dashboard: frontend/src/pages/Dashboard.jsx
• Inventory/product view: frontend/src/pages/Products.jsx, frontend/src/pages/Stock.jsx
• Supply-chain views: frontend/src/pages/Suppliers.jsx, frontend/src/pages/Warehouses.jsx
Current UI data is explicitly mock-driven, centered in frontend/src/mockData.js; API integration is therefore a key boundary rather than an established end-to-end flow.
HTTP API and authorization boundary
Express route modules separate public/auth concerns from protected inventory-domain operations.
• Authentication routes and controller: backend/src/routes/authRoutes.js, backend/src/controllers/authController.js
• Product API: backend/src/routes/productRoutes.js, backend/src/controllers/productController.js
• Inventory API: backend/src/routes/inventoryRoutes.js, backend/src/controllers/inventoryController.js
• JWT enforcement: backend/src/middleware/auth.js
The intended flow is client request → route → authentication middleware where required → controller → Mongoose model → MongoDB response.
Inventory domain and audit model
The persistence model distinguishes catalog entities, on-hand inventory, location/supply-chain entities, users, and transaction history.
• Catalog and stock: backend/src/models/Product.js, backend/src/models/Inventory.js
• Movement/audit record: backend/src/models/Transaction.js
• Organization context: backend/src/models/Warehouse.js, backend/src/models/Supplier.js
• Identity/roles: backend/src/models/User.js
Stock-in, stock-out, adjustments, and transfers should treat inventory mutation plus transaction creation as a consistency-sensitive domain boundary.
External services and integration concerns
MongoDB (local or Atlas) is required through MONGODB_URI; JWT signing requires JWT_SECRET; bcrypt supports credential handling. Socket.IO is the real-time channel intended to publish inventory changes to dashboards. The main implementation gap implied by the repository is connecting React mock-data workflows to authenticated REST endpoints and real-time events while preserving transaction/audit integrity.
Main entry points: productRoutes.js Product and inventory API · inventoryController.js Inventory mutation boundary · Dashboard.jsx Dashboard and inventory views · server.js Express server
Components 18
React client
Independently started Vite dashboard.
- Vite bootstrap
frontend/src/main.jsx - App composition
frontend/src/App.jsx - Dashboard shell · Persistent operational navigation frame.
frontend/src/layouts/DashboardLayout.jsx - Sidebar and top nav
frontend/src/components/Sidebar.jsx - Dashboard and inventory views · KPIs, products, stock, movements, suppliers, and warehouses.
frontend/src/pages/Dashboard.jsx - Mock UI data · Current UI workflows are mock-driven.
frontend/src/mockData.js - Live update client · Intended client-side inventory update channel.
Node API
Express inventory service.
- Express server · Starts infrastructure and exposes API routes.
backend/server.js - Authentication API
backend/src/routes/authRoutes.js - Product and inventory API · Protected inventory-domain operations.
backend/src/routes/productRoutes.js - JWT middleware
backend/src/middleware/auth.js - Inventory mutation boundary · Stock changes must create matching audit transactions.
backend/src/controllers/inventoryController.js - Live update publisher · Intended publisher for inventory changes.
Persistence
MongoDB-backed domain records.
- Users and roles
backend/src/models/User.js - Catalog and stock · Product and on-hand inventory records.
backend/src/models/Product.js - Movement audit · Stock-in, stock-out, adjustment, and transfer history.
backend/src/models/Transaction.js - Warehouses and suppliers
backend/src/models/Warehouse.js - MongoDB · Configured through MONGODB_URI.
Connections 23
- Vite bootstrap → App composition: mounts
- App composition → Dashboard shell: composes
- Dashboard shell → Sidebar and top nav: frames
- Dashboard shell → Dashboard and inventory views: hosts
- Dashboard and inventory views → Mock UI data: currently reads
- Dashboard and inventory views → Product and inventory API: intended authenticated REST
- Live update publisher → Live update client: inventory events
- Live update client → Dashboard and inventory views: updates dashboards
- Express server → Authentication API: registers
- Express server → Product and inventory API: registers
- Express server → Live update publisher: hosts
- Product and inventory API → JWT middleware: protects routes
- JWT middleware → Inventory mutation boundary: authorizes
- Authentication API → Users and roles: credentials and roles
- Product and inventory API → Catalog and stock: catalog operations
- Inventory mutation boundary → Catalog and stock: mutates stock
- Inventory mutation boundary → Movement audit: creates audit record
- Product and inventory API → Warehouses and suppliers: location context
- Users and roles → MongoDB: persists
- Catalog and stock → MongoDB: persists
- Movement audit → MongoDB: persists
- Warehouses and suppliers → MongoDB: persists
- Inventory mutation boundary → Live update publisher: publishes changes