Skip to content

dawood125/inventory-management-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ Inventory Management System - Backend

RESTful API for inventory management built with Laravel 11 using modular architecture and event-driven design.

Laravel PHP MySQL


✨ Features

πŸ—οΈ Architecture

  • Modular Design - Separated modules for scalability
  • Event-Driven - Laravel Events and Listeners for loose coupling
  • RESTful API - Clean and consistent API endpoints

πŸ” Authentication

  • Laravel Sanctum for API tokens
  • Role-based access (Admin, Manager, Staff)
  • Password reset functionality

πŸ“¦ Modules

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

πŸ› οΈ Tech Stack

Technology Purpose
Laravel 11 PHP Framework
PHP 8.2+ Programming Language
MySQL 8.0 Database
Laravel Sanctum API Authentication

πŸ“ Project Structure

app/
β”œβ”€β”€ Models/
β”‚   └── User.php
β”‚
β”œβ”€β”€ Modules/
β”‚   β”œβ”€β”€ Auth/
β”‚   β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   β”œβ”€β”€ Requests/
β”‚   β”‚   └── Routes/
β”‚   β”‚
β”‚   β”œβ”€β”€ Product/
β”‚   β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   β”œβ”€β”€ Events/
β”‚   β”‚   └── Routes/
β”‚   β”‚
β”‚   β”œβ”€β”€ Category/
β”‚   β”œβ”€β”€ Supplier/
β”‚   β”œβ”€β”€ Order/
β”‚   β”œβ”€β”€ Stock/
β”‚   └── Report/
β”‚
└── Providers/
    └── ModuleServiceProvider.php

πŸ”Œ API Endpoints

Authentication

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

Products

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

Categories

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

Suppliers

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

Orders

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

Stock Movements

Method Endpoint Description
GET /api/stock-movements List movements
POST /api/stock-movements Create movement

Reports

Method Endpoint Description
GET /api/reports/dashboard Dashboard stats
GET /api/reports/inventory Inventory report
GET /api/reports/sales Sales report

πŸš€ Getting Started

Prerequisites

  • PHP 8.2 or higher
  • Composer
  • MySQL 8.0
  • XAMPP / Laragon

Installation

# 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

πŸ§ͺ API Testing

Using Postman

  1. Set base URL: http://localhost:8000/api
  2. For authenticated routes, add header:
    Authorization: Bearer {your-token}
    

Example: Login Request

POST /api/login
Content-Type: application/json

{
  "email": "admin@example.com",
  "password": "password123"
}

πŸ”— Frontend Repository

This API is designed to work with the React frontend.

Frontend Repository: inventory-management-frontend


πŸ‘¨β€πŸ’» Author

Dawood Ahmed

About

RESTful API for inventory management built with Laravel 11 using modular architecture and event-driven design. Features authentication, product management, order processing, and stock tracking.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages