T.A Consultant · lead frontend

E-Office

Digital workflow for a state-owned bridge and ferry operator.

Digital paperwork for a state-owned bridge and ferry operator: a document is drafted from a template, moves through a chain of people, gets a register number, and goes out as a PDF. I was lead frontend, one of two frontend developers on it.

01A template chain that bends per document

An approval chain comes from a template, but a real document often needs a different person or a shorter deadline at one step, without changing the template for everyone. So when a workflow starts, its steps open as editable drafts. On submit, the frontend compares each field with the template, trims it, and sends only what changed, because the backend takes sparse overrides.

The form blocks empty names, content or assignees and invalid deadlines. The kind of flow limits which step types are allowed: a signing flow gets approve, sign and dispatch, while a task flow gets task and review. The API returns enums as numbers in some places and strings in others, so one helper normalises them before the UI sees any.

decided
Show the "effective" fields the backend computes.
instead of
Reconciling template and overrides again in the browser.
the cost
The screen depends on the backend for that answer, but there is only one version of the truth about a step.

02From editor to issued PDF, without losing anything

Documents are written in TipTap and rendered to PDF by a separate service, so whatever leaves the editor has to be complete. It was not. Whether a table had borders lived on the DOM and never reached getHTML(), so a function copies that state back into the serialised HTML, matching tables by index, and styles are inlined before export.

Large documents hit 413 errors as JSON bodies, so the HTML now travels as a multipart blob, and the client accepts the reply as either binary or base64 JSON. New versions start from the template's latest version. At dispatch, placeholders are replaced with the escaped register number, the version is saved, and only then is the PDF generated.

decided
Multipart upload for document HTML.
instead of
A JSON body, which the server refused for large documents.
the cost
A little more client code on both the send and receive sides.

03A bundle budget the build enforces

No user had complained yet, but the entry chunk was 4.3 MB before compression, and 49 of 53 pages loaded eagerly. I added lazy routes, vendor chunk groups, hover prefetch, and an error boundary for stale chunks after a deploy. Then I made it stick: a Vite plugin fails the build over a gzip budget, and a Playwright test guards it too. The entry is now about 36 KB gzipped against a 45 KB budget. I have no gzipped baseline from before, so I will not quote a percentage.

The guard earned its place straight away. It failed the first time because the manualChunks shim in rolldown gave no priority control, which is what pushed the config to advancedChunks.

decided
Route-level lazy loading plus explicit vendor groups.
instead of
Routes alone, where heavy libraries could land in a shared chunk, and component-level imports, which meant editing page internals.
the cost
A chunk config and a budget that someone has to maintain.

04Roles from three different shapes

An authorization hook, role requirements on menu entries, and a protected route that normalises role values arriving as numbers, English or Vietnamese. This is there to shape the interface. Enforcement belongs to the backend.

What this does not cover

  • The backend, approval and signing logic, PDF rendering and the AI models are not mine. From this repo they are API calls.
  • The other frontend developer led task management, and split the rest of the work with me almost evenly.
  • Some page components run to nearly 3,000 lines, two rich-text editors still ship, and the lint backlog is real.
  • The admin dashboard still downloads TipTap, and SignalR loads on every page. The render performance and accessibility follow-ups have not started.
  • The last full end-to-end run was 65 passed and 16 skipped.
next projectSigma