T.A Consultant · lead frontend
E-Office
Digital workflow for a state-owned bridge and ferry operator.
T.A Consultant · lead frontend
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.
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.
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.
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.
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.