darucodes.my.id
Case Study

Workflow System

Designing a reusable workflow engine to handle complex approval processes across multiple business modules.

PHP (CodeIgniter) MySQL Workflow Engine
workflow_state.php
<?php
$transitions = [
  'start' => 'CREATED',
  'level_1' => 'PENDING_LVL_1',
  'level_2' => 'PENDING_LVL_2',
  'end_state' => ['APPROVED', 'REJECTED'],
];
?>
Overview

Context & Problem

The Context

Many enterprise business processes (procurement, finance, and others) require multi-level approvals with different rules depending on roles, departments, and transaction values.

The Problem

Approval processes were handled manually or inconsistently across modules, causing delays, duplicated logic, and unreliable process tracking.

Execution

Challenges & Solution

!
Obstacles

Key Challenges

  • Dynamic approval chains based on roles and conditions
  • Multiple approval levels with strict ordering
  • Preventing invalid actions (skip, double approve, wrong user)
  • Maintaining consistency across different modules
✓
Architecture

The Solution

Designed and implemented a reusable workflow engine that manages state transitions for each request.

The system enforces role-based approvals, strict validation rules, and monitored state transitions to prevent invalid or out-of-order actions.

Logic

Key Features

State-based Workflow

Each request moves through controlled, predefined states preventing requests from skipping steps or moving to invalid states.

Role-based Approval

Only authorized users designated to a specific stage in the chain can approve at each level.

Validation Rules

Strict backend validation rules prevent invalid transitions and ensure total process integrity.

Audit Trail

All actions (approvals, rejections, and state changes) are comprehensively logged for full traceability.

Impact

Results & Methodology

Why This Approach Works

  • Consistency & Reusability: Centralized workflow logic removes duplicated rules across modules. The same engine can be applied to multiple business processes.
  • Reliability: Strict state transitions ensure entirely predictable process behavior regardless of the module.
  • Data Integrity: Transactional updates prevent partial or inconsistent states from being saved to the database.
EfficiencyReduced Delays

Significantly reduced approval delays and bottlenecks across multiple modules.

StandardizationSystem-wide Logic

Standardized approval logic system-wide, eliminating disjointed department-specific procedures.

TraceabilityImproved Auditing

Vastly improved traceability and auditability of approval processes for compliance.

Outcome: This workflow engine became a core component used across multiple modules, ensuring reliable and scalable business process execution.