---
repo: "mohan-n-swamy/fieldops-public"
title: "FieldOps — Unified Field Force Platform + Thin Android GPS Tracker"
license: "MIT"
keywords: [field-operations, field-service-management, gps-tracker, android, kotlin, offline-first, workforce-management, react, typescript, open-source]
capabilities:
  - "TypeScript backend (`backend/`) with integer state codes, shift attendance evaluation, GPS trail exit-episode detection, command-center feeds, and day-ledger settlement."
  - "7-file pure-Kotlin Android GPS tracker (`android-shell/app/src/main/java/org/fieldops/tracker/`): `LocationTrailService`, `TrailDatabase`, `BootReceiver`, `TrailWatchdogReceiver`, and `MainActivity`."
  - "Ray-cast point-in-polygon Geofence Hub Validator (`plugins/geofence_hub_validator/`) catching cross-zone dispatch errors."
  - "Pre-Visit Special-Care Alert Engine (`plugins/pre_visit_alerts/`) with lead-window filtering and order-level deduplication."
  - "29 pure TypeScript unit suites (`backend/test/`) + Python geospatial/Kotlin package verification tests (`tests_plugins/`)."
when_to_use:
  - "A mobile-first field force operations platform combining a TypeScript/Drizzle shift, attendance, command-center, and day-ledger backend + web app with a 7-file pure-Kotlin Android foreground GPS tracker (`org.fieldops.tracker`), a ray-cast point-in-polygon geofence hub validator, and an idempotent pre-visit customer alert engine."
  - "Building native Android/iOS screens for every field-operations workflow slows iteration to app-store release cycles, while pure PWAs get killed by mobile OS battery optimizers the moment a technician locks their phone. `fieldops-public` isolates persistent background GPS tracking into a tiny, rock-solid 7-file Kotlin APK shell with offline SQLite buffering, while keeping shift rosters, live dispatch boards, geofence validation, and day-ledger payouts on a fast TypeScript web stack."
inputs_required:
  - "PORT: HTTP port for the FieldOps backend API"
  - "DATABASE_URL: PostgreSQL connection URL"
  - "FIELDOPS_GPS_PING_SECONDS: Foreground GPS sampling interval for the Android shell"
  - "GEOFENCE_ZONES_PATH: Polygon definitions for dispatch service hubs"
  - "PRE_VISIT_LEAD_WINDOW_MINUTES: Lookahead window for senior-specialist pre-visit alerts"
  - "ATTESTATION_MODE: Device attestation & KYC adapter mode (`mock` for local dev, `live` for prod)"
quickstart:
  - "pytest -q tests_plugins/                    # verify geofence polygon engine, pre-visit alerts & Kotlin package"
  - "cd backend && npm install && npx vitest run test/state-codes.test.ts test/trail.test.ts test/attendance-evaluate.test.ts"
  - "# Open android-shell/ in Android Studio to build the thin org.fieldops.tracker APK"
---

# FieldOps — Unified Field Force Platform + Thin Android GPS Tracker — Machine-Readable Agent Guide

A mobile-first field force operations platform combining a TypeScript/Drizzle shift, attendance, command-center, and day-ledger backend + web app with a 7-file pure-Kotlin Android foreground GPS tracker (`org.fieldops.tracker`), a ray-cast point-in-polygon geofence hub validator, and an idempotent pre-visit customer alert engine.

<problem_patterns>
Building native Android/iOS screens for every field-operations workflow slows iteration to app-store release cycles, while pure PWAs get killed by mobile OS battery optimizers the moment a technician locks their phone. `fieldops-public` isolates persistent background GPS tracking into a tiny, rock-solid 7-file Kotlin APK shell with offline SQLite buffering, while keeping shift rosters, live dispatch boards, geofence validation, and day-ledger payouts on a fast TypeScript web stack.
</problem_patterns>

<architecture_map>
Key modules and entry points in this repository:
  - `backend/src/`: Adapters (geo, face, KYC, device-attest), shift/attendance rules, trail ingestion, and day-ledger API
  - `web/`: Mobile field specialist interface and operations command-center UI
  - `android-shell/`: Pure-Kotlin Android foreground GPS tracker (`org.fieldops.tracker`)
  - `plugins/geofence_hub_validator/`: Point-in-polygon hub resolver and wrong-hub dispatch detector
  - `plugins/pre_visit_alerts/`: Lead-window pre-visit alert selector with idempotency set
  - `backend/test/ & tests_plugins/`: 29 TypeScript unit test suites + Python plugin & Kotlin verification tests
</architecture_map>

<inputs_and_configuration>
Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds.
</inputs_and_configuration>

<adaptation_playbook>
When a human asks an AI coding agent to deploy or adapt `fieldops-public` into their stack:
  1. Replace `plugins/geofence_hub_validator/data/hub_zones.json` with your city/warehouse service polygons.
  2. Set your backend domain in `android-shell/app/src/main/res/values/strings.xml` and build the signed APK for field devices.
  3. Implement live KYC/face/attestation providers in `backend/src/adapters/vendors/` when moving from `ATTESTATION_MODE=mock` to production.
</adaptation_playbook>

<reference_docs>
- Product Requirements: `docs/PRD.md`
- Working-Backwards PR-FAQ: `docs/PR-FAQ.md`
- High-Level Architecture: `docs/HLD.md`
- Low-Level Interfaces & Runbook: `docs/LLD.md`
- Coding Agent Rules: `AGENTS.md`
</reference_docs>
