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.
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.
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.
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).
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)
| Surface | Framework | Constraint Optimized For |
|---|---|---|
| Field PWA | SvelteKit (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 Portal | Next.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. |
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.
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;
}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.
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.
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.
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.
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.
| Dimension | Multi-Tenant Field SaaS | Gradilište OS (Single-Tenant VPS) |
|---|---|---|
| Data Location | Vendor-chosen region & external sub-processors | Single client-selected EU data center (Hetzner) |
| Tenancy Isolation | Logical (tenant_id row filter) | Physical VM isolation; zero shared tables |
| Data Export | Rate-limited REST API or gated CSV tier | Raw SQLite file + attachments directory (cp) |
| Pricing & Code | Annual price hikes, seat lock-in, closed source | 100% source code ownership, €0 license server |
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:
Because the SvelteKit PWA is offline-first, a VPS reboot never blocks jobsite capture. Server availability governs office sync latency, not field uptime.
Automated nightly encrypted S3 backups plus Hetzner volume snapshots allow full restoration onto a fresh VPS in under 10 minutes.
SQLite WAL on one node is sized for a single enterprise's operational write volume (thousands of daily events), not multi-tenant SaaS scale.
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 Vector | Commercial Per-Seat Field SaaS | Gradilište OS (DukaTrio Build) |
|---|---|---|
| Baseline Seat Assumption | 25 active users × €40/seat/mo | Unlimited 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 36 | None (Subscription termination = data lockout) | 100% Source Code, Docker Stack & SQLite Ledger |