A modern, fullstack inventory management system built with Next.js 14, TypeScript, and MySQL.
- 📊 Dashboard - Overview of inventory statistics and recent transactions
- 📦 Products Management - Full CRUD operations for products
- 📋 Inventory Management - Track stock at multiple locations
- 🔄 Stock Movements - Transfer stock between locations with approval workflow
- 📈 Activity Logs - Track all system activities
- 🔐 Authentication - JWT-based authentication with role-based access control
- 👥 Multi-role Support - Super Admin, Warehouse Manager, Distributor, Sales Agent, Store Manager
- Frontend: Next.js 14, React, TypeScript, Bootstrap 5
- Backend: Laravel 8 (PHP)
- Database: MySQL
- Authentication: Laravel Sanctum (Bearer tokens)
- Node.js 18+ installed
- PHP 8.1+ installed
- Composer installed
- MySQL 8.0+ installed and running
- npm or yarn package manager
-
Navigate to backend directory:
cd backend -
Install PHP dependencies:
composer install
-
Configure environment:
cp .env.example .env php artisan key:generate
-
Edit
.envfile and set your database credentials:DB_DATABASE=inventory_db DB_USERNAME=root DB_PASSWORD=your_mysql_password
-
Run migrations and seed database:
php artisan migrate php artisan db:seed
-
Start Laravel server:
php artisan serve
The API will be available at
http://localhost:8000
-
Return to root directory:
cd .. -
Install dependencies:
npm install
-
Create
.env.localfile in the root directory:NEXT_PUBLIC_API_URL=http://localhost:8000/api
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:3000
After running php artisan db:seed in the backend directory, you can log in with:
- Super Admin:
admin@inventory.com/admin123 - Warehouse Manager:
warehouse@inventory.com/admin123 - Distributor:
distributor@inventory.com/admin123 - Sales Agent:
agent@inventory.com/admin123 - Store Manager:
store@inventory.com/admin123
├── app/ # Next.js app directory
│ ├── dashboard/ # Dashboard page
│ ├── login/ # Login page
│ ├── products/ # Products page
│ ├── inventory/ # Inventory page
│ ├── movements/ # Movements page
│ └── activity-log/ # Activity log page
├── backend/ # Laravel backend
│ ├── app/Http/Controllers/Api/ # API controllers
│ ├── app/Models/ # Eloquent models
│ ├── database/migrations/ # Database migrations
│ └── routes/api.php # API routes
├── components/ # React components
│ └── Layout.tsx # Main layout component
├── lib/ # Utility libraries
│ └── api.ts # API client for Laravel backend
└── js/ # Legacy JavaScript files (for HTML pages)
All API endpoints are provided by the Laravel backend at http://localhost:8000/api. See BACKEND_API.md for complete API documentation.
- Authentication:
POST /api/auth/login,GET /api/auth/me - Products:
GET /api/products,POST /api/products,GET /api/products/{id},PUT /api/products/{id},DELETE /api/products/{id} - Inventory:
GET /api/inventory,POST /api/inventory,POST /api/inventory/initial-stock - Movements:
GET /api/movements,POST /api/movements,GET /api/movements/{id},PUT /api/movements/{id} - Locations:
GET /api/locations - Users:
GET /api/users,POST /api/users,GET /api/users/{id},PUT /api/users/{id},DELETE /api/users/{id}(admin only) - Activity Logs:
GET /api/activity-logs,POST /api/activity-logs - Dashboard:
GET /api/dashboard/stats
The database includes the following main tables:
users- User accountslocations- Warehouse, distributor, sales agent, and store locationsproducts- Product cataloginventory- Stock levels at each locationmovements- Stock transfer requestsmovement_items- Items in each movementmovement_activities- Activity log for movementsactivity_logs- General activity tracking
The system enforces a location hierarchy:
- Warehouse → can send to Distributor
- Distributor → can send to Sales Agent
- Sales Agent → can send to Store
- Store → cannot send to anyone
npm run devnpm run build
npm startnpm run lintFor Windows users, use the provided setup scripts:
-
Setup Laravel backend:
cd backend .\setup.ps1
Or use:
setup.bat -
Start Laravel server:
.\start-server.ps1Or use:
start-server.bat -
Setup Next.js frontend (in root directory):
npm install # Create .env.local with NEXT_PUBLIC_API_URL=http://localhost:8000/api npm run dev
- Change the
APP_KEYin Laravel.envfile for production - Use strong passwords for MySQL database
- Set
APP_ENV=productionandAPP_DEBUG=falsein Laravel.envfor production - Implement rate limiting for API endpoints in production
- Use HTTPS in production
- Regularly update dependencies
MIT License - feel free to use this project for your own purposes.
For issues or questions, please open an issue in the repository.