A modern, full-stack inventory management system with role-based access control, built with React and Node.js.
- Secure JWT-based authentication
- Role-based access control (Admin & Staff roles)
- Protected routes and API endpoints
- Session management
- Create, Read, Update, Delete (CRUD) operations for inventory items
- Real-time inventory tracking
- Low stock alerts and warnings
- Advanced filtering and search capabilities
- Price range filters
- User account creation and management
- Role assignment and modification
- Password reset functionality
- User activity tracking
- Secure user deletion
- Dark theme with glass morphism effects
- Responsive design for all devices
- Intuitive navigation with React Router
- Real-time visual feedback
- Icon-based interface using React Icons
- Interactive Swagger UI documentation
- Complete API endpoint reference
- Request/response examples
- Built-in API testing interface
- React 19.1.1 - Modern UI library
- React Router DOM 7.9.3 - Client-side routing
- React Icons 5.5.0 - Icon library
- Axios - HTTP client for API calls
- CSS3 - Custom styling with glass morphism effects
- Node.js - JavaScript runtime
- Express 4.18.2 - Web application framework
- Sequelize 6.35.2 - ORM for database management
- MySQL2 - Database driver
- JWT (jsonwebtoken 9.0.2) - Authentication tokens
- bcryptjs 2.4.3 - Password hashing
- Swagger - API documentation
- Nodemon - Auto-restart development server
- CORS - Cross-origin resource sharing
- dotenv - Environment variable management
Invex/
βββ backend/
β βββ config/
β β βββ database.js # Database configuration
β β βββ swagger.js # Swagger/API documentation config
β βββ controllers/
β β βββ authController.js # Authentication logic
β β βββ itemController.js # Inventory item operations
β β βββ userController.js # User management operations
β βββ middleware/
β β βββ auth.js # JWT authentication middleware
β β βββ roleCheck.js # Role-based authorization
β βββ models/
β β βββ index.js # Model exports
β β βββ Item.js # Inventory item model
β β βββ User.js # User model
β βββ routes/
β β βββ authRoutes.js # Authentication endpoints
β β βββ itemRoutes.js # Inventory endpoints
β β βββ userRoutes.js # User management endpoints
β βββ utils/
β β βββ generateToken.js # JWT token generation
β β βββ hashPassword.js # Password hashing utilities
β β βββ seedAdmin.js # Create admin user
β β βββ seedStaff.js # Create staff user
β β βββ seedItems.js # Seed sample inventory
β βββ .env # Environment variables
β βββ .gitignore
β βββ package.json
β βββ server.js # Express server entry point
βββ frontend/
β βββ public/
β β βββ favicon.ico
β β βββ index.html
β βββ src/
β β βββ components/
β β β βββ Icons.js # Icon component exports
β β β βββ Navbar.js # Navigation bar component
β β βββ context/
β β β βββ AuthContext.js # Authentication context
β β βββ pages/
β β β βββ Dashboard.js # User dashboard
β β β βββ ErrorPages.js # 403/404 error pages
β β β βββ Forbidden.js # Access denied page
β β β βββ Items.js # Inventory management
β β β βββ Login.js # Login page
β β β βββ NotFound.js # 404 page
β β β βββ Users.js # User management (Admin)
β β βββ services/
β β β βββ api.js # Axios instance & interceptors
β β βββ theme/
β β β βββ dark-theme.css # Dark theme styles
β β βββ App.css # Global app styles
β β βββ App.js # Main app component
β β βββ index.css # Base styles
β β βββ index.js # React entry point
β β βββ reportWebVitals.js # Performance monitoring
β βββ .gitignore
β βββ package.json
β βββ README.md
βββ README.md # This file
- Node.js (v16 or higher)
- MySQL (v5.7 or higher)
- npm or yarn package manager
- Clone the repository
git clone https://github.com/yourusername/invex.git
cd invex- Setup Backend
cd backend
npm installCreate a .env file in the backend directory:
# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=invex_db
DB_DIALECT=mysql
# JWT Configuration
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
# Server Configuration
PORT=5000
NODE_ENV=development- Setup Database
Create the MySQL database:
CREATE DATABASE invex_db;The application will automatically sync database tables on startup.
- Seed Initial Data (Optional)
Create default admin user:
npm run seed:adminCreate default staff user:
npm run seed:staffSeed sample inventory items:
npm run seed:items- Setup Frontend
cd ../frontend
npm install- Start Backend Server
cd backend
npm start # Production mode
# or
npm run dev # Development mode with nodemonBackend will run on: http://localhost:5000
API Documentation: http://localhost:5000/api-docs
- Start Frontend Development Server
cd frontend
npm startFrontend will run on: http://localhost:3000
After running the seed scripts:
Admin Account:
- Username:
admin - Password:
admin123 - Access: Full system access
Staff Account:
- Username:
staff - Password:
staff123 - Access: View items, update quantities only
http://localhost:5000/api
POST /api/auth/register
Content-Type: application/json
Authorization: Bearer <admin_token>
{
"username": "newuser",
"password": "password123",
"role": "staff"
}POST /api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "admin123"
}Response:
{
"success": true,
"message": "Login successful",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"username": "admin",
"role": "admin"
}
}
}GET /api/users
Authorization: Bearer <admin_token>PUT /api/users/:id/role
Authorization: Bearer <admin_token>
Content-Type: application/json
{
"role": "admin"
}PUT /api/users/:id/password
Authorization: Bearer <admin_token>
Content-Type: application/json
{
"newPassword": "newpassword123"
}DELETE /api/users/:id
Authorization: Bearer <admin_token>GET /api/items
Authorization: Bearer <token>Query Parameters:
search- Search by name or SKUminPrice- Minimum price filtermaxPrice- Maximum price filter
POST /api/items
Authorization: Bearer <admin_token>
Content-Type: application/json
{
"name": "Product Name",
"sku": "SKU123",
"description": "Product description",
"quantity": 100,
"price": 29.99,
"lowStockThreshold": 10
}PUT /api/items/:id
Authorization: Bearer <admin_token>
Content-Type: application/json
{
"name": "Updated Name",
"quantity": 150,
"price": 34.99
}DELETE /api/items/:id
Authorization: Bearer <admin_token>Visit http://localhost:5000/api-docs for interactive Swagger UI documentation where you can:
- View all available endpoints
- See request/response schemas
- Test API calls directly from the browser
- View authentication requirements
- Background:
#080f25- Deep navy blue - Card/Panel:
#101935- Dark blue with glass effect - Accent/Primary:
#6c72ff- Vibrant purple - Text Primary:
#ffffff- Pure white - Text Muted:
#8892a6- Light gray - Success:
#4ade80- Green - Danger:
#ff6b6b- Red - Warning:
#fbbf24- Amber
The UI features a modern glass morphism design with:
backdrop-filter: blur(20px)for frosted glass effect- Semi-transparent backgrounds with rgba colors
- Subtle borders and shadows
- Smooth transitions and hover effects
- Password Hashing: All passwords are hashed using bcrypt (10 salt rounds)
- JWT Authentication: Secure token-based authentication
- Role-Based Access Control: Separate permissions for Admin and Staff
- Protected Routes: Frontend route guards
- API Middleware: Backend endpoint protection
- SQL Injection Prevention: Sequelize ORM with parameterized queries
- CORS Configuration: Cross-origin request handling
β
View all inventory items
β
Create new items
β
Update item details
β
Delete items
β
Manage users (create, edit, delete)
β
Reset user passwords
β
Assign user roles
β
Access all system features
β
View all inventory items
β
Update item quantities
β
Search and filter items
β Cannot create/delete items
β Cannot manage users
β Cannot access user management page
Backend:
npm start # Start production server
npm run dev # Start with nodemon (auto-reload)
npm run seed:admin # Create admin user
npm run seed:staff # Create staff user
npm run seed:items # Seed inventory itemsFrontend:
npm start # Start development server
npm run build # Create production build
npm test # Run testsCreate a .env file in the backend directory with these variables:
# Database
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=invex_db
DB_DIALECT=mysql
# JWT
JWT_SECRET=your_secret_key_min_32_characters_long
# Server
PORT=5000
NODE_ENV=development- Ensure MySQL is running
- Check database credentials in
.env - Verify port 5000 is not in use
- Run
npm installto ensure dependencies are installed
- Verify backend is running on port 5000
- Check CORS configuration in
backend/server.js - Ensure API base URL in
frontend/src/services/api.jsis correct
- Delete and recreate the database
- Check Sequelize model definitions
- Review server.js sync configuration
- Verify user exists (run seed scripts)
- Check password format (min 6 characters)
- Review JWT_SECRET in
.env - Check browser console and network tab
ISC License - feel free to use this project for learning and development.
Contributions, issues, and feature requests are welcome!
For questions or support, please open an issue in the repository.
Built with β€οΈ using React and Node.js