π¦ Inventory Management System - Backend
RESTful API for inventory management built with Laravel 11 using modular architecture and event-driven design.
Modular Design - Separated modules for scalability
Event-Driven - Laravel Events and Listeners for loose coupling
RESTful API - Clean and consistent API endpoints
Laravel Sanctum for API tokens
Role-based access (Admin, Manager, Staff)
Password reset functionality
Module
Description
Auth
User authentication and management
Product
Product CRUD operations
Category
Category management
Supplier
Supplier management
Order
Order processing with events
Stock
Stock movements and tracking
Report
Analytics and reporting
Technology
Purpose
Laravel 11
PHP Framework
PHP 8.2+
Programming Language
MySQL 8.0
Database
Laravel Sanctum
API Authentication
app/
βββ Models/
β βββ User.php
β
βββ Modules/
β βββ Auth/
β β βββ Controllers/
β β βββ Requests/
β β βββ Routes/
β β
β βββ Product/
β β βββ Controllers/
β β βββ Models/
β β βββ Events/
β β βββ Routes/
β β
β βββ Category/
β βββ Supplier/
β βββ Order/
β βββ Stock/
β βββ Report/
β
βββ Providers/
βββ ModuleServiceProvider.php
Method
Endpoint
Description
POST
/api/register
Register new user
POST
/api/login
Login user
POST
/api/logout
Logout user
GET
/api/user
Get current user
Method
Endpoint
Description
GET
/api/products
List all products
POST
/api/products
Create product
GET
/api/products/{id}
Get single product
PUT
/api/products/{id}
Update product
DELETE
/api/products/{id}
Delete product
Method
Endpoint
Description
GET
/api/categories
List all categories
POST
/api/categories
Create category
GET
/api/categories/{id}
Get single category
PUT
/api/categories/{id}
Update category
DELETE
/api/categories/{id}
Delete category
Method
Endpoint
Description
GET
/api/suppliers
List all suppliers
POST
/api/suppliers
Create supplier
GET
/api/suppliers/{id}
Get single supplier
PUT
/api/suppliers/{id}
Update supplier
DELETE
/api/suppliers/{id}
Delete supplier
Method
Endpoint
Description
GET
/api/orders
List all orders
POST
/api/orders
Create order
GET
/api/orders/{id}
Get single order
PUT
/api/orders/{id}
Update order
PATCH
/api/orders/{id}/status
Update status
Method
Endpoint
Description
GET
/api/stock-movements
List movements
POST
/api/stock-movements
Create movement
Method
Endpoint
Description
GET
/api/reports/dashboard
Dashboard stats
GET
/api/reports/inventory
Inventory report
GET
/api/reports/sales
Sales report
PHP 8.2 or higher
Composer
MySQL 8.0
XAMPP / Laragon
# Clone the repository
git clone https://github.com/yourusername/inventory-management-backend.git
# Navigate to project directory
cd inventory-management-backend
# Install dependencies
composer install
# Copy environment file
cp .env.example .env
# Generate application key
php artisan key:generate
# Run migrations
php artisan migrate
# Start development server
php artisan serve
The API will be available at http://localhost:8000
π§ Environment Variables
Update your .env file:
APP_NAME = " Inventory Management"
APP_URL = http://localhost:8000
DB_CONNECTION = mysql
DB_HOST = 127.0.0.1
DB_PORT = 3306
DB_DATABASE = inventory_db
DB_USERNAME = root
DB_PASSWORD =
SANCTUM_STATEFUL_DOMAINS = localhost:5173
π Event-Driven Architecture
When an order is created, events automatically update stock:
Order Created
β
βΌ
OrderCreated Event
β
βΌ
UpdateStockListener
β
βΌ
Stock Updated Automatically
Set base URL: http://localhost:8000/api
For authenticated routes, add header:
Authorization: Bearer {your-token}
POST /api/login
Content-Type: application/json
{
" email" : " admin@example.com" ,
" password" : " password123"
}
This API is designed to work with the React frontend.
Frontend Repository: inventory-management-frontend
Dawood Ahmed