ARCHITECTURAL CASE STUDYSvelteKit (Field PWA) + Next.js 16 (Command Portal)PocketBase (Embedded SQLite WAL)

Gradilište OS: Offline-First Construction Operations on a Self-Hosted Stack.

How we replaced lost paper delivery dockets and cloud-dependent field apps with a split-surface SvelteKit & Next.js 16 architecture, client-side IndexedDB UUIDv7 outbox queuing, on-device WebAssembly camera OCR, and PocketBase (Embedded SQLite WAL) on a single-tenant Hetzner VPS.

VERIFIED PRODUCTION TELEMETRY // OUTCOME SUMMARYDomain: Concrete & Materials Logistics · 100% Client IP Ownership
−80%
Administrative Ticketing Delay

Elapsed time from physical mixer arrival on site to a verified, reconcilable ledger entry in the back office.

€0
Recurring User Licensing

Unlimited drivers, foremen, subcontractors, and back-office staff with zero per-seat SaaS tax or App Store gatekeeping.

< €15/mo
Infrastructure Footprint

Amortized monthly cost for the entire Docker + Caddy v2 + PocketBase stack on a dedicated EU Hetzner Cloud VPS.

SECTION 01 // THE OPERATIONAL FAILURE

1. Why Commercial Cloud SaaS Fails on Construction Sites

Construction sites break the assumptions commercial field-management SaaS is built on. Most cloud products assume three things: a continuous network connection, a stable headcount, and data that starts out digital. On an active jobsite, none of those hold.

1.1 Connectivity Dead Zones

Blocking Writes & Auth Expiry

Basements, underground garages, reinforced-concrete cores, and rebar cages routinely drop signal to zero. Cloud-first forms block on API calls, time out, or expire auth tokens while offline—sending foremen back to a login screen and losing whatever was in memory.

1.2 Per-Seat Field Taxes

Seat Rationing Destroys Auditability

Workforce size swings across foundation, structure, and finishing phases. Per-user pricing (€40–€65/seat/mo) pushes firms to ration accounts and share a single login across multiple foremen—destroying the exact audit trail the software was bought to provide.

1.3 Paper Delivery Dockets

Lost Evidence & 90-Min Pour Windows

Every ready-mix truck arrives with a physical paper docket: supplier, mix design, volume (m³), batch time, departure time, and truck ID. Slips get wet, torn, or sit in jacket pockets for days while fresh concrete faces a strict 90-minute discharge window (ASTM C94).

SECTION 02 // ARCHITECTURAL BLUEPRINT

2. Architectural Blueprint: Device as Primary Write Target

The governing design rule throughout Gradilište OS: the field device is the primary write target; the server is the eventual system of record. Every field action completes locally and deterministically with zero network round-trip.

2.1 Split Front-End Architecture: SvelteKit (Field PWA) + Next.js 16 (Command Portal)

SurfaceFrameworkConstraint Optimized For
Field PWASvelteKit (Static PWA + SW)Low-end Android devices, intermittent 3G/EDGE, gloved one-handed use. Compiles to tiny, runtime-light bundles with minimal memory pressure alongside the camera and WebAssembly OCR worker.
Command PortalNext.js 16 (App Router Standalone)Data-dense reconciliation tables, supplier invoice auditing, dual-currency payroll engines, and CSV/PDF exports on office desktops with stable connectivity.
2.2 PocketBase (Embedded SQLite WAL) as the Unified Backend

PocketBase compiles into a single Go binary bundling SQLite in Write-Ahead Logging (WAL) mode, JWT authentication, collection-level access rules, local file storage, and real-time subscriptions over Server-Sent Events (SSE). For a single-company operational workload, this eliminates four separate moving parts (external DB server, third-party auth vendor, cloud object bucket, and pub/sub broker):

  • SQLite WAL Concurrency

    Field writes arrive in bursty batches. With WAL enabled, concurrent office readers and the single writer never block each other.

  • Declarative RBAC Rules

    Server-enforced collection expressions (@request.auth.role = "foreman") isolate site records regardless of client state.

  • SSE Realtime Dispatch

    The Next.js 16 Command Portal subscribes over SSE; synced field dockets appear on the headquarters ledger within milliseconds.

2.3 Client-Side IndexedDB Sync Queue (UUIDv7 Outbox Pattern)

Every field mutation writes to IndexedDB inside a single atomic transaction: the materialized record that the SvelteKit UI reads from immediately, and an OutboxEntry describing the pending mutation. Record IDs are generated on the client using time-ordered UUIDv7 at the moment of capture, so records and photo attachments can reference each other offline without temporary ID remapping.

interface OutboxEntry {
  id: string;              // UUIDv7, doubles as idempotency key
  collection: "deliveries" | "pours" | "timesheets" | "attachments";
  op: "create" | "update";
  recordId: string;        // Client-generated UUIDv7 before server contact
  payload: Record<string, unknown>;
  createdAt: number;       // Device clock, for display only
  attempts: number;
  lastError?: string;
}
iOS Safari Sync Fallback

While Chromium/Android utilizes the Service Worker Background Sync API, iOS Safari does not implement Background Sync. We engineered deterministic fallback listeners on online, visibilitychange, and app-launch events so iPhones flush the outbox reliably the second signal returns.

Idempotency & Append-Only Dockets

Client-generated UUIDv7 keys make create operations strictly idempotent across interrupted network flushes. Delivery dockets are modeled as immutable append-only events; corrections link as child audit records rather than overwriting original evidence.

2.4 On-Device Web Worker Camera OCR

OffscreenCanvas Pre-Processing + WASM OCR

Thermal and dot-matrix delivery slips photographed in harsh sunlight undergo grayscale conversion, adaptive thresholding, and deskewing on an OffscreenCanvas before passing to a WebAssembly OCR engine inside a Web Worker. Supplier, docket number, mix class, volume (m³), and departure time are extracted on-device, starting the 90-minute hydration countdown immediately.

2.5 Self-Hosted Docker on Hetzner with Caddy v2

Zero-Downtime Field Continuity

The entire stack runs via docker composeon an EU Hetzner Cloud VPS behind Caddy v2 (automatic Let's Encrypt TLS, HTTP/3 QUIC, reverse proxy). Scheduled off-site S3 backups and volume snapshots protect the SQLite WAL state, and server restarts are completely invisible to field crews working from device cache.

SECTION 03 // SECURITY & DATA SOVEREIGNTY

3. Zero-Dependency Private VPS vs. Multi-Tenant Cloud Lock-In

Gradilište OS makes zero runtime calls to external third-party APIs: OCR executes on the phone, while auth, relational storage, and realtime sync run inside PocketBase on the client's own EU server.

DimensionMulti-Tenant Field SaaSGradilište OS (Single-Tenant VPS)
Data LocationVendor-chosen region & external sub-processorsSingle client-selected EU data center (Hetzner)
Tenancy IsolationLogical (tenant_id row filter)Physical VM isolation; zero shared tables
Data ExportRate-limited REST API or gated CSV tierRaw SQLite file + attachments directory (cp)
Pricing & CodeAnnual price hikes, seat lock-in, closed source100% source code ownership, €0 license server
3.4 Operational Trade-Offs & Failure ModesARCHITECTURAL TRANSPARENCY

What a Single-Node Self-Hosted Architecture Accepts—and How We Mitigate It

A single VPS is a single point of failure, and self-hosting shifts operational responsibility away from a SaaS vendor. Those trade-offs are accepted deliberately and engineered around across three axes:

1. Availability vs. Field Uptime

Because the SvelteKit PWA is offline-first, a VPS reboot never blocks jobsite capture. Server availability governs office sync latency, not field uptime.

2. Deterministic Disaster Recovery

Automated nightly encrypted S3 backups plus Hetzner volume snapshots allow full restoration onto a fresh VPS in under 10 minutes.

3. Single-Tenant Write Ceiling

SQLite WAL on one node is sized for a single enterprise's operational write volume (thousands of daily events), not multi-tenant SaaS scale.

SECTION 04 // VERIFIABLE ROI & PAYOFF

4. Verifiable ROI: €4,800 Fixed Milestone vs. €43,200 Commercial SaaS Tax

By moving OCR execution onto the field crews' existing smartphones and eliminating per-seat licensing, Gradilište OS reaches break-even in under 5 months while turning software expenditure into a permanent company-owned asset.

Illustrative 36-Month Total Cost of Ownership (25 Field + Office Users)

Break-Even Horizon: ~4.1 Months
Cost VectorCommercial Per-Seat Field SaaSGradilište OS (DukaTrio Build)
Baseline Seat Assumption25 active users × €40/seat/moUnlimited seats · €0/user/mo
Initial Engineering / Setup€0€4,800 (One-Time Fixed Milestone)
36-Month Seat & Module Licensing€43,200 (incl. OCR & API tier add-ons)€0
36-Month Infrastructure (Hetzner VPS + Backups)Bundled in seat tax< €540 (< €15/mo × 36 mos)
36-Month Total Cash Outflow€43,200< €5,340 (Net Savings: €37,860+)
Asset Owned at Month 36None (Subscription termination = data lockout)100% Source Code, Docker Stack & SQLite Ledger
DEPLOY THIS ARCHITECTURE IN 10–14 DAYS

Ready to Replace Paper Field Tickets & Per-Seat SaaS Taxes?

We engineer bespoke Offline Field Operations PWAs and Command Portals on the exact Gradilište OS blueprint for a flat €4,800 milestone with 100% source code handover.

Direct Systems Inquiry Terminal
Zero-Spam Honeypot Protected
Direct TLS Ingestion · Zero Client-Exposed RecipientSLA: < 12 Hours