Skip to content

novarentech/adiwarna-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

116 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Adiwarna API - Laravel 12

API Backend untuk sistem ERP PT Adiwarna Alam Raya menggunakan Laravel 12 dengan arsitektur API-first.

πŸ“‹ Table of Contents


🎯 Overview

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

πŸ›  Technology Stack

  • 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

πŸ’» System Requirements

  • PHP >= 8.2
  • Composer >= 2.0
  • MySQL >= 8.0 atau MariaDB >= 10.3
  • Node.js >= 18.x (untuk asset compilation, optional)
  • Git

πŸ“¦ Installation

1. Clone Repository

git clone https://github.com/dzuura/adiwarna-api.git
cd adiwarna-api

2. Install Dependencies

composer install

3. Copy Environment File

cp .env.example .env

4. Generate Application Key

php artisan key:generate

βš™οΈ Environment Configuration

Edit file .env dan sesuaikan dengan environment Anda:

Database Configuration

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=adiwarna_db
DB_USERNAME=root
DB_PASSWORD=your_password

Application Configuration

APP_NAME="Adiwarna API"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000

Sanctum Configuration

SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1
SESSION_DRIVER=cookie

πŸ—„οΈ Database Setup

1. Create Database

Buat database MySQL:

CREATE DATABASE adiwarna_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

2. Run Migrations

Jalankan semua migrations untuk membuat struktur database:

php artisan migrate

Migrations 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

3. Seed Database (Optional)

Untuk development, Anda bisa seed database dengan sample data:

php artisan db:seed

Ini 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 Authentication

API menggunakan Laravel Sanctum untuk token-based authentication.

Login

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..."
    }
}

Using the Token

Gunakan token di header untuk semua protected endpoints:

GET /api/v1/users
Authorization: Bearer 1|abc123...

Logout

POST /api/v1/auth/logout
Authorization: Bearer 1|abc123...

πŸš€ Running the Application

Development Server

php artisan serve

API akan berjalan di http://localhost:8000

Testing API

Gunakan tools seperti:

  • Postman
  • Insomnia
  • cURL
  • Thunder Client (VS Code extension)

πŸ“š API Documentation

Base URL

http://localhost:8000/api/v1

API Endpoints Overview

Authentication

  • POST /auth/login - Login
  • POST /auth/logout - Logout
  • GET /auth/me - Get current user

User Management (Admin Only)

  • GET /users - List users
  • POST /users - Create user
  • GET /users/{id} - Get user
  • PUT /users/{id} - Update user
  • DELETE /users/{id} - Delete user

Customers

  • GET /customers - List customers
  • POST /customers - Create customer
  • GET /customers/{id} - Get customer
  • PUT /customers/{id} - Update customer
  • DELETE /customers/{id} - Delete customer

Employees

  • GET /employees - List employees
  • POST /employees - Create employee
  • GET /employees/{id} - Get employee
  • PUT /employees/{id} - Update employee
  • DELETE /employees/{id} - Delete employee

Quotations

  • GET /quotations - List quotations
  • POST /quotations - Create quotation (with items)
  • GET /quotations/{id} - Get quotation
  • PUT /quotations/{id} - Update quotation
  • DELETE /quotations/{id} - Delete quotation

Purchase Orders

  • GET /purchase-orders - List purchase orders
  • POST /purchase-orders - Create PO (with items)
  • GET /purchase-orders/{id} - Get PO
  • PUT /purchase-orders/{id} - Update PO
  • DELETE /purchase-orders/{id} - Delete PO

Purchase Requisitions

  • GET /purchase-requisitions - List purchase requisitions
  • POST /purchase-requisitions - Create PR (with items, supplier/routing validation)
  • GET /purchase-requisitions/{id} - Get PR
  • PUT /purchase-requisitions/{id} - Update PR
  • DELETE /purchase-requisitions/{id} - Delete PR

Material Receiving Reports

  • GET /material-receiving-reports - List material receiving reports
  • POST /material-receiving-reports - Create MRR (with items, enum remarks)
  • GET /material-receiving-reports/{id} - Get MRR
  • PUT /material-receiving-reports/{id} - Update MRR
  • DELETE /material-receiving-reports/{id} - Delete MRR

Delivery Notes

  • GET /delivery-notes - List delivery notes
  • POST /delivery-notes - Create delivery note (with items, customer relationships)
  • GET /delivery-notes/{id} - Get delivery note
  • PUT /delivery-notes/{id} - Update delivery note
  • DELETE /delivery-notes/{id} - Delete delivery note

Work Assignments

  • GET /work-assignments - List work assignments
  • POST /work-assignments - Create work assignment
  • GET /work-assignments/{id} - Get work assignment
  • PUT /work-assignments/{id} - Update work assignment
  • DELETE /work-assignments/{id} - Delete work assignment

Daily Activities

  • GET /daily-activities - List daily activities
  • POST /daily-activities - Create daily activity
  • GET /daily-activities/{id} - Get daily activity
  • PUT /daily-activities/{id} - Update daily activity
  • DELETE /daily-activities/{id} - Delete daily activity

Payroll System

  • GET /payroll/projects - List payroll projects
  • POST /payroll/projects - Create payroll project
  • GET /payroll/projects/{id} - Get payroll project
  • PUT /payroll/projects/{id} - Update payroll project
  • DELETE /payroll/projects/{id} - Delete payroll project
  • GET /payroll/periods - List payroll periods
  • POST /payroll/periods - Create payroll period
  • GET /payroll/periods/{id} - Get payroll period
  • PUT /payroll/periods/{id} - Update payroll period
  • DELETE /payroll/periods/{id} - Delete payroll period

Untuk dokumentasi lengkap, lihat Postman Collection


πŸ“ Project Structure

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

Architecture Pattern

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

πŸ”’ Authorization

System menggunakan role-based access control dengan 3 roles:

Admin

  • Full access ke semua modul
  • User management
  • Semua CRUD operations

Teknisi

  • View dan create Daily Activities (own only)
  • View Work Assignments
  • Limited access

User

  • Minimal access
  • View only untuk assigned data

πŸ§ͺ Testing

Run Tests

php artisan test

Run Specific Test Suite

php artisan test --testsuite=Feature
php artisan test --testsuite=Unit

πŸ“ Additional Commands

Clear Cache

php artisan cache:clear
php artisan config:clear
php artisan route:clear

Optimize for Production

php artisan config:cache
php artisan route:cache
php artisan view:cache

Database Commands

# 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

🀝 Contributing

  1. Create feature branch
  2. Make changes
  3. Write tests
  4. Submit pull request

πŸ“„ License

Proprietary - PT Adiwarna Alam Raya


πŸ“ž Support

Untuk pertanyaan atau issues, hubungi tim development.


πŸ”„ Version History

v1.0.0 (Current)

  • Initial release
  • Full CRUD untuk semua modul
  • Authentication dengan Sanctum
  • Role-based authorization
  • Comprehensive API documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages