Skip to content

Regional Service

The Regional Service provides access to Indonesian administrative region data (province, city, district, village). It is implemented as a separate service (merq-indonesian-regional) with its own PostgreSQL database containing reg_* tables.

The main backend (merq-backend) proxies requests to the regional service via HTTP. This separation allows independent scaling and maintenance of the regional data service.

Use cases:

  • Outlet store location assignment
  • Employee address registration
  • Geographic filtering and reporting
sequenceDiagram
    participant Web as Web/Mobile Client
    participant Backend as merq-backend (proxy)
    participant Regional as merq-indonesian-regional
    
    Web->>Backend: GET /office/v1/regional/provinces
    Backend->>Regional: HTTP GET /provinces
    Regional-->>Backend: JSON response
    Backend-->>Web: Proxy response
    
    Note over Backend,Regional: Separate DB, same Docker network

Key Points:

  • Regional service runs as a separate HTTP service
  • merq-backend proxies requests (no direct DB access)
  • Both services run in the same Docker network (Dokploy)
  • Configured via REGIONAL_SERVICE_URL environment variable
FieldTypeDescription
idintegerPrimary key
codestringRegional code (e.g., “31” for Jakarta)
namestringRegional name (e.g., “DKI Jakarta”)
typestringOnly for cities: “kota” or “kabupaten”

All endpoints are read-only (no RBAC required beyond authentication).

MethodEndpointDescriptionParams
GET/office/v1/regional/provincesList all provincespage, limit, keyword
GET/office/v1/regional/citiesList cities by provinceprovince_id (required), page, limit, keyword
GET/office/v1/regional/districtsList districts by citycity_id (required), page, limit, keyword
GET/office/v1/regional/villagesList villages by districtdistrict_id (required), page, limit, keyword

Mobile endpoints: Same paths under /app/v1/regional/ prefix (read-only).

GET /office/v1/regional/provinces?keyword=Jakarta
{
"data": [
{
"id": 31,
"code": "31",
"name": "DKI Jakarta"
}
],
"message": "provinces retrieved",
"code": "PROVINCE_LIST"
}
GET /office/v1/regional/cities?province_id=31
{
"data": [
{
"id": 3171,
"code": "3171",
"name": "Jakarta Pusat",
"type": "kota"
},
{
"id": 3172,
"code": "3172",
"name": "Jakarta Utara",
"type": "kota"
}
],
"message": "cities retrieved",
"code": "CITY_LIST"
}
GET /office/v1/regional/districts?city_id=3171
{
"data": [
{
"id": 317101,
"code": "317101",
"name": "Gambir"
},
{
"id": 317102,
"code": "317102",
"name": "Tanah Abang"
}
],
"message": "districts retrieved",
"code": "DISTRICT_LIST"
}
GET /office/v1/regional/villages?district_id=317101
{
"data": [
{
"id": 3171010001,
"code": "3171010001",
"name": "Gambir"
},
{
"id": 3171010002,
"code": "3171010002",
"name": "Kebon Kelapa"
}
],
"message": "villages retrieved",
"code": "VILLAGE_LIST"
}

The regional API is designed for cascading dropdowns:

1. Load Provinces (no parent)
↓ user selects province
2. Load Cities (filter by province_id)
↓ user selects city
3. Load Districts (filter by city_id)
↓ user selects district
4. Load Villages (filter by district_id)

Important:

  • Always load parent first
  • Child lists are empty until parent is selected
  • Reset child selections when parent changes
  • Village table has 83k+ rows — always require district_id filter
VariableDefaultDescription
REGIONAL_SERVICE_URLhttp://merq-indonesian-regional:8081Regional service base URL

For local development, set in .env:

Terminal window
REGIONAL_SERVICE_URL=http://localhost:8082

In Dokploy, services are in the same Docker network:

Terminal window
REGIONAL_SERVICE_URL=http://merq-indonesian-regional:8081

If the regional service is down, the backend returns empty data (graceful degradation):

{
"data": [],
"message": "regional service unavailable",
"code": "REGIONAL_SERVICE_ERROR"
}

If parent ID doesn’t exist:

{
"data": [],
"message": "province not found",
"code": "REGIONAL_PROVINCE_NOT_FOUND"
}

HTTP Status Codes:

  • 200 OK — Success
  • 404 Not Found — Parent ID not found
  • 503 Service Unavailable — Regional service down
LevelCountNotes
Provinces~34All Indonesian provinces
Cities~514Kota + Kabupaten
Districts~7,200Kecamatan
Villages~83,000+Kelurahan/Desa

Performance Notes:

  • Province/city lists are small (can load all)
  • District/village lists require parent filter
  • Keyword search recommended for large lists