Technical Documentation
Enter Access PIN
ECOFORPEST // DOCS v1.0 API v1
Technical Documentation Dokumentasi Teknis

Ecoforpest

Full-stack pest control management platform consisting of a Laravel web backend (Admin + API) and a React Native mobile app for field technicians.

Platform manajemen jasa pest control berbasis full-stack yang terdiri dari backend web Laravel (Admin + API) dan aplikasi mobile React Native untuk teknisi lapangan.

Laravel 12 Filament 3 React Native Expo 53 Laravel Sanctum Xendit Payments
01

Tech Stack

Teknologi yang Digunakan

🌐 Web Backend 🌐 Backend Web
FrameworkLaravel 12
PHP^8.2
Admin PanelFilament 3.3
AuthLaravel Sanctum
PDFDomPDF ^3.1
PaymentXendit Webhook
ExcelMaatwebsite ^3.1
CachePredis/Redis
FrontendInertia.js + Vue
RolesFilament Shield
📱 Mobile App 📱 Aplikasi Mobile
FrameworkReact Native
PlatformExpo ~53
Navigationexpo-router ~5.1
UI LibraryTamagui ^1.126
StateZustand ^5.0
StorageMMKV ^3.2
Data FetchSWR ^2.3
MapsLeaflet (WebView)
Cameraexpo-camera ~16.1
LanguageTypeScript ~5.8
02

System Architecture

Arsitektur Sistem

Ecoforpest follows a client-server architecture where the Laravel backend serves two roles: an admin web panel (Filament) for internal staff, and a RESTful API for the mobile app used by field technicians.

Ecoforpest menggunakan arsitektur client-server di mana backend Laravel berperan ganda: sebagai panel admin web (Filament) untuk staf internal, dan sebagai RESTful API untuk aplikasi mobile yang digunakan teknisi lapangan.

Admin Web Panel
Filament 3 / Inertia.js
Vue / Web
Laravel 12 Backend
Web & API (Sanctum Auth)
MySQL Database
REST API
Mobile App
React Native / Expo 53
Webhooks
Xendit Payment Gateway
Authentication
Autentikasi
Token-based via Laravel Sanctum. Employee login returns Bearer token for all subsequent requests.
Berbasis token via Laravel Sanctum. Login karyawan mengembalikan Bearer token untuk semua request selanjutnya.
Work Orders
Work Order
Core module. Manages pest control jobs including progress tracking, surveys, and service reports.
Modul inti. Mengelola pekerjaan pest control termasuk tracking progress, survei, dan laporan servis.
Attendance
Absensi
Clock-in/out with GPS location. Includes leave, permit, and overtime management.
Absensi masuk/keluar dengan lokasi GPS. Mencakup manajemen cuti, izin, dan lembur.
Leader Reports
Laporan Leader
Team leader submits field reports with approval workflow by management.
Team leader membuat laporan lapangan dengan alur persetujuan dari manajemen.
Schedule Planning
Jadwal Planning
Weekly treatment schedule planning with employee assignment and method tracking.
Perencanaan jadwal treatment mingguan dengan penugasan karyawan dan tracking metode.
Cash Advance
Kasbon
Employee cash advance requests with status tracking and approval flow.
Pengajuan kasbon karyawan dengan tracking status dan alur persetujuan.
03

Authentication API

API Autentikasi

Base URL & Headers Base URL & Headers
Configuration
Base URL: https://docs.ecopestcontrol.co.id/api

# Public endpoints — no token required
POST /api/auth/login

# Protected endpoints — include header:
Authorization: Bearer {token}
Accept: application/json
Content-Type: application/json
POST /api/auth/login Employee login Login karyawan
FieldTypeRequiredDescription
emailstringrequiredEmployee email
passwordstringrequiredEmployee password
device_namestringoptionalDevice identifier
Response (200)
{
  "user": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com",
    "position": { 
      "id": 2, 
      "title": "Technician"
    }
  },
  "token": "1|abc123..."
}
GET /api/auth/user Get authenticated employee + today's task count Data karyawan + jumlah work order hari ini

Fetch detail of the logged-in technician with their current active profile and today's work order count.

Mengambil detail profil teknisi yang login beserta jumlah tugas absensi/work order miliknya hari ini.

Response
{
  "user": {
    "id": 1,
    "name": "John Doe"
  },
  "today_work_orders_count": 3
}
POST /api/auth/logout Revoke current token Hapus token saat ini

Destroy token and logs out user.

Menghapus token yang sedang digunakan.

Response
{
  "message": "Successfully logged out"
}
04

Attendance API

API Absensi

All endpoints require Bearer token. Prefix: /api/attendance

Semua endpoint membutuhkan Bearer token. Prefix: /api/attendance

Attendance Endpoints
GET /api/attendance/today Today's attendance record Data absensi hari ini

Returns today's clock-in/out status, work hours, and shift info for the authenticated employee.

Mengembalikan status absensi masuk/keluar, jam kerja, dan info shift karyawan yang login.

{
  "status": "present",
  "clock_in": "08:00:12",
  "clock_out": null
}
GET /api/attendance/history Attendance history (paginated) Riwayat absensi (paginasi)
QueryDescription
monthFilter by month (1-12)
yearFilter by year
{
  "current_page": 1,
  "data": [
    { "date": "2026-05-20", "status": "present" }
  ]
}
GET /api/attendance/summary Monthly attendance summary Ringkasan absensi bulanan

Returns total present days, late days, absent days, and total work hours for the month.

Mengembalikan total hari hadir, telat, absen, dan total jam kerja dalam sebulan.

{
  "total_present": 20,
  "total_late": 2,
  "total_hours": 160.5
}
POST /api/attendance Clock-in or Clock-out Absensi masuk atau keluar
FieldTypeReqDescription
typestringyesclock_in / clock_out
photofileyesSelfie photo
latitudefloatyesGPS latitude
longitudefloatyesGPS longitude
{
  "message": "Clock-in successful",
  "time": "08:00:15"
}
POST /api/attendance/request-access Request location access exception Minta pengecualian akses lokasi

Used when employee is outside the registered attendance zone and needs to request manual override.

Digunakan saat karyawan berada di luar zona absensi terdaftar dan perlu minta pengecualian manual.

{
  "status": "pending_approval"
}
05

Work Orders API

API Work Order

Core module for pest control job management. Prefix: /api/work-orders

Modul inti untuk manajemen pekerjaan pest control. Prefix: /api/work-orders

All work order endpoints are authenticated. Only the assigned employee (or helpers) can access/update a specific work order.
Semua endpoint work order membutuhkan autentikasi. Hanya karyawan yang ditugaskan (atau helper) yang bisa mengakses/mengubah work order tertentu.
GET /api/work-orders List work orders Daftar work order
QueryOptions
statusOpen, Pending, Hold Confirm, Confirm, Assigned, On Progress, Closed, Cancelled
{
  "data": [
    {
      "id": 12,
      "task_code": "WO-2026-0001",
      "status": "Assigned"
    }
  ]
}
GET /api/work-orders/by-month Work orders grouped by month Work order dikelompokkan per bulan

Returns work orders for the current employee grouped by month, useful for the monthly calendar view in the mobile app.

Mengembalikan work order karyawan yang login, dikelompokkan per bulan.

{
  "May 2026": [
    { "id": 12, "scheduled_date": "2026-05-21" }
  ]
}
GET /api/work-orders/{id} Work order detail Detail work order

Full detail including relations: service, assigned employee, progress, work order package, helpers, customer info.

Detail lengkap termasuk relasi: service, karyawan yang ditugaskan, progress, paket work order, helper, info pelanggan.

{
  "id": 12,
  "customer": { "name": "ACME Corp" },
  "service": { "name": "General Pest Control" },
  "helpers": []
}
PATCH /api/work-orders/{id}/status Update status Update status
FieldTypeReqDescription
statusstringrequiredOn Progress, Closed, etc.
{ "status": "On Progress" }
POST /api/work-orders/{id}/progress Add progress update Tambah update progress
FieldTypeReqDescription
progress_statusstringreqTake Order / Ketemu Client / Survey / Mulai Kerja / Tindakan / Selesai Kerja / Collect Money
notesstringoptProgress notes
photos[]file[]optPhoto files (max 5MB each)
locationobjectopt{"latitude":..., "longitude":...}
Use multipart/form-data when uploading photos.
Gunakan multipart/form-data saat upload foto.
{
  "message": "Progress updated successfully"
}
POST /api/work-orders/{id}/service-report Submit service report Submit laporan servis

Submit the final service report for a completed work order. Includes treatment details, chemicals used, and technician signature.

Submit laporan servis akhir untuk work order yang selesai. Mencakup detail treatment, bahan kimia yang digunakan, dan tanda tangan teknisi.

{
  "message": "Service report submitted"
}

Survey Endpoints

GET /api/work-orders/{id}/forms/{type} Get dynamic survey form template Ambil template form survei dinamis

type options: identification, initial_check, final_check

Pilihan type: identification, initial_check, final_check

{
  "form_id": 1,
  "fields": [
    { "id": "f_1", "type": "text", "label": "Pest Found" }
  ]
}
POST /api/work-orders/{id}/surveys Submit survey answers Submit jawaban survei
{
  "survey_form_id": 1,
  "answers": {
    "field_id_1": "Rat infestation found"
  }
}
{
  "message": "Survey answers saved"
}
06

Leave & Permit API

API Cuti & Izin

Standard CRUD for employee leave and permit requests. Prefix: /api/leaves and /api/permits

CRUD standar untuk pengajuan cuti dan izin karyawan. Prefix: /api/leaves dan /api/permits

Leave — /api/leaves
GET/api/leavesList leave requests

List requests

{"data":[]}
POST/api/leavesSubmit leave request
FieldDescription
start_dateStart of leave period
end_dateEnd of leave period
reasonLeave reason
attachmentSupporting document (optional)
{"message":"Submitted"}
07

Overtime API

API Lembur

CRUD for overtime requests. Prefix: /api/overtimes

CRUD untuk pengajuan lembur. Prefix: /api/overtimes

GET/api/overtimesList overtime requests

View list

[]
POST/api/overtimesSubmit overtime request
FieldDescription
dateOvertime date
duration_hourDuration in hours (float)
reasonReason for overtime
{"message":"Overtime logged"}
08

Cash Advance API

API Kasbon

Employee cash advance requests. Prefix: /api/cash-advance

Pengajuan kasbon karyawan. Prefix: /api/cash-advance

GET/api/cash-advanceList requests

View all cash advance history

[]
POST/api/cash-advanceNew request
FieldDescription
amountAmount requested
reasonPurpose of advance
repayment_dateExpected repayment date
{"message":"Advance request created"}
09

Leader Report API

API Laporan Leader

For team leaders to submit field reports with management approval flow. Prefix: /api/leader-reports

Untuk team leader submit laporan lapangan dengan alur persetujuan manajemen. Prefix: /api/leader-reports

GET/api/leader-reportsList reports

All submitted leader reports

[]
POST/api/leader-reports/{id}/approveApprove report
Management approves submitted leader reports through this endpoint.
{"status":"approved"}
10

Schedule Planning API

API Jadwal Planning

Weekly treatment schedule management. Prefix: /api/schedule-plannings

Manajemen jadwal treatment mingguan. Prefix: /api/schedule-plannings

GET/api/schedule-planningsList schedules

Fetch weekly scheduling planners.

[]
11

Location API

API Lokasi

POST /api/location/update Update employee GPS location

Called automatically by the mobile app's background location service for real-time tracking of field technicians.

Dipanggil otomatis oleh layanan lokasi latar belakang di aplikasi mobile untuk tracking real-time teknisi di lapangan.

FieldDescription
latitudeCurrent latitude
longitudeCurrent longitude
{"status":"updated"}
12

Mobile App Structure

Struktur Aplikasi Mobile

The mobile app is built with Expo (React Native) and uses file-based routing via expo-router. It communicates with the Laravel API using Bearer token authentication stored in MMKV local storage.

Aplikasi mobile dibangun dengan Expo (React Native) dan menggunakan routing berbasis file via expo-router. Berkomunikasi dengan API Laravel menggunakan autentikasi Bearer token yang disimpan di MMKV local storage.

ecoforpest-mobile/
├── app/              # Screen files (file-based routing)
├── components/       # Reusable UI components
│   ├── attendance/   # Attendance-related components
│   ├── form/         # Dynamic form system
│   └── schedulePlanning/
├── hooks/            # Custom React hooks (data fetching)
├── service/          # API client layer
│   ├── api.ts        # Core fetch utilities + types
│   └── locationTracking.ts
├── types/            # TypeScript type definitions
├── utils/            # Utility functions
└── constants/        # App constants
13

Mobile Screens

Halaman Mobile

Screen FileDescriptionDeskripsi
signin.tsxEmployee login screenHalaman login karyawan
home.tsxDashboard — tasks & actionsDasbor — tugas & aksi
attendance.tsxAttendance calendar viewRingkasan absensi dengan kalender
attendance-clock-in.tsxClock-in screen with selfie + GPSAbsensi masuk/keluar dengan selfie + GPS
create-leave.tsxLeave request formForm pengajuan cuti
task-maps.tsxWork order locations on Leaflet mapLokasi work order di peta (Leaflet)
form-signature.tsxCustomer signature padPad tanda tangan pelanggan
14

Custom Hooks

Custom Hooks

HookPurposeFungsi
useAuthAuthentication state + login/logoutState autentikasi + login/logout
useAttendanceTodayToday's attendance dataData absensi hari ini
useWorkOrderProgressWork order progress trackingTracking progress work order
useOptimizedFormOffline queue-based supportForm dengan dukungan offline berbasis antrian
useBatteryOptimizationAndroid battery optimization checkCek optimasi baterai Android
15

Key Components

Komponen Utama

The app includes a flexible dynamic form system under components/form/ that renders survey fields based on backend-defined schemas.

Aplikasi menyertakan sistem form dinamis fleksibel di components/form/ yang merender field survei berdasarkan skema yang didefinisikan dari backend.

Dynamic Form Components

ComponentDescription
FormFieldRendererRenders the correct field type based on schema
FormFieldTextInputSingle-line text input
FormFieldSignatureSignature canvas field
16

Web Setup Guide

Panduan Setup Web

Terminal Commands
# 1. Clone & install
git clone <repo> && cd ecoforpest-web
composer install
npm install

# 2. Environment
cp .env.example .env
php artisan key:generate

# 3. Database
# Edit .env: DB_DATABASE, DB_USERNAME, DB_PASSWORD
php artisan migrate
php artisan db:seed

# 4. Storage
php artisan storage:link

# 5. Build frontend
npm run build

# 6. Start server
php artisan serve
For production, use nixpacks (nixpacks.toml is included) or any standard PHP hosting with PHP ^8.2 support.
17

Mobile Setup Guide

Panduan Setup Mobile

Terminal Commands
# 1. Install dependencies
cd ecoforpest-mobile
npm install

# 2. Configure API URL
# Edit constants/ or .env to point to your Laravel backend URL

# 3. Start development
npx expo start

# 4. Run on device
npx expo run:android   # Android
npx expo run:ios       # iOS (requires macOS)
Location tracking requires "always on" location permission on Android. Ensure battery optimization is disabled for reliable background updates.