Skip to content

Pramudi02/Invex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Invex - Inventory Management System

A modern, full-stack inventory management system with role-based access control, built with React and Node.js.

✨ Features

πŸ” Authentication & Authorization

  • Secure JWT-based authentication
  • Role-based access control (Admin & Staff roles)
  • Protected routes and API endpoints
  • Session management

πŸ“¦ Inventory 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 Management (Admin Only)

  • User account creation and management
  • Role assignment and modification
  • Password reset functionality
  • User activity tracking
  • Secure user deletion

🎨 Modern UI/UX

  • 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

πŸ“š API Documentation

  • Interactive Swagger UI documentation
  • Complete API endpoint reference
  • Request/response examples
  • Built-in API testing interface

πŸ› οΈ Technology Stack

Frontend

  • 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

Backend

  • 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

Development Tools

  • Nodemon - Auto-restart development server
  • CORS - Cross-origin resource sharing
  • dotenv - Environment variable management

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • MySQL (v5.7 or higher)
  • npm or yarn package manager

Installation

  1. Clone the repository
git clone https://github.com/yourusername/invex.git
cd invex
  1. Setup Backend
cd backend
npm install

Create 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
  1. Setup Database

Create the MySQL database:

CREATE DATABASE invex_db;

The application will automatically sync database tables on startup.

  1. Seed Initial Data (Optional)

Create default admin user:

npm run seed:admin

Create default staff user:

npm run seed:staff

Seed sample inventory items:

npm run seed:items
  1. Setup Frontend
cd ../frontend
npm install

Running the Application

  1. Start Backend Server
cd backend
npm start          # Production mode
# or
npm run dev        # Development mode with nodemon

Backend will run on: http://localhost:5000 API Documentation: http://localhost:5000/api-docs

  1. Start Frontend Development Server
cd frontend
npm start

Frontend will run on: http://localhost:3000

Default User Credentials

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

πŸ“– API Documentation

Base URL

http://localhost:5000/api

Authentication Endpoints

Register User (Admin Only)

POST /api/auth/register
Content-Type: application/json
Authorization: Bearer <admin_token>

{
  "username": "newuser",
  "password": "password123",
  "role": "staff"
}

Login

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"
    }
  }
}

User Management Endpoints (Admin Only)

Get All Users

GET /api/users
Authorization: Bearer <admin_token>

Update User Role

PUT /api/users/:id/role
Authorization: Bearer <admin_token>
Content-Type: application/json

{
  "role": "admin"
}

Reset User Password

PUT /api/users/:id/password
Authorization: Bearer <admin_token>
Content-Type: application/json

{
  "newPassword": "newpassword123"
}

Delete User

DELETE /api/users/:id
Authorization: Bearer <admin_token>

Inventory Endpoints

Get All Items

GET /api/items
Authorization: Bearer <token>

Query Parameters:

  • search - Search by name or SKU
  • minPrice - Minimum price filter
  • maxPrice - Maximum price filter

Create Item (Admin Only)

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
}

Update Item (Admin Only)

PUT /api/items/:id
Authorization: Bearer <admin_token>
Content-Type: application/json

{
  "name": "Updated Name",
  "quantity": 150,
  "price": 34.99
}

Delete Item (Admin Only)

DELETE /api/items/:id
Authorization: Bearer <admin_token>

Interactive API Documentation

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

🎨 Design System

Color Palette

  • 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

Glass Morphism Effect

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

πŸ”’ Security Features

  • 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

πŸ‘€ User Roles & Permissions

Admin Role

βœ… 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

Staff Role

βœ… View all inventory items
βœ… Update item quantities
βœ… Search and filter items
❌ Cannot create/delete items
❌ Cannot manage users
❌ Cannot access user management page

πŸ§ͺ Development

Available Scripts

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 items

Frontend:

npm start          # Start development server
npm run build      # Create production build
npm test           # Run tests

Environment Variables

Create 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

πŸ› Troubleshooting

Backend won't start

  • Ensure MySQL is running
  • Check database credentials in .env
  • Verify port 5000 is not in use
  • Run npm install to ensure dependencies are installed

Frontend won't connect to backend

  • Verify backend is running on port 5000
  • Check CORS configuration in backend/server.js
  • Ensure API base URL in frontend/src/services/api.js is correct

Database sync issues

  • Delete and recreate the database
  • Check Sequelize model definitions
  • Review server.js sync configuration

Login issues

  • Verify user exists (run seed scripts)
  • Check password format (min 6 characters)
  • Review JWT_SECRET in .env
  • Check browser console and network tab

πŸ“ License

ISC License - feel free to use this project for learning and development.

🀝 Contributing

Contributions, issues, and feature requests are welcome!

πŸ“§ Contact

For questions or support, please open an issue in the repository.


Built with ❀️ using React and Node.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors