📦 StockSync is a MERN-based Inventory Management System designed to help businesses efficiently manage products 🛒, categories 🗂️, suppliers 🚚, and stock levels 📊.
The system provides real-time inventory tracking ⏱️, low-stock alerts
- 🧰 Tech Stack
- ✨ Features
- 🎨 UI Highlights
- 🖼️ Screenshots
- 📦 Installation & Setup
- 🎮 Demo Access
- 🚀 Usage
- 🏗 App Structure
- 🗂 Key Files
- 🧩 Core Functionality
- 🔐 Security & Rules
- 🧱 System Architecture
- 🔗 Database Schema & Relationships
- 📈 Future Enhancements
- ❤️ Built With Love
- ⚡ React 19 (Vite) – Used for building a fast and interactive user interface.
- 🎨 Material-UI (MUI) – Provides ready-made components for a clean and consistent design.
- 🛣️ React Router DOM (v7) – Handles page navigation smoothly across the app.
- 📡 Axios – Used to communicate with the backend APIs.
- 🔔 React Toastify – Shows real-time notifications for user actions.
- 📊 Recharts - D3-based charting library for React.
- 🟢 Node.js – Javascript runtime environment which runs the server-side code and handles requests.
- 🚀 Express – Lightweight framework for building RESTful APIs.
- 🍃 MongoDB & Mongoose (ODM) – Stores app data and provides schema-based data modeling.
- 🔑 JWT (JSON Web Token) – Secure, stateless authentication for user sessions.
- 🛡️ Bcryptjs – Hashes passwords for secure user authentication.
-
🔐 Role-Based Access Control (RBAC) - Distinct interfaces for Admins (Full Control) and Staff (Restricted View).
-
📊 Live Stock Tracking - Real-time calculation of In Stock, Low Stock, and Out of Stock statuses.
-
🚚 Supplier Management - Complete supplier CRM with cascade deletion logic (removing a supplier also deletes linked products).
-
👥 User Management - Admins can create, promote, or deactivate staff accounts.
-
🔍 Centralized Search & Filters - Quick filtering by category, supplier and stock status.
-
🔐 Authentication: JWT-secured login (Admin controlled).
-
📘 Products & Categories: CRUD operations with validation.
-
👥 Suppliers: Manage suppliers and relationships with products.
-
⚠️ Cascade Delete: Deleting a product category or supplier automatically removes related products.
- ✨ Clean Design – Built with Material-UI for a modern and consistent look.
- 🔔 Toast Notifications – Real-time alerts for user actions and feedback.
- ⚡ Demo Quick-Start - One-click demo login buttons on the authentication page for instant access.
- 🧭 Dynamic Sidebar - Navigation items conditionally render based on user permissions.
- 🏷️ Status Badging - Visual color-coding to clearly represent inventory health.
To get started with Study Flux, follow these steps:
git clone https://github.com/sandeepmukku12/stocksync.git
cd stocksyncNavigate to the server directory and install dependencies:
cd server
npm installCreate a .env file in the server directory:
PORT=5000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_super_secret_keyRun the server:
npm startNavigate to the client directory and install dependencies:
cd client
npm installCreate a .env file in the client directory:
VITE_API_URL=http://localhost:8082/apiStart the Vite development server:
npm run dev- After running the frontend, open your browser at http://localhost:5173 (Vite default) to access the app.
- Make sure the backend server is running before using the frontend.
You can try out StockSync using the following demo credentials:
-
Admin Account
📧 Email:admin@demo.com
🔑 Password:admin123 -
Staff Account
📧 Email:staff@demo.com
🔑 Password:staff123
⚠️ Important: These accounts are for testing/demo purposes only.
Do not change the password or modify critical data, and do not use them for production data. All changes may be reset.
- 🌐 Access the App - Open
http://localhost:5173in your browser. - ⚡ Quick Login - Use the Admin or Staff demo buttons on the login screen to auto-fill credentials.
- 🔐 Security Check - Public registration is disabled — only an Admin can add new team members.
- 📊 Dashboard Analytics - View real-time stock distribution and value charts powered by 📊 Recharts.
- 👥 User Management - Navigate to the Users Management tab to view all staff. Try promoting a Staff member to Admin.
- 📦 Product Inventory - Add new products or edit existing stock. When an item falls below its Low Stock Threshold, the UI instantly displays a
⚠️ Low Stock badge. - 📦 Categories - Add new category or edit existing category.
- 🚚 Suppliers - Add new supplier or edit existing supplier.
- 🚫 Permission Enforcement - Log out and sign in as Staff — the Users management tab will no longer appear in the sidebar.
- 👀 View-Only Access - Staff can monitor inventory and update stock levels but are restricted from sensitive administrative settings.
- 🚚 Supplier Management - Navigate to the Suppliers tab.
- 🧨 Test Cascade Delete - Delete a supplier from the list.
- ✅ Verification - Return to the Products page — all products linked to that supplier are automatically removed to maintain data integrity
(handled via Mongoose middleware).
- 🔍 Global Search - Use the table search bar to find products by Name or SKU.
- 🧩 Responsive Filtering - Filter inventory by Category or Supplier or Stock Status (In Stock, Low Stock, Out of Stock) to see the dynamic UI in action.
stocksync/
│
├─ client/ # Frontend built with React + Vite
│ ├─ public/ # Static assets (images, icons, etc.)
│ ├─ src/
│ │ ├─ components/ # Reusable React components
| | ├─ dashboard/ # Dashboard layout
│ │ ├─ pages/ # Page components (Login, Register, Dashboard, Products, Categories, Suppliers, Users Management, Profile)
│ │ ├─ api/ # API calls using Axios
│ │ └─ context/ # React context for global state (auth)
│ └─ .env # Environment variables (VITE_API_URL)
|
├─ server/ # Backend built with Node.js + Express
│ ├─ controllers/ # Handles incoming requests
│ ├─ models/ # Mongoose schemas (User, product, supplier, category)
│ ├─ routes/ # API route definitions
│ ├─ services/ # Business logic for controllers
│ ├─ middleware/ # Authentication & error handling
| └─ .env # Environment variables (PORT, DB URI, JWT secret)
│
└─ README.md # Project documentationHere are the important files in the StockSync project and their purposes:
src/App.jsx– Main React component that wraps all pages and routes.src/main.jsx– Entry point for the React + Vite app.src/components/– Reusable UI components like ProtectedRoute, Sidebar.src/pages/– Individual pages (Login, Register, Dashboard, Products, Categories, Suppliers, Users Management, Profile).src/api/– Handles API calls to the backend using Axios.src/context/– Global state management for auth.
index.js– Entry point for the Express backend server and MongoDB connection setup..env– Stores environment variables likePORT,MONGODB_URI, andJWT_SECRET. .controllers/– Handle incoming requests and interact with services.auth.controller.js– Register/Login, Update Password endpoints.user.controller.js– User profile endpoints.product.controller.js– Product CRUD, status and search logic.category.controller.js– Category CRUD logic.supplier.controller.js– Supplier CRUD logic.report.controller.js– Dashboard stats logic.
models/– Mongoose schemas for User, product, supplier, category.routes/– API endpoint definitions.services/– Business logic separate from controllers.middleware/– JWT authentication and centralized error handling.
README.md– Project documentation..env– Environment variables for backend configuration.
- Secure login using JWT-based authentication
- Protected frontend routes and backend APIs
- Create, view, update, and delete products
- Manage product categories and suppliers
- Stock status is dynamically determined by comparing quantity against a custom lowStockThreshold set per product.
- Automatic stock status updates (In Stock, Low Stock, Out of Stock)
- Deleting a category or supplier automatically removes all related products
- Ensures data consistency and prevents orphan records
- Low-stock threshold tracking
- Visual indicators for inventory status
- Centralized view of products, categories, and suppliers
- Intuitive navigation through sidebar layout
- Admins can create, promote, or deactivate staff accounts.
- Change password securely
- The sidebar is persistent across all pages and includes:
- 📊 Dashboard
- 📦 Products
- 🗂️ Categories
- 🚚 Suppliers
- 👥 User Management
- 👤 Profile
-
🔒 Public Registration Disabled
- New accounts can only be created by an Admin via the User Management panel.
-
🔑 JWT Authentication
- All protected routes require a valid JWT token
-
🛡️ Protected Routes
- Unauthorized users cannot access inventory APIs or dashboard pages
-
🧹 Data Integrity
- Cascade delete logic ensures related data is removed safely
- Eliminates orphaned documents in the database
The application follows a client–server architecture:
- The React frontend handles user interactions and UI rendering
- The Node.js + Express backend exposes RESTful APIs
- The frontend communicates with the backend via HTTP requests using Axios
- JWT tokens are used to secure API communication
- MongoDB is used as the primary database for persistent storage
This architecture ensures:
- Clear separation of concerns
- Scalability and maintainability
- Secure and efficient data flow between client and server
- User: name, email, password, role
- Product: name, SKU, quantity, price, stock status, low stock threshold, category reference, supplier reference, creator
- Category: name, description, creator
- Supplier: name, contact details, creator
StockSync uses a structured, relational approach within MongoDB to manage inventory data while maintaining strong relationships between products, categories, suppliers, and users.
- 🔁 User ↔ Product – One-to-Many relationship where users can create and manage multiple products.
- 📦 Category ↔ Product – One-to-Many relationship allowing each category to contain multiple products.
- 🚚 Supplier ↔ Product – One-to-Many relationship to link suppliers with their supplied products.
⚠️ Cascade Delete – Deleting a category or supplier automatically removes all related products to maintain data integrity.- 👤 Ownership Rules – Products, categories, and suppliers store a
createdByfield to enforce permission-based updates and deletions.
- 🔔 Real-Time Stock Alerts via in-app notfications or email
- 📊 Advanced Analytics Dashboard
- 👥 Role-Based Access Expansion
- 🧾 Inventory History & Audit Logs
- 📦 Support for CSV/Excel-based Import & Export
- 🌐 Multi-Warehouse Support
This project is licensed under the MIT License. See the LICENSE file for more info.
StockSync was built with ❤️ by Sandeep Mukku
It’s designed to help teams manage inventory, track stock levels, and maintain data consistency through a simple and reliable system.
Thank you for checking out the project! 🙌






