Thirty-eight provinces, 514 regencies and cities, 7,277 districts and 83,731 villages, served as a REST API whose URL shape mirrors the administrative hierarchy itself. Every record carries its parent chain, and the entire dataset ships with the code — there is no database and no upstream call.
Indonesian administrative data is public and reasonably stable, and almost every project that needs it ends up re-scraping or re-typing it. This serves the whole hierarchy — province, regency or city, district, village — from one API, with each record naming its parent so a caller can walk back up without a second request.
The data does not change often enough to justify a database. All four levels load from JSON at import, get indexed into dictionaries by code and by parent, and are held for the process lifetime. Lookups are hash hits; there is no query planner and nothing to keep in sync.
The primary scheme uses official codes, nested the way the hierarchy nests: a province code, then a regency code beneath it, then a district. That is the right shape when you already hold an official code and want its children.
A parallel scheme addresses the same records by ordinal position — the third regency of a province, the second district of that regency — which is what you want when you are walking a form from a dropdown rather than resolving a known code. A separate lookup resolves any code at any level in one call, without the caller needing to know which level it belongs to.