API Backend untuk sistem ERP PT Adiwarna Alam Raya menggunakan Laravel 12 dengan arsitektur API-first.
- Overview
- Technology Stack
- System Requirements
- Installation
- Environment Configuration
- Database Setup
- API Authentication
- Running the Application
- API Documentation
- Project Structure
Adiwarna API adalah backend system untuk mengelola operasional PT Adiwarna Alam Raya, meliputi:
- User Management - Manajemen user dengan role-based access (Admin, Teknisi, User)
- Customer & Employee Management - Master data pelanggan dan karyawan
- Sales Management - Quotations dan Purchase Orders
- Operations Management - Work Assignments, Daily Activities, Schedules, Work Orders
- Document Management - Document Transmittals, Purchase Requisitions, Material Receiving Reports, Delivery Notes
- Equipment Management - General Equipment dan Project Equipment
- Project Tracking - Track Records dan Operational Records
- Payroll System - Comprehensive payroll management dengan timesheet dan slip generation
- Company Information - About/Company profile management
- Framework: Laravel 12.x
- PHP: 8.2+
- Database: MySQL 8.0+
- Authentication: Laravel Sanctum (Token-based)
- Architecture: Repository Pattern + Service Layer
- API: RESTful API with JSON responses
- Validation: Form Request Validation with Enum Support
- Authorization: Policy-based Authorization
- PHP >= 8.2
- Composer >= 2.0
- MySQL >= 8.0 atau MariaDB >= 10.3
- Node.js >= 18.x (untuk asset compilation, optional)
- Git
git clone https://github.com/dzuura/adiwarna-api.git
cd adiwarna-apicomposer installcp .env.example .envphp artisan key:generateEdit file .env dan sesuaikan dengan environment Anda:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=adiwarna_db
DB_USERNAME=root
DB_PASSWORD=your_passwordAPP_NAME="Adiwarna API"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1
SESSION_DRIVER=cookieBuat database MySQL:
CREATE DATABASE adiwarna_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;Jalankan semua migrations untuk membuat struktur database:
php artisan migrateMigrations akan membuat tabel untuk:
- Users & Authentication - User management dengan role-based access
- Customers & Customer Locations - Master data pelanggan
- Employees - Master data karyawan
- Quotations - Penawaran dengan items, adiwarnas, clients
- Purchase Orders - Purchase order dengan items
- Work Assignments & Daily Activities - Penugasan kerja dan aktivitas harian
- Schedules & Work Orders - Jadwal dan work order
- Document Transmittals - Transmittal dokumen
- Purchase Requisitions - Permintaan pembelian dengan enum supplier/routing dan position fields
- Material Receiving Reports - Laporan penerimaan material dengan enum remarks dan separated PO fields
- Delivery Notes - Surat jalan dengan customer relationships dan enum status
- Equipment - General & Project equipment
- Track Records & Operational Records - Tracking dan operational records
- Payroll System - Projects dan periods untuk payroll
- Company Information - About/Company profile
Untuk development, Anda bisa seed database dengan sample data:
php artisan db:seedIni akan membuat:
- 1 Admin user (admin@adiwarna.com / password)
- 2 Teknisi users
- 3 Regular users
- 10 Customers dengan locations
- 15 Employees
- Sample data untuk semua modul
Default Admin Credentials:
- Email:
admin@adiwarna.com - Password:
password
API menggunakan Laravel Sanctum untuk token-based authentication.
POST /api/v1/auth/login
Content-Type: application/json
{
"email": "admin@adiwarna.com",
"password": "password"
}Response:
{
"success": true,
"message": "Login successful",
"data": {
"user": {
"id": 1,
"name": "Admin User",
"email": "admin@adiwarna.com",
"usertype": "admin"
},
"token": "1|abc123..."
}
}Gunakan token di header untuk semua protected endpoints:
GET /api/v1/users
Authorization: Bearer 1|abc123...POST /api/v1/auth/logout
Authorization: Bearer 1|abc123...php artisan serveAPI akan berjalan di http://localhost:8000
Gunakan tools seperti:
- Postman
- Insomnia
- cURL
- Thunder Client (VS Code extension)
http://localhost:8000/api/v1
POST /auth/login- LoginPOST /auth/logout- LogoutGET /auth/me- Get current user
GET /users- List usersPOST /users- Create userGET /users/{id}- Get userPUT /users/{id}- Update userDELETE /users/{id}- Delete user
GET /customers- List customersPOST /customers- Create customerGET /customers/{id}- Get customerPUT /customers/{id}- Update customerDELETE /customers/{id}- Delete customer
GET /employees- List employeesPOST /employees- Create employeeGET /employees/{id}- Get employeePUT /employees/{id}- Update employeeDELETE /employees/{id}- Delete employee
GET /quotations- List quotationsPOST /quotations- Create quotation (with items)GET /quotations/{id}- Get quotationPUT /quotations/{id}- Update quotationDELETE /quotations/{id}- Delete quotation
GET /purchase-orders- List purchase ordersPOST /purchase-orders- Create PO (with items)GET /purchase-orders/{id}- Get POPUT /purchase-orders/{id}- Update PODELETE /purchase-orders/{id}- Delete PO
GET /purchase-requisitions- List purchase requisitionsPOST /purchase-requisitions- Create PR (with items, supplier/routing validation)GET /purchase-requisitions/{id}- Get PRPUT /purchase-requisitions/{id}- Update PRDELETE /purchase-requisitions/{id}- Delete PR
GET /material-receiving-reports- List material receiving reportsPOST /material-receiving-reports- Create MRR (with items, enum remarks)GET /material-receiving-reports/{id}- Get MRRPUT /material-receiving-reports/{id}- Update MRRDELETE /material-receiving-reports/{id}- Delete MRR
GET /delivery-notes- List delivery notesPOST /delivery-notes- Create delivery note (with items, customer relationships)GET /delivery-notes/{id}- Get delivery notePUT /delivery-notes/{id}- Update delivery noteDELETE /delivery-notes/{id}- Delete delivery note
GET /work-assignments- List work assignmentsPOST /work-assignments- Create work assignmentGET /work-assignments/{id}- Get work assignmentPUT /work-assignments/{id}- Update work assignmentDELETE /work-assignments/{id}- Delete work assignment
GET /daily-activities- List daily activitiesPOST /daily-activities- Create daily activityGET /daily-activities/{id}- Get daily activityPUT /daily-activities/{id}- Update daily activityDELETE /daily-activities/{id}- Delete daily activity
GET /payroll/projects- List payroll projectsPOST /payroll/projects- Create payroll projectGET /payroll/projects/{id}- Get payroll projectPUT /payroll/projects/{id}- Update payroll projectDELETE /payroll/projects/{id}- Delete payroll projectGET /payroll/periods- List payroll periodsPOST /payroll/periods- Create payroll periodGET /payroll/periods/{id}- Get payroll periodPUT /payroll/periods/{id}- Update payroll periodDELETE /payroll/periods/{id}- Delete payroll period
Untuk dokumentasi lengkap, lihat Postman Collection
adiwarna-api/
βββ app/
β βββ Contracts/
β β βββ Repositories/ # Repository interfaces
β βββ Enums/ # PHP Enums (UserType, Status, etc.)
β βββ Http/
β β βββ Controllers/Api/V1/ # API Controllers
β β βββ Requests/Api/V1/ # Form Request Validation
β β βββ Resources/V1/ # API Resources
β βββ Models/ # Eloquent Models
β βββ Policies/ # Authorization Policies
β βββ Repositories/ # Repository Implementations
β βββ Services/ # Business Logic Services
βββ database/
β βββ factories/ # Model Factories
β βββ migrations/ # Database Migrations
β βββ seeders/ # Database Seeders
βββ routes/
β βββ api.php # API Routes
βββ docs/ # Documentation
β βββ postman/ # Postman Collection
β βββ API.md # API Documentation
βββ README.md
Repository Pattern + Service Layer:
Controller β Service β Repository β Model β Database
- Controllers: Handle HTTP requests/responses
- Services: Business logic dan transactions
- Repositories: Data access layer
- Models: Eloquent ORM models
- Policies: Authorization logic
System menggunakan role-based access control dengan 3 roles:
- Full access ke semua modul
- User management
- Semua CRUD operations
- View dan create Daily Activities (own only)
- View Work Assignments
- Limited access
- Minimal access
- View only untuk assigned data
php artisan testphp artisan test --testsuite=Feature
php artisan test --testsuite=Unitphp artisan cache:clear
php artisan config:clear
php artisan route:clearphp artisan config:cache
php artisan route:cache
php artisan view:cache# Fresh migration (drop all tables and re-migrate)
php artisan migrate:fresh
# Fresh migration with seeding
php artisan migrate:fresh --seed
# Rollback last migration
php artisan migrate:rollback
# Check migration status
php artisan migrate:status- Create feature branch
- Make changes
- Write tests
- Submit pull request
Proprietary - PT Adiwarna Alam Raya
Untuk pertanyaan atau issues, hubungi tim development.
- Initial release
- Full CRUD untuk semua modul
- Authentication dengan Sanctum
- Role-based authorization
- Comprehensive API documentation