Skip to content
SATANG.B
All workCase study
Eastern Economic Corridor Office · via Chanwanich

EEC e-Customs

The customs-privilege e-service for Thailand’s Eastern Economic Corridor: companies submit machinery and raw-material imports, BOQs, fast-track releases and e-payments; officers review and approve.

Role
Senior engineer · bootstrapped 5 Phase 2 services · main author of the payment service · MR reviewer for a ~10-person team
Stack
.NET 10 · CQRS · Next.js 16 · PostgreSQL 17
SUBMITTEDIN REVIEWAPPROVEDAPPROVEDE-CUSTOMSMACHINERY · RAW MATERIALSDGA SIGNATURENSW · ASYNC
Problem
Phase 2 re-architected Phase 1 into microservices, and had to talk to outside systems — DGA digital signatures and the asynchronous NSW customs gateway.
What I did
Bootstrapped five Phase 2 services from the first commit, wrote most of the payment service, review and approve the team’s MRs, and built across the web app and core service.

Results

Apr → Nov 2026 · Phase 2 signed off in SIT/UAT, awaiting launch · bootstrapped 5 services · 79% of payment-service commits
  • In SIT/UAT, retrying a payment returns the existing payment link instead of charging twice, and document numbers no longer collide under load
  • Adding a scheduled job is quicker — no queue listener to build in every service — and jobs can only call approved services
  • Every UAT round re-runs a 275-case Playwright suite; the payment service alone has about 250 unit tests

How it fits together

Redrawn diagram
Companies
Next.js 16
Officers
Next.js 16
Core service
.NET 10 · CQRS
Payment service
Report service
Qorstack · Gotenberg
Worker
Schedule
Hangfire
External gateway
DGA
digital signature · sync
NSW customs
async · polling
PostgreSQL 17 · Redis · MinIO · OpenTelemetry · Kubernetes (Kustomize + Fleet)

How it works

  1. 01

    Slow outside systems

    One external service is the only door out: DGA is called synchronously; NSW goes through RabbitMQ with polling for the answer.

  2. 02

    Work on a schedule

    A schedule service runs Hangfire jobs as internal commands or HTTP callbacks.

  3. 03

    Certificates you can trust

    Certificate PDFs are rendered by Qorstack Report through Gotenberg.

What went wrong — and how I fixed it

Real problems from the commit history, not a highlight reel.

  1. 01
    Problem

    Retrying a payment could create a second payment.

    How I fixed it

    Return the existing payment link when one is active, and guard state transitions so a webhook can’t overwrite a cancelled request.

  2. 02
    Problem

    Scheduled jobs replied over a queue, so every service needed its own consumer.

    How I fixed it

    Hangfire calls services back over HTTP, with an exact-host allow-list (SSRF protection) and callback authentication.

  3. 03
    Problem

    Notifications succeeded on some channels and failed on others.

    How I fixed it

    A bounded retry queue with dead-lettering, and delivery logs so retries skip channels that already succeeded.

  4. 04
    Problem

    Running numbers collided under concurrency.

    How I fixed it

    A transaction-scoped PostgreSQL advisory lock around count-then-insert.

  5. 05
    Problem

    Stale cache, cleared by hand with key prefixes.

    How I fixed it

    A save interceptor that clears tagged Redis entries only after commit, covering 57 cached queries.

Decisions & trade-offs

  • CQRS inside Clean Architecture

    Commands and queries split with MediatR, validated with FluentValidation — the same shape in every service, so people move between them easily.

  • GitOps for ~14 workloads

    Kustomize and Fleet make every deploy reviewable in git.

What I owned
  • Five Phase 2 services bootstrapped (payment, scheduling, workers, reports, integrations)
  • Most of the payment service: idempotency, callback checks, expiry, audit trail
  • Advisory-lock standard for document numbers, adopted by five teammates
  • Sage AI-agent rules and decision records across the repos
  • MR review and approval for the team; the 275-case Playwright UAT suite
  • Features across the Next.js 16 web app and .NET 10 core service
Stack
  • .NET 10
  • CQRS
  • Next.js 16
  • PostgreSQL 17
  • Redis
  • RabbitMQ
  • MinIO
  • Hangfire
  • OpenTelemetry
  • Kubernetes

Client system with private data — the visuals on this page are redrawn diagrams, not screenshots.