A high-performance, scalable REST API for managing e-commerce operations. Built with modern Laravel architecture (Actions, Repositories, Enums) and strict typing.
- Inventory Management: Real-time stock tracking with pessimistic locking to prevent race conditions.
- Product Search: Integrated database search (Searchable by Name, Description, or SKU).
- Order Processing:
- Atomic Database Transactions.
- Automatic Invoice PDF Generation (Queued).
- Smart Inventory Rollback on Cancellation.
- Security: JWT Authentication with Role-Based Access Control (RBAC).
- Framework: Laravel 12 (PHP 8.3)
- Database: MySQL 8
- Auth: PHP-Open-Source-Saver JWT Auth
- Queue: Database Driver (Async Jobs)
- PDF: DomPDF
- PHP 8.2 or higher (with
sodiumandfileinfoextensions enabled) - Composer
- MySQL
# Clone Repository
git clone <your-repo-url>
cd project-name
# Install Dependencies
composer install
#Build assets
npm install
npm run build
# Environment Setup
cp .env.example .env
php artisan key:generate
# JWT Setup
php artisan jwt:secretConfigure your .env file with database credentials, then run:
php artisan migrate:fresh --seedYou need two terminals open: Terminal 1 (API Server):
php artisan queue:work- Header:
Authorization: Bearer <token>
| Method | Endpoint | Description | Body |
|---|---|---|---|
| POST | /api/v1/auth/login |
Login | {email, password} |
| POST | /api/v1/auth/register |
Register | {name, email, password, role} |
| Method | Endpoint | Role | Description |
|---|---|---|---|
| GET | /api/v1/products?q=nike |
Public | Search products |
| POST | /api/v1/products |
Vendor | Create product {name, variants: [...]} |
| Method | Endpoint | Role | Description |
|---|---|---|---|
| POST | /api/v1/orders |
Customer | Place order {items: [{variant_id, qty}]} |
| PATCH | /api/v1/orders/{id}/cancel |
Customer | Cancel & Restore Stock |
| GET | /api/v1/my-orders |
Customer | View Order History |
This project uses PHPUnit for feature testing.
Run Tests:
php artisan testNow you can login with these credentials in Postman:
Role: Customer (For Buying)
- Email:
[email protected] - Password:
password
Role: Vendor (For creating more products)
- Email:
[email protected] - Password:
password
Role: Admin
- Email:
[email protected] - Password:
password
- Name: Firoz Ebna Jobaier
- Email: [email protected]