Skip to main content

SAPOT — Documentation Index

Browse this documentation as a website by running pnpm start inside docs/site/.

SAPOT (Search and Patrol Operations Technology) is a LAN-first disaster-response communications platform. It provides messaging, voice/video calls, GPS tracking, and announcements over a local-area network (LAN) when internet connectivity is unavailable. All core functions — messaging, peer discovery, and calls — operate without an internet connection. The server coordinates authentication, sync, and signalling but does not relay chat messages.


Components

NameRolePrimary StackLocal Docs
mobile-app/sapot-mobile-app/Android app — messaging, voice/video calls, GPS sharing, announcements, peer discoveryExpo, React Native, TypeScript, WatermelonDB, WebRTCMobile App Docs
server/Backend — auth, sync, signalling relay, GPS, admin, GSM proxy, MikroTik telemetryFastAPI, Python, MariaDB, Redis, Gunicorn
admin-frontend/sapot-admin/Admin/rescuer dashboard — user management, GPS map, network analyticsNext.js App Router, TypeScript
GSM-module/SMS gateway — sends SMS when LAN messaging failsFastAPI, pyserial, Arduino/AT commands
captive-portal/MikroTik hotspot login pages shown to users joining the networkStatic HTML/CSS/JS
tileserver/Offline map tile server for the GPS map
deploy/Offline, immutable Docker deployment bundle toolingBash, Docker Composedeployment/docker-bundle.md

By Role

RoleStart here
New developer / contributorGetting Started
QAqa/README.md
DevOpsdevops/README.md
Architectarchitecture/ and adr/

Documentation Index

Architecture

DocumentContents
architecture/system-overview.mdComponent responsibilities, system boundaries, communication matrix, roles
architecture/assumptions-and-constraints.mdConsolidated deployment assumptions and technical constraints, with links to the ADRs/threat model they come from
architecture/component-map.mdProcess/service topology, ports, deployment units, what talks to what
architecture/data-flow.mdSync flow, message delivery (WS relay, LAN P2P, SMS fallback), call signalling, GPS streaming — with Mermaid diagrams
architecture/networking-lan-model.mdLAN topology, MikroTik router role, mDNS discovery, client isolation considerations
architecture/security-architecture.mdAuth, password hashing, E2E encryption key hierarchy and flows, rate limiting, LAN transport security
architecture/threat-model.mdTrust boundaries, in-scope attack surfaces, device theft / router compromise / insider threat scenarios, known risks
adr/Architecture Decision Records — NaCl box, WatermelonDB, P2P calls, LAN-first design, roles model, Alembic server migrations

Mobile App (Detailed)

These live inside the mobile app sub-project at mobile-app/sapot-mobile-app/docs/:

DocumentContents
ONBOARDING.mdDeveloper onboarding — where complexity lives and how to navigate the codebase
ARCHITECTURE.mdService map, DI containers, transport modes, encryption, adapters
SYNC.mdPull/push sync cycle, trigger points, entity list, field normalization
API.mdREST endpoint reference
DATABASE.mdWatermelonDB schema and migrations
CALL_FLOW.mdCall lifecycle and message types
LAN_MESSENGER.mdLAN-only messaging behaviour and constraints
CONNECTION_MESSAGES.mdWebSocket, TCP, and WebRTC data-channel message catalogue
ENV_CONFIG.mdEnvironment variables, build variants, secure-storage keys
TESTING.mdTest utilities, mock patterns, conventions
STATE_MANAGEMENT.mdThe app's seven state mechanisms, sources of truth, debugging pain points
system-boundaries.mdUI/hooks/service layer boundaries
design-system.mdMaterial Design 3 theming via react-native-paper
conventions.mdCode style and TypeScript conventions
READABILITY_AUDIT.mdCodebase readability/maintainability audit
adr/Mobile-specific Architecture Decision Records (WebRTC reconnect/rebuild behaviour)
diagrams/Mermaid sequence diagrams for startup, LAN messaging, calls, GPS, SMS, guest user, security, encryption
audits/QA test cases, regression suite, automation plan

CI/CD

DocumentContents
.github/workflows/EXPO_ANDROID_CI_DOCUMENTATION.mdExpo Android CI/CD workflow

Getting Started

DocumentContents
getting-started/overview.mdComponent map and setup order
getting-started/quickstart.mdFull-stack "clone → run everything" happy path
getting-started/docker-setup.mdRun the full stack — server, admin dashboard, tileserver, SMS gateway — via Docker Compose (recommended)
getting-started/server-setup.mdRun the FastAPI server bare-metal (no Docker)
getting-started/mobile-app-setup.mdNix + Expo dev environment setup
getting-started/gsm-module-setup.mdSMS gateway setup
getting-started/admin-frontend-setup.mdNext.js admin dashboard setup

API

DocumentContents
api/README.mdHow to discover the live API base URL and spec (/docs, /redoc, /openapi.json)
api/conventions.mdShared API conventions (auth, errors, rate limits)
api/openapi/Committed OpenAPI YAML fragments per feature, generated from the live server

Database

DocumentContents
database/erd.mdEntity-relationship diagram (Mermaid)
database/schema-overview.mdServer (SQLModel) and mobile (WatermelonDB) schema overview
database/tables.mdFull column reference, server and mobile
database/migrations.mdServer (no tooling) and mobile (WatermelonDB schemaMigrations) migration strategy

Deployment

DocumentContents
deployment/overview.mdDeployment topology and component overview
deployment/server.mdFastAPI server deployment
deployment/environment-config.mdEnvironment variables for every component
deployment/secrets-management.mdSecret storage and rotation
deployment/monitoring-logging.mdMonitoring and logging setup
deployment/runbooks.mdBackup/restore, manual DB DDL application, TLS rotation, rollback, disaster recovery
deployment/incident-response.mdSeverity levels, roles, and communication process during a live incident
deployment/maintenance.mdRecurring backup/cert/log/dependency upkeep schedule
deployment/mobile-eas.mdMobile app EAS build/deploy
deployment/admin-frontend.mdAdmin dashboard deployment
deployment/gsm-module.mdGSM module deployment
deployment/tileserver.mdOffline tileserver deployment
deployment/docker-bundle.mdOffline Docker bundle build, install, upgrade, and recovery
deployment/install-ubuntu-server.mdFirst-install walkthrough: CA USB stick, Docker Engine on Ubuntu Server 24.04, build, transfer, install, verify

Features

Per-feature design/requirements/testing docs live under features/<name>/, each with a README.md summary: account-recovery, admin-management, authentication, calls, e2e-encryption, gps, messaging, sms-gateway, sync.


Troubleshooting

See TROUBLESHOOTING.md for common setup and connectivity failures across all components.

Glossary

See GLOSSARY.md for definitions of SAPOT-specific terms (roles, LAN, signalling, sync, etc.).


Root-Level Documents

DocumentContents
README.mdRepository overview, architecture, and quick-start links
CONTRIBUTING.mdBranching, commit conventions, and PR workflow
SECURITY.mdVulnerability disclosure process and known security posture
LICENSEMIT license
VERSIONING.mdGit-tag-driven versioning and release process (mobile, server, admin, captive portal, GSM module — independent)
CHANGELOG.mdNotable changes per release

Known Gap

Physical deployment steps — MikroTik router configuration for a real site, APK distribution to rescuer devices, onboarding rescuers at an incident site — are not yet documented. See devops/README.md and qa/README.md for what is covered for those workflows.