Skip to content
Back to the list

static build: HTML + JS + .wasm

VDG FreightForwarder

28 Rust state machines running in the browser via WebAssembly

Vietnamese freight forwarders run on Excel and email. Rate sheets, customer credit limits and bill-of-lading data are exactly what they do not want to push to a third party's server. That constraint decided the whole architecture.

Installed software — no public demo.

  • Rust
  • wasm-bindgen
  • calamine
  • Lit
  • AG Grid

§ 01Algorithm

src/abstractions/states — 28 máy trạng thái thuần Rust
# Biểu cước, hạn mức tín dụng, dữ liệu B/L là dữ liệu nhạy cảm
#   → toàn bộ parse / validate / transition chạy TRONG TRÌNH DUYỆT
#   → sản phẩm giao đi chỉ là file tĩnh, không tính toán phía server

Shipment:  Open → Quoted → Booked → InTransit
                → Arrived → Delivered → Invoiced → Closed
           ↘ Cancelled

  Closed, Cancelled = trạng thái hút (không còn chuyển tiếp)
  test: transitions_closed_empty, transitions_cancelled_empty

AirRate:   Draft → Published → Expired

transition(s, e):
  nếu (s, e) ∉ bảng chuyển:
    Err(GuardError::InvalidTransition { from: s, event: e })   # chặn, không sửa ngầm

# 28 FSM: AirShipment, Allocation, ArrivalNotice, AwbDoc, Billing,
#         CarrierBooking, …

§ 02Highlights

  • All parsing, validation and transitions run in the browser through WebAssembly
  • 28 pure-Rust state machines for shipments, rates, documents, allocation and billing
  • Invalid transitions blocked by an error carrying context, never silently corrected
  • Excel read client-side with calamine — no file is uploaded anywhere
  • Excel-like grid with virtual scrolling past 10,000 rows
  • A.D.D V3 architecture with hard layer rules: Boundary and Core depend on nothing

§ 03Screens

VDG FreightForwarder01