Skip to main content
Back to Articles
● December 1, 2026 ● 4 MIN READ

Rebuilding Indonesia’s 143,980-Certificate TKDN Registry in Rust, Leptos SSR, and Cloudflare D1

RustLeptosWebAssemblyCloudflare D1Government TechCase Study
Research & Insights ● Future of Digital Experience ● AI Revolution ● Design Strategy ● New Era of Intelligence ●
Rebuilding Indonesia’s 143,980-Certificate TKDN Registry in Rust, Leptos SSR, and Cloudflare D1
Featured Image

TL;DR — Pinning one upstream hostname at nginx startup caused site-wide 504 timeouts every time a container rotated. That single line in an edge proxy config was one of five production failures we had to close while migrating Indonesia’s national TKDN (Tingkat Komponen Dalam Negeri) registry from a six-year PHP monolith to Axum + Leptos 0.8 SSR, a Golang headless CMS, and a Cloudflare D1 read-through replica. Today, tkdn.kemenperin.go.id serves 143,980 certificates (83,606 active) with zero JavaScript required for indexable HTML and sub-second faceted search.

Contents

1. Why a Six-Year PHP Monolith Hit a Wall

For six years, Kemenperin’s TKDN site ran as a server-rendered PHP/MySQL monolith (search.php, sertifikat_ik_idx.php, rekap.php, regulasi.php). Every public page rendered per-request against the same database tables that held the certificate registry, and every editorial or org-chart update required a code deploy.

When procurement officers and manufacturers verify a TKDN score—such as the Material 75% + Tenaga Kerja 10% + Overhead 15% + BMP breakdown under Permenperin 35/2025 Pasal 4—trust is a latency problem. If a lookup stalls or a regulation table drifts out of date, users fall back to manual PDFs and phone calls.

We split the platform into two decoupled halves:

LayerResponsibilityKey Contract
Axum 0.8 + Leptos 0.8 SSR/WASM (tkdn-web)Server-rendered HTML for SEO + progressive WASM hydration for interactive toolscurl -s / \| grep Title works with zero JS; /kalkulator, /sertifikat, /cari, /kapasitas hydrate in-browser
Golang Headless CMS + CmsRepositoryStructured pages, regulations, infographics, media, and org-chart nodes in PostgresSyncs TKDN and LVI records directly from SIINas—staff never re-key certificate data

Public TKDN Infografis Dashboard — Live Registry Metrics Rendered via Leptos SSR

Live /infografis dashboard rendered via Leptos 0.8 SSR with synced SIINas certificate metrics, issuance volume, and sector distributions.


2. Five-Arc Engineering Timeline (Sep–Dec 2026)

Instead of a single big-bang cutover, the platform evolved across five documented engineering arcs, culminating in 76 commits across 20 active days in November 2026:

ArcPeriodScopeCore Deliverable
01. BootstrapSep 9–11, 202612 commitsAxum + Leptos SSR scaffold, Render PORT bind rule, fail-soft lazy-DB boot, Neon/PgBouncer statement-cache hardening
02. Content Build-OutOct 19, 2026+4,981 / −834 linesPublic routes (/inventarisasi, /regulasi, /tentang), OKLCH @theme tokens, JSON-LD + sitemap.xml
03. CMS IntegrationOct 20, 2026+7,470 / −894 linesBidirectional CmsRepository (direct Postgres read arm + Go API client), staff auth, /api/snapshot
04. Hardening EraOct 21–Nov 1, 202616+ commitsBranded error layers, CSP nonces, /kalkulator F.1.4 rework, self-hosted ALTCHA PoW, html_cache, cold-SSR Suspense fix
05. Scale & ExpansionNov 3–Dec 1, 202676 commitsBox<str> memory cuts, D1 replica, tkdn-edge 504 fix, /cari FTS, /capaian, /referensi, /kapasitas, 21 SVGs

November 2026 Commit Velocity Across 20 Active Engineering Days

Daily commit cadence across November 2026—76 commits landed across resilience, PoW defense, and new public surfaces.

November 2026 Code Diff Distribution by Subsystem

Diff distribution across app/ pages, server/ gates, Cloudflare workers, and documentation.


3. Why Pinning One Upstream IP Caused Site-Wide 504s

On 2026-11-13, the tkdn-edge nginx proxy began returning site-wide 504 Gateway Timeout errors whenever Railway rotated backend container IPs.

Root cause: proxy_pass pointed directly at a static upstream hostname. nginx resolved that hostname once at startup and pinned the stale IP until the proxy itself restarted.

The fix:

  • Per-request DNS resolution: Switched tkdn-edge.conf.template to an explicit resolver paired with a variable-backed proxy_pass, forcing fresh DNS lookups on every request.
  • Dual-stack private mesh: Bound API_INTERNAL_URL over Railway’s private network so internal CMS calls skip public egress while media URLs stay browser-resolvable.
  • Public-origin fallback: Added an automatic public-origin retry when the private-mesh transport fails at connect.

Per-Request DNS Resolution and Private-Mesh Egress Architecture

Dynamic upstream DNS resolution in tkdn-edge paired with dual-stack private-mesh transport and /api/version freshness checks.


4. Keeping Neon Asleep with a Cloudflare D1 Read-Through Replica

Public certificate registries are overwhelmingly read-biased. Without an edge read layer, every anonymous GET /sertifikat or GET /infografis woke serverless Postgres and ran full-table facet aggregates before painting the first row.

The fix (2026-11-04):

Client ─▶ tkdn-edge (10r/s, 30 conn/IP, dotfile 444)
            └─▶ App (velocity_gate, PoW gate)
                  └─▶ edge_key() eligible GET?
                        ├─ NO (POST / Bearer / verify / export) ─▶ CMS / Postgres
                        └─ YES ─▶ D1 Worker (4s timeout, 300s STALE_TTL)
                                    ├─ HIT  ─▶ JSON (Neon stays asleep)
                                    └─ MISS ─▶ CMS / Postgres fallback
  1. D1 Read-Through Replica (edge_get()): Eligible GET requests query a Cloudflare D1 worker (EDGE_READ_URL, 300s STALE_TTL, 4-second timeout) before touching CmsRepository. Cache hits never wake Neon.
  2. Strict Exclusions (edge_key()): Non-GETs, bearer-authenticated requests, token-parameterized queries, /verify endpoints, and /export routes bypass the shared replica so bulk exports never serve stale data.
  3. Split Row and Facet Queries: We split load_sertifikat_page into load_sertifikat_rows (indexed LIMIT query, render-blocking) and load_sertifikat_facets (tab-keyed aggregates). Filter edits no longer re-scan facets or block initial paint.

Cloudflare D1 Read-Through Replica and Edge Gates

Read-through replica flow and edge_key() exclusion boundaries.

Public /sertifikat Faceted Search Over 143,980 Synced Certificates

/sertifikat rendering indexed certificate rows independently of tab-level facet counts.


5. Closing the Fast-First-Search 403 Race with ALTCHA PoW

Our initial 30 req/min per-IP scrape_guard stopped naive bots, but legitimate users behind shared corporate NATs hit 429s. When we added a Proof-of-Work (PoW) widget, fast typers who submitted a search immediately after page load hit a 403 race before the background challenge finished solving.

Design rule: Security controls that degrade legitimate first-interaction UX get bypassed or disabled. Self-hosted PoW had to be invisible to normal users and deterministic under load.

The fix (2026-10-31 & 2026-11-04):

  • Built server/src/challenge.rs, a self-hosted ALTCHA-compatible PoW verifier with zero third-party CAPTCHA calls (/api/challenge, /api/issue).
  • Replaced naive == token checks with constant-time MAC comparison and enforced Cache-Control: no-store on challenge endpoints to prevent shared-cache replay.
  • Added a client-side clearance promise (arm_gate_forms document-capture submit handler) in <PowCheck/> so fast first searches await clearance cleanly instead of racing into a 403.
  • Upgraded cleared browsers from 30 req/min to 300 req/min, while uncleared traffic shares fingerprinted 120/min buckets so mobile IP rotation cannot mint fresh quotas.
  • Protected bulk /export_excel* downloads behind a hard /unduh interstitial.

/unduh Self-Hosted ALTCHA Proof-of-Work Interstitial

/unduh hard gate verifying human clearance before releasing bulk dataset exports.


6. Bounding SSR Memory Before Crawlers Hit the Semaphore

Even with D1 caching, cache misses and uncached search queries hit the Rust SSR server. During crawler bursts, unbounded concurrent Leptos renders spiked memory usage.

The fix (2026-11-07 & 2026-11-11):

  • velocity_gate (120/min): Sits outside the render semaphore so aggressive crawlers are rejected before they claim an SSR slot.
  • MAX_INFLIGHT semaphore (64 → 32): Caps peak SSR concurrency inside the 30-second request_timeout, backed by companion caps (SIINAS_PAGE 24→12, VERIFY 128→48, BMP_EXPORT 4→2, SSE_SLOTS 1024). Overflow degrades to a branded 503 instead of an OOM crash.
  • 256-entry html_cache (~96 MB ceiling): Serves anonymous SSR HTML with stale-on-error fallback, while events::invalidate() purges both html_cache and SITEMAP_CACHE on CMS saves.

Velocity Gate, MAX_INFLIGHT Semaphore, and 256-Entry html_cache

Concurrency gating and stale-on-error html_cache protection.


7. Preventing Stale WASM Traps and Hydration Mismatches

Deploying a Leptos SSR + WASM app introduces a subtle failure mode: if a user’s browser serves a cached .wasm binary from an older deploy against newly rendered SSR HTML, hydration traps.

The fix (2026-11-03 & 2026-11-13):

  • Shared TKDN_BUILD stamp: Compiled into both the SSR server and WASM hydrate targets.
  • /api/version freshness loop: Polled every 5 minutes by the client (Cache-Control: no-store); on a BUILD_ID mismatch, the client purges Cache Storage and prompts a reload.
  • Cold-SSR Suspense fixes: Wrapped conditional <Editable> and <PendingSections> arms and /rekapitulasi export dialogs in explicit <Suspense> boundaries, and guarded disposed signals on route transitions.

/kalkulator Single-Column Permenperin 35/2025 Worksheet with Floating F.1.4 Dock

/kalkulator single-column Permenperin 35/2025 Pasal 4 worksheet with live F.1.4 recap dock.


8. What Broke Along the Way & Key Trade-Offs

  • Render PORT binding & PgBouncer: Early September deploys failed health checks until Axum bound dynamically to PORT with fail-soft lazy DB startup and disabled prepared-statement caching for Neon/PgBouncer transaction pooling.
  • Scoped ILIKE sequential scans: Adding merk, tipe, HS, LVI, and KBLI filter chips initially bypassed search_blob indexes. Binding each chip to its own column alongside a blob_guide GIN AND clause restored bitmap-index scans.
  • D1 staleness window: Accepting a 300s STALE_TTL on public read models kept Neon asleep, but required strict edge_key() exclusions so /verify and /export never serve stale results.
  • cargo-leptos CI ergonomics: Keeping SSR and WASM in sync required pinning wasm-bindgen-cli against Cargo.lock, using cargo-chef layers in Dockerfile.musl, and gating PRs on cargo audit, sqlx offline checks, and Criterion hot-path benchmarks.

Continue Exploring

Ikziriv Design & Development
Share
Continue Reading

Related
Articles