Technical document

Architecture Design of a Unified Municipal & Business Platform with Local-First and Minimal Go Backend

How consolidating fragmented repositories into a single Local-First monorepo—powered by SolidJS 2, OPFS SQLite Wasm, Rust Wasm, a minimal Go ConnectRPC sync-api, Quint/CUE formal verification, and deterministic ETL—achieves zero-latency UI and strict tenant isolation.
AI Development23 minPublication Date November 30, 2026Update date November 30, 2026
Thumbnail for Architecture Design of a Unified Municipal & Business Platform with Local-First and Minimal Go Backend

Summary

Key points of this document

  • 1. Background: Why Consolidate into a Single Platform
  • 2. Core Architecture (Local-First + Minimal Go Backend)
  • 3. Unified Domains & Large-Scale Public Data

Overview

When municipal business platforms, commercial business platforms, AI, public data, statutory calculation engines, infrastructure, and operations tooling live across separate repositories, cross-repo synchronization and maintenance costs quickly escalate.

This document outlines the architecture for consolidating these systems into one Local-First unified monorepo and application. By pairing an in-browser execution layer (SolidJS 2 + Web Worker + SQLite Wasm on OPFS + Rust Wasm) for zero-latency UI with a minimal Go backend (sync-api via ConnectRPC) dedicated strictly to eight core platform responsibilities and server-authoritative operations, both municipalities and businesses can operate on a single, reliable foundation.


1. Background: Why Consolidate into a Single Platform

Challenges of Fragmented Repositories and Build Tooling

Previously, municipal systems (Go + React Router + PostgreSQL + Bazel), business systems (numerous Cloudflare Workers + D1 + React), and supporting domains (AI, data, statutory rules, standards, infrastructure, admin) were split across separate repositories. Distributing shared rules and maintaining Bazel pipelines created substantial operational overhead.

In the new design, Bazel is retired in favor of pnpm workspaces (TypeScript) + Cargo workspace (Rust) + Go modules (Go) orchestrated by a thin justfile and mise.toml, uniting municipal and commercial workloads on one codebase.

ComparisonLegacy Architecture (Multi-Repo)Unified Platform (Single Monorepo)
RepositoriesSplit across business, AI, data, law, infra, and adminConsolidated into one monorepo (legacy repos archived Read-Only after cutover)
FrontendReact Router / React across multiple buildsSolidJS 2 + Tailwind CSS v4 + Ark UI + TanStack Table (React fully retired)
Execution ModelServer-First cloud API calls on every interactionLocal-First (OPFS SQLite Wasm + Rust Wasm) for 60–120fps zero-latency UI
BackendLarge Go monolith + dozens of Cloudflare WorkersMinimal Go sync-api (8 core responsibilities + server authority only)
Build & ToolingBazel + BuildBuddyjustfile + mise.toml + native language toolchains
Tenant ControlSeparate apps and per-tenant implementationsSingle platform + PostgreSQL RLS + Feature Toggles

2. Core Architecture (Local-First + Minimal Go Backend)

The core principle is strict separation of concerns: computation, search, and document generation run inside the browser (Web Worker + SQLite Wasm + Rust Wasm), while the Go sync-api handles authentication, differential sync, server authority, key issuance, and external proxying.

Loading diagram...

Frontend Modernization & 120fps Motion Standard

  • SolidJS 2: Fine-grained reactivity without virtual DOM overhead maintains 60–120fps even on large tables (with SolidJS 1.9.x as a defined fallback if the Phase 1 PoC gate detects ecosystem incompatibility).
  • Tailwind CSS v4 + Ark UI + @tanstack/solid-table: Zero-runtime styling, state-machine-driven accessible inputs (Japanese era DatePicker, tabular-nums currency fields, Splitter panes), and virtual scrolling for thousands of records.
  • 120fps Motion Standard: Strictly SVG icons via Lucide Solid (zero emojis), GPU-composited transitions (transform / opacity), View Transitions API, Sync Pulse status indicators, and a Cmd+K cross-domain command palette.

In-Browser Storage & Multi-Tab Concurrency

  1. SQLite Wasm (opfs-sahpool + FTS5 trigram): Sub-50ms local full-text search across tens of thousands of records. Prioritizes opfs-sahpool (single-thread Dedicated Worker, no COOP/COEP or SharedArrayBuffer required).
  2. Physical Tenant Isolation: One SQLite file per tenant (/opfs/tenant_{tenant_id}.db), with clear_local_db_on_logout wiping OPFS data on shared terminals.
  3. Web Locks API + BroadcastChannel: navigator.locks.request elects a single leader tab owning the Web Worker; follower tabs proxy RPCs over BroadcastChannel and seamlessly take over if the leader closes.

Rust Wasm vs. Go sync-api Split

WorkloadRuntimeExamplesRationale
Pure Calculation & RulesRust core-enginePayroll/tax/social-insurance math (integer-only, no float), property matching, approval routing, SEO/AIO scoringZero network latency and zero server compute load
Local Search & AnalyticsSQLite Wasm + core-engineDocument search, ledger cross-tabs, cash-flow forecasting, demographic mesh aggregationFull tenant dataset is local; executes in milliseconds
Document GenerationRust doc-engine (Lazy)Approval PDFs, invoices, payslips, Zengin banking files, Excel/CSV, barcodes/QREliminates heavy server-side PDF rendering containers
Auth, RLS & Server AuthorityGo sync-api (ConnectRPC)Go Auth (Argon2id / Passkey / OIDC / __Host- Cookie), diff sync, document numbering, approval locks, reservation slot holds, monthly closing, disbursement Saga, R2 presigned URLs, SaaS proxyGuarantees atomicity across devices, hides secrets, and enforces RLS

Sync Protocol & Three-App Isolation

  • sync_log.seq & rbac_epoch: Monotonic seq cursor prevents missed commits; rbac_epoch triggers immediate local Tier 2 purge upon permission revocation. Non-retryable Push errors are evicted from Outbox to prevent poison pills.
  • Three Sync Tiers: Tier 1 (full sync for masters/active work), Tier 2 (RBAC & recency-scoped sensitive/historical data), Tier 3 (server-only: credentials, audit logs, >3-year archives, R2 binaries).
  • R2 Two-Phase Commit: Short-lived PUT presigned URL -> ConfirmUpload with Go-side HeadObject verification -> periodic GC for orphaned pending objects.
  • Three Separate Apps: apps/web (Staff, Local-First), apps/public (Citizens/Customers, lightweight Server-First without OPFS/COOP-COEP), and apps/admin (Platform Ops, isolated domain with MFA + Cloudflare Access).
Loading diagram...

3. Unified Domains & Large-Scale Public Data

DomainScope & Key CapabilitiesArchitectural Highlights
1. government-coreDocument management, approval workflows, org/staff/RBAC mastersuser_org_assignments supports multi-department concurrent posts; numbering & approval locks are server-authoritative
2. citizen-servicesVacant-house bank + 10 municipal modules (disasters, digital circular, elderly monitoring, health events, sports, attendance, language classes, regional insights, public data, bid qualifications)Dynamic per-tenant enablement via feature_entitlements; regional insight math runs in Rust core-engine
3. reservationsUnified phone (Twilio), Web, LINE, and counter bookings + AI voice/chatHoldReservationSlot enforces held (10-min TTL) -> confirmed under PostgreSQL row locks (zero double-booking)
4. communicationsAds (Meta/Google/LINE), social scheduling, LINE 1-on-1 chat & rich menus, CMS, SEO/MEO/AIO auditsProhibited-word checks and SEO/AIO scoring run instantaneously in core-engine
5. ledgerUnified party master (ledger_parties), employees, deals, purchases, payroll, expenses, reconciliation, monthly closingDeterministic integer-only Rust math; CloseLedgerMonth server lock blocks writes to closed months
6. paymentsCollections, disbursements, refunds, bank statement matching, Zengin format exportLocks amount/account hash at approval; executes external transfers via Transactional Outbox / Saga
7. integrationsGoogle Workspace (SSO/Directory/Calendar/Drive/Gmail), freee, LINE, Twilio, Stripe, GitHubOAuth tokens encrypted in sync-api (ProxyService); arbitrary URLs blocked to prevent SSRF

For nationwide public datasets (tens of millions of assembly-minute, tender, and grant chunks), data is collected and ONNX-embedded off-cluster, then queried on demand (Tier 3) via DuckDB (Parquet) + LanceDB on Cloud Run (min_instances=0) reading from same-region GCS.


4. Balancing Safety and Velocity (5 Quality Pillars, Quint/CUE, ETL Cutover)

  • Five Quality Pillars: Maintainability (single monorepo + Protobuf contract), Performance (P95 warm start < 1.5s, local FTS5 search < 50ms, INP < 100ms), Security (OPFS isolation + Go Auth + RLS), Reliability (offline recovery + server locks + integer math), and Observability (OpenTelemetry traceparent single Trace ID from @sentry/solid through Web Worker/Wasm, Go sync-api, Cloud SQL, and SaaS proxies with strict PII scrubbing).
  • Targeted Quint & CUE: Quint verifies only mission-critical state machines (diff sync, authority locks, disbursement Saga, tenant isolation), while CUE validates cross-cutting RBAC × Feature Toggle × Sync Tier policies and deployment configs—leaving CRUD and UI validation to native type systems and Property-Based Testing.
  • Zero-Base Schema + Deterministic ETL Cutover: No dual-write coexistence; a Go ETL CLI deterministically maps legacy IDs to UUIDv7 (via uuid_v5) and blocks cutover unless record counts, monetary totals, foreign keys, RLS, and R2 object checks pass 100% (Fail-Closed). Legacy repositories are preserved as Read-Only archives.

Summary

Combining in-browser Local-First responsiveness (SolidJS 2 + OPFS SQLite Wasm + Rust Wasm) with a minimal Go sync-api, targeted Quint/CUE formal verification, and deterministic ETL creates a sustainable, unified platform for both municipal and commercial operations.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list