A modular, multi-tenant backend API boilerplate built with Laravel 9, designed to accelerate development of SaaS and multi-tenant applications. This repository includes boilerplate code for managing domains, products, categories, offers, inventory, and more, with robust support for tenant data isolation and AWS S3 integration.
- Multi-Tenancy:
- Isolates data and resources per tenant using stancl/tenancy.
- Dynamically creates and manages AWS S3 buckets for each tenant.
- Domain Management:
- Seamless CRUD for domains, with support for primary and fallback domains.
- Product & Inventory Management:
- Modular services for products, categories, inventory, and deductibles.
- Offer Management:
- Flexible offers, promo codes, and voucher management, including product associations.
- Role & Permission System:
- Role-based access control using spatie/laravel-permission.
- RESTful API Endpoints:
- Organized under
/apiwith versioning support. - Authentication via Laravel Sanctum.
- Organized under
- Event-Driven:
- Decoupled logic using Laravel Events for handling entity lifecycle.
- Seeders and Boilerplate Data:
- Quick start with seeders for roles, permissions, and sample posts.
- PHP 8.0+
- Composer
- Laravel 9.x
- MySQL or PostgreSQL or SQLite
- AWS account (for S3 integration)
- Redis (optional, for queues/cache)
-
Clone the repository
git clone https://github.com/PrashantRatanparikhe/Laravel-9-Backend-APIs.git cd Laravel-9-Backend-APIs -
Install dependencies
composer install
-
Copy
.envand configurecp .env.example .env # Edit .env and set DB, AWS, and tenancy configs -
Generate application key
php artisan key:generate
-
Run migrations and seeders
php artisan migrate --seed
-
Serve the application
php artisan serve
- All endpoints are prefixed with
/api. - Authentication uses Laravel Sanctum.
- Example endpoints:
POST /api/loginGET /api/domainPOST /api/productGET /api/inventoryPOST /api/offer
- Each tenant gets a dedicated AWS S3 bucket for file storage.
- Tenancy is initialized by request data.
- Tenant-specific config is handled via bootstrappers (
TenancyBootstrappers).
- Roles:
superadmin,admin,staff - Permissions defined in
database/seeders/RoleSeeder.php
app/Services/- Business logic for main entities.app/Models/- Eloquent models.app/Requests/- Form request validation.database/seeders/- Seeder classes for roles, tenants, posts, etc.routes/api.php- API routes.
Contributions, issues, and feature requests are welcome. Please open an issue or submit a pull request.
As always, don't forget to ship fast 😎. We hope this boilerplate saves you a lot of development time and lets you get to production much faster.