SiteMap
An offline-first mobile app for facility inspection and equipment mapping, powered by PowerSync for real-time bidirectional sync between a local SQLite database and PostgreSQL.
What is SiteMap?
SiteMap is an offline-first React Native app designed for facility teams who need to document, reference, and manage equipment locations across large industrial spaces — factory floors, warehouses, and plant facilities where connectivity is unreliable or nonexistent.
Every interaction writes to a local encrypted SQLite database first. PowerSync handles bidirectional sync with PostgreSQL in the background — the user never waits for a network request. Data created offline syncs automatically when connectivity returns, and changes from other team members stream down in real time.
The Problem
Factory shutdowns, facility audits, and infrastructure inspections require teams to document where equipment is located and who's responsible for it. These environments are exactly where traditional cloud-dependent apps fail:
- Concrete walls, basements, and remote areas with no cell signal
- Paper checklists and hand-drawn diagrams that can't be shared
- Printed floor plans with handwritten notes that get lost
- Fragmented spreadsheets and email threads with no single source of truth
- Cloud-only apps that are unusable the moment connectivity drops
SiteMap solves this by putting the database on the device. PowerSync ensures every write is local-first and every read comes from SQLite — the network is used for sync, never as a dependency for core functionality.
Offline-First Architecture (PowerSync)
PowerSync is the backbone of SiteMap's offline-first architecture. It provides bidirectional sync between a local SQLite database on each mobile device and a central PostgreSQL server — so the app works at full speed with zero connectivity, and syncs transparently when a connection is available.
Sync Architecture
├─ Mobile App ──→ Writes to local SQLite (SQLCipher encrypted)
├─ PowerSync SDK ──→ Queues changes as CRUD transactions
├─ Upload path ──→ /api/sync/:table ──→ Upsert into PostgreSQL
├─ Download path ──→ PostgreSQL WAL ──→ PowerSync Server ──→ SQLite
└─ File uploads ──→ Queued separately ──→ Background upload to RustFS (S3)
Core Features
Collaboration
SiteMap includes a full collaboration layer built directly into the map viewer. Teams can discuss issues, track progress, and coordinate work without leaving the map.
Annotations & Checklists
Beyond markers, SiteMap supports freehand path drawing and location-based checklists for structured inspection workflows.
Service Requests
Operators on the plant floor can create IT service requests directly from the map, pinpointing exactly where the issue is and attaching photo evidence.
User Roles
SiteMap uses role-based access to match how plant teams actually work. Each role has capabilities tailored to their day-to-day responsibilities.
Use Cases
Dashboard & Administration
The web dashboard provides a centralized view of all facility data, recent activity, and platform administration.
Facility & Team Management
Organize work by facility and manage team relationships directly from the app. Users can be assigned to specific facilities and collaborate with teammates across roles.
Push Notifications
SiteMap includes a fully self-hosted push notification system — no third-party push services required beyond Apple and Google's native gateways. This serves as a reference implementation for anyone building custom push notifications in an open-source project.
Mobile App
├─ Register device token ──→ Web API ──→ PostgreSQL (push_devices)
└─ Receive notification ◀── APNs / FCM ◀── Gorush ◀── Go Server ◀── Web App
Object Storage (RustFS)
SiteMap uses a self-hosted S3-compatible object storage server (RustFS) for all file uploads — no third-party cloud storage required. All map images, marker photos, comment attachments, and checklist item photos are stored here.
Authentication & Security
SiteMap uses a self-hosted authentication system — no third-party auth providers required. The system supports email/password login, TOTP two-factor authentication, and WebAuthn passkeys (Face ID, Touch ID, Windows Hello) for passwordless sign-in.
Auth Flow
├─ Email + Password ──→ better-auth ──→ Session (cookie)
├─ Passkey (WebAuthn) ──→ SimpleWebAuthn ──→ JWT ──→ Session
└─ 2FA (TOTP) ──→ Authenticator App ──→ Verify code ──→ Session
iOS Deployment (Fastlane)
SiteMap includes a fully transparent iOS deployment pipeline built with Fastlane. All build scripts, configuration, and automation logic are committed to the repo so contributors can see exactly how builds are created and shipped to TestFlight.
Architecture
- Mobile: React Native + Re.Pack (iOS/Android)
- Web: React 19 + TanStack Start + TanStack DB + Drizzle ORM
- Database: PostgreSQL (server) + SQLite/SQLCipher (mobile)
- Sync: PowerSync (offline-first with cloud bridge)
- File Storage: RustFS (self-hosted S3-compatible)
- Push Notifications: Go microservice + Gorush (APNs/FCM gateway)
- Canvas/Interaction: react-native-skia (pan/zoom/markers)
- Infrastructure: Docker Compose for all services
Database
SiteMap uses PostgreSQL as its primary database, with a local SQLite replica on mobile devices for offline-first operation. A shared Zod schema package ensures type safety and consistency across all apps.
Migrations
Schema changes follow a structured workflow to keep PostgreSQL, Drizzle, PowerSync, and the shared type definitions in sync. Every migration touches multiple layers of the stack.
Migration Flow
1. Update Zod schema in shared package
2. Update Drizzle table in web app
3. Generate or write SQL migration
4. Apply migration to PostgreSQL
5. Update PowerSync table in mobile app
6. Update sync config + publication (new tables only)
Roadmap
Privacy & Data
All data is stored locally on your device first. Sync to external services is optional and configurable. You maintain full control over what data leaves your device and when.
Getting Started
- Create a new project
- Upload a floor plan photo
- Define custom icons for your equipment types
- Start marking locations on your map
- Add details and photos to each marker
- Configure PowerSync to sync data when ready
Credits
This app was built with the help of the following tools:
- shadcn/ui — component library and MCP server for AI-assisted UI development
- PowerSync — offline-first sync engine and AI agent skills for guided development
- better-auth — self-hosted authentication framework with 2FA support
- SimpleWebAuthn — WebAuthn/passkey implementation for passwordless authentication
- Re.Pack — Webpack/Rspack-based toolkit for React Native
- Rock.js — server framework
Built for teams who work in the field, in areas with unreliable connectivity, and need to maintain accurate facility documentation without cloud dependency.