A production-ready Laravel-based multi-organization ERP core microservice with JWT authentication, role-based access control (RBAC), modular architecture, and comprehensive user management.
- π’ Multi-Tenancy - Users can belong to multiple organizations with different roles
- π JWT Authentication - Secure token-based authentication with embedded permissions
- π₯ RBAC System - Flexible role and permission management scoped per organization
- π UUID Organization IDs - Secure, non-enumerable organization identifiers
- π¦ Module Management - Modular ERP architecture with 68+ Odoo-style modules
- π― Selective Module Access - Organizations can enable/disable specific modules
- βοΈ Module Configuration - Per-organization settings, limits, and licensing
- π€ Enhanced User Profiles - 20+ profile fields with avatar upload support
- ποΈ Soft Deletes - Safe data retention
- π API-First Design - RESTful API with complete documentation
- π³ Docker Support - Ready-to-deploy containers
- π Comprehensive Seeding - Demo data for quick development
- π§ Email Verification - Automated email verification for new registrations
- π Password Reset - Secure forgot password flow with email tokens
- π Two-Factor Authentication (2FA) - TOTP-based 2FA with QR codes and recovery codes
- π¦ Rate Limiting - Intelligent rate limiting on authentication endpoints
- π‘οΈ Security Best Practices - Password hashing, token expiration, CORS support
- β Comprehensive Test Suite - Unit and feature tests for all critical functionality
- π§ͺ Test Coverage - Authentication, RBAC, organizations, email, 2FA, password reset
- π Model Factories - Easy test data generation
# Clone the repository
git clone https://github.com/lavaliteerp/core.git
cd core
# Install dependencies
composer install
# Setup environment
cp .env.example .env
php artisan key:generate
php artisan jwt:secret
# Run migrations and seed demo data
php artisan migrate:fresh --seed --seeder=MultiOrganizationSeeder
# Start development server
php artisan serveVisit http://localhost:8000 and use the demo credentials to login.
# Clone the repository
git clone https://github.com/lavaliteerp/core.git
cd core
# Copy environment file
cp .env.example .env
# Build and start containers
docker-compose up -d
# Run migrations inside container
docker-compose exec app php artisan migrate:fresh --seed --seeder=MultiOrganizationSeeder
# Generate keys inside container
docker-compose exec app php artisan key:generate
docker-compose exec app php artisan jwt:secretApplication will be available at http://localhost:8000
- PHP 8.2 or higher
- Composer
- MySQL 8.0+ / PostgreSQL 16+ / SQLite
- Redis (optional, for caching and queues)
- Node.js and npm (for frontend assets)
-
Install PHP Dependencies
composer install
-
Environment Configuration
cp .env.example .env
Update
.envwith your database credentials:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=lavalite_core DB_USERNAME=your_username DB_PASSWORD=your_password
-
Generate Application Keys
php artisan key:generate php artisan jwt:secret
-
Run Database Migrations
php artisan migrate
-
Seed Demo Data (Optional)
php artisan db:seed --class=MultiOrganizationSeeder
-
Install Frontend Dependencies (Optional)
npm install npm run build
-
Start Development Server
php artisan serve
The project includes a complete Docker setup with MySQL, Redis, and Nginx.
Start all services:
docker-compose up -dView logs:
docker-compose logs -f appStop services:
docker-compose downRebuild containers:
docker-compose build --no-cache
docker-compose up -d| Service | Port | Description |
|---|---|---|
| app | 8000 | Laravel application with Nginx + PHP-FPM |
| db | 3306 | MySQL 8.0 database |
| redis | 6379 | Redis for caching and queues |
| postgres | 5432 | PostgreSQL (optional, use profile) |
Start with PostgreSQL instead of MySQL:
docker-compose --profile postgres up -dStart with queue worker:
docker-compose --profile queue up -dStart with scheduler:
docker-compose --profile scheduler up -dFor production, use the optimized Dockerfile:
# Build production image
docker build -t lavalite/erp:latest .
# Run container
docker run -d \
--name lavalite-erp \
-p 80:80 \
-e APP_ENV=production \
-e APP_DEBUG=false \
-e DB_HOST=your-db-host \
-e DB_DATABASE=your-db-name \
-e DB_USERNAME=your-db-user \
-e DB_PASSWORD=your-db-password \
lavalite/erp:latest| Method | Endpoint | Description |
|---|---|---|
| POST | /api/register |
Register new user |
| POST | /api/login |
Login with email/password |
| POST | /api/logout |
Logout and invalidate token |
| GET | /api/user |
Get current authenticated user |
| POST | /api/switch-organization |
Switch to different organization |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/me |
Get complete user profile |
| PUT | /api/profile |
Update profile information |
| POST | /api/profile/avatar |
Upload avatar image |
| DELETE | /api/profile/avatar |
Delete avatar |
| PUT | /api/profile/password |
Change password |
| PUT | /api/profile/preferences |
Update user preferences |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/organizations |
List user's organizations |
| POST | /api/organizations |
Create new organization |
| GET | /api/organizations/{id} |
Get organization details |
| PUT | /api/organizations/{id} |
Update organization |
| POST | /api/organizations/{id}/add-user |
Add user to organization |
| POST | /api/organizations/{id}/remove-user |
Remove user from organization |
All role and permission endpoints require admin privileges and organization context via X-Organization-ID header.
Complete API documentation: docs/API_REFERENCE.md
Postman Collection: postman_collection.json
Users βββ¬ββ Organization A (Admin) βββ¬ββ Roles βββ¬ββ Permissions
β β βββ manage-users
β βββ Users
β
βββ Organization B (User) ββββ¬ββ Roles βββ¬ββ Permissions
β βββ view-posts
βββ Users
- users - User accounts with 20+ profile fields
- organizations - Organizations with UUID primary keys
- roles - Organization-scoped roles
- permissions - Organization-scoped permissions
- organization_user - User-organization relationships
- role_user - User-role assignments (per organization)
- permission_role - Role-permission assignments
- permission_user - Direct user permissions
{
"sub": 1,
"organization_id": "019a77f4-54f3-72c3-beec-c8b1a59dbc23",
"roles": ["admin"],
"permissions": ["manage-users", "manage-roles", "..."],
"exp": 1699876543
}After seeding the database, you can use these credentials:
| Password | Organizations | Role | |
|---|---|---|---|
| [email protected] | password | Acme (Admin), TechStart (Admin) | Global Admin |
| [email protected] | password | Acme (Super Admin), TechStart (Super Admin) | Super Admin |
| [email protected] | password | Acme (User Admin), TechStart (User Admin) | User Admin |
| [email protected] | password | Acme (User), TechStart (User) | User |
| [email protected] | password | Acme (Client), TechStart (Client) | Client |
curl -X POST http://localhost:8000/api/login \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "password"
}'- Getting Started Guide - Installation and setup
- Authentication Guide - JWT auth and multi-organization login
- API Reference - Complete endpoint documentation
- User Management - Profile management features
- Multi-Organization Guide - Organization and RBAC management
- Microservice Skeleton Guide - Create new microservices based on this architecture
- Postman Collection - Ready-to-use API requests
- Framework: Laravel 12.x
- Authentication: Laravel Sanctum 4.2 + JWT Auth 2.2
- Database: MySQL 8.0 / PostgreSQL 16 / SQLite
- Cache/Queue: Redis 7
- PHP: 8.2+
- Server: Nginx + PHP-FPM
- Container: Docker + Docker Compose
# Run all tests
php artisan test
# Run with coverage
php artisan test --coverage
# Run specific test suite
php artisan test --testsuite=FeatureWe welcome contributions! Please see CONTRIBUTING.md for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CHANGELOG.md for version history.
This project is open-sourced software licensed under the MIT license.
- Built with Laravel
- JWT authentication by tymon/jwt-auth
- Inspired by modern multi-organization SaaS architectures
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
Made with β€οΈ by the Lavalite Team