# FieldOps — Unified Field Force Platform + Thin Android GPS Tracker — Complete AI & LLM Reference Corpus (`llms-full.txt`) - Repository: https://github.com/mohan-n-swamy/fieldops-public - Web Discovery URL: https://mohan-n-swamy.github.io/repos/fieldops-public/ - License: MIT - Keywords: field-operations, field-service-management, gps-tracker, android, kotlin, offline-first, workforce-management, react, typescript, open-source --- ## File: `AI-README.md` — AI-README.md --- 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. 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. 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 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. 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. - 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` --- ## File: `.env.example` — Environment Contract (.env.example) ```ini # fieldops-public — Unified Field Force Web App + Android GPS Tracker + Dispatch Plugins PORT=4100 DATABASE_URL=postgresql://postgres:postgres@localhost:5432/fieldops FIELDOPS_GPS_PING_SECONDS=30 FIELDOPS_TRAIL_OFFLINE_BUFFER_MAX=2000 GEOFENCE_ZONES_PATH=./plugins/geofence_hub_validator/data/hub_zones.json PRE_VISIT_LEAD_WINDOW_MINUTES=90 ATTESTATION_MODE=mock ``` --- ## File: `AGENTS.md` — AGENTS.md # AGENTS.md — FieldOps — Unified Field Force Platform + Thin Android GPS Tracker Read this file first before modifying `fieldops-public`. ## Purpose 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. ## Commands ```bash 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 ``` ## Module Map - `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 ## Invariants 1. Keep all organization names, credentials, domains, and thresholds in `.env` or external config files. Never hardcode company names, host IPs, or secrets in source files. 2. Deterministic business logic belongs in code and lookup tables, not inside LLM prompts. 3. Update `docs/HLD.md`, `docs/LLD.md`, and `.env.example` in the same commit whenever an interface or environment variable changes. 4. Run the repository smoke check and secret scan before opening a pull request. --- ## File: `docs/PRD.md` — Product Requirements Document (docs/PRD.md) # Product Requirements Document — FieldOps — Unified Field Force Platform + Thin Android GPS Tracker 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. ## 1. Problem 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. ## 2. Users and Jobs-to-be-Done | Persona | Job-to-be-Done | |---|---| | Field Operations Director | Track live specialist locations, hub coverage, shift attendance, and wrong-hub dispatch exceptions from one command center. | | Mobile / Platform Engineer | Maintain reliable Android background GPS trails with 7 auditable Kotlin files instead of a 100-package cross-platform native build. | | Dispatch Coordinator | Receive automated pre-visit alerts 90 minutes before appointments requiring a senior technician. | ## 3. Core 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/`). ## 4. Configurable Inputs Adopters configure the system for their own organization without editing core application logic: | Variable | Default / Example | Purpose | |---|---|---| | `PORT` | `4100` | HTTP port for the FieldOps backend API | | `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5432/fieldops` | PostgreSQL connection URL | | `FIELDOPS_GPS_PING_SECONDS` | `30` | Foreground GPS sampling interval for the Android shell | | `GEOFENCE_ZONES_PATH` | `./plugins/geofence_hub_validator/data/hub_zones.json` | Polygon definitions for dispatch service hubs | | `PRE_VISIT_LEAD_WINDOW_MINUTES` | `90` | Lookahead window for senior-specialist pre-visit alerts | | `ATTESTATION_MODE` | `mock` | Device attestation & KYC adapter mode (`mock` for local dev, `live` for prod) | ## 5. Phasing and Stability Exit Criteria 1. **Phase 1 (Local Synthetic Run):** Clone the repository, copy `.env.example` to `.env`, and run the quickstart commands against synthetic seed data. Exit criterion: smoke checks pass with zero external credentials. 2. **Phase 2 (Read-Only Shadow Wiring):** Connect read-only credentials or webhook listeners in shadow/dry-run mode. Exit criterion: 100 consecutive events or queries reconcile cleanly against source records. 3. **Phase 3 (Production Cutover):** Enable live writes, alerts, or routing behind bounded retry and idempotency guards. ## 6. Non-Goals - Shipping organization-specific business rules hardcoded in application source. - Storing credentials, personal customer records, or tenant URLs inside version control. - Replacing deterministic validation or arithmetic with unconstrained model prompts. --- ## File: `docs/PR-FAQ.md` — Working-Backwards PR-FAQ (docs/PR-FAQ.md) # Working-Backwards PR-FAQ — FieldOps — Unified Field Force Platform + Thin Android GPS Tracker **Release Summary:** `fieldops-public` gives engineering and operations teams a self-hosted, open-source implementation of FieldOps — Unified Field Force Platform + Thin Android GPS Tracker that configures via `.env` and runs on standard infrastructure in minutes. ## Press Release Operations and engineering teams often rebuild the same internal workflows behind closed doors or pay per-seat SaaS markups for rigid tools that cannot match their field reality. `fieldops-public` open-sources a battle-tested implementation of FieldOps — Unified Field Force Platform + Thin Android GPS Tracker, stripped of all single-company assumptions and packaged with clear adapter boundaries, synthetic demo data, and machine-readable agent documentation. Any team can fork `fieldops-public`, supply their own `.env` inputs and taxonomy config, and deploy locally or in production with Docker, Python, or Node. AI coding assistants such as Claude Code, Codex, and Cursor can read `AI-README.md` and `llms.txt` to wire custom ERP, CRM, or warehouse adapters in a single session. ## External Adopter FAQ **Q1: How long does it take to run locally after cloning?** Under five minutes. Copy `.env.example` to `.env` and run the quickstart commands in `README.md`. Synthetic fixtures let you inspect the workflow before connecting live credentials. **Q2: Do I need to rewrite source files to use my own company name, channels, or rules?** No. Organization names, endpoints, thresholds, and credentials sit in `.env` and declarative config files. External system specifics live behind narrow adapter modules documented in `docs/LLD.md`. **Q3: What license governs this repository?** MIT License. You can fork, modify, self-host, and use it commercially without restriction. ## Internal Engineering & Security FAQ **Q4: How do we prevent tenant or employer data from ever entering a public fork?** The repository starts from a clean git history, excludes raw exports and binary dumps, validates every commit through `gitleaks`, and ships only synthetic fixtures. **Q5: What happens when an upstream API or model provider is slow or unavailable?** Inbound webhooks persist raw payloads before processing, outbound writes carry idempotency keys with bounded exponential backoff, and model-backed paths fail open to deterministic rules or explicit human queues. --- ## File: `docs/HLD.md` — High-Level Design (docs/HLD.md) # High-Level Design (HLD) — FieldOps — Unified Field Force Platform + Thin Android GPS Tracker 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. ## 1. System Topology ```mermaid flowchart LR APK["Thin Kotlin APK (LocationTrailService)"] -->|"FIFO batch flush"| API["FieldOps TypeScript API"] SQLite["Android SQLite Offline Buffer"] <--> APK Web["Mobile Field Web + Ops Command Center"] --> API Geo["plugins/geofence_hub_validator"] --> API Pre["plugins/pre_visit_alerts"] --> API API --> PG["PostgreSQL Day-Ledger & Trails"] ``` ## 2. Architectural Decisions and Rejected Alternatives | Decision | Why It Holds | Rejected Alternative | |---|---|---| | Thin 7-file Kotlin APK + Mobile Web UI | Gives native OS foreground-service GPS reliability while keeping 95% of UI/workflow changes instant on the web. | Full native app duplicating every form and workflow | | SQLite store-and-forward on device (`TrailDatabase.kt`) | Prevents trail gaps in elevators, basements, and rural dead zones. | Fire-and-forget HTTP location posts | | Pure ray-cast polygon check over local hub JSON | Validates thousands of coordinates per second at $0 API cost before invoking external geocoders. | Per-order Google Maps Geocoding API calls on every poll | ## 3. Data Flow and Failure Boundaries 1. **Configuration Boundary:** Startup validates `.env` variables and declarative config schemas before accepting traffic or running scheduled jobs. 2. **Adapter Boundary:** External services (databases, chat channels, HRMS, warehouses, or LLM providers) sit behind explicit adapter modules so failures stay isolated and testable with local mocks. 3. **Observability and Audit:** State transitions and job executions emit structured logs and deterministic status records rather than mutating state silently. ## 4. Scaling Notes - **1x to 10x load:** Single-node Docker Compose or process supervisor handles standard team workloads with indexed database queries and bounded worker concurrency. - **First bottleneck at 10x+:** High-frequency webhook or batch ingestion queues; mitigate by separating the stateless HTTP receiver from background worker processes sharing Redis or PostgreSQL locks. --- ## File: `docs/LLD.md` — Low-Level Design & Runbook (docs/LLD.md) # Low-Level Design (LLD) & Operations Runbook — FieldOps — Unified Field Force Platform + Thin Android GPS Tracker This document defines the module responsibilities, environment contract, and operational procedures for `fieldops-public`. ## 1. Module and File Inventory | Path | Responsibility | |---|---| | `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 | ## 2. Environment Variable Contract | Variable | Default / Example | Required | Description | |---|---|---|---| | `PORT` | `4100` | Yes | HTTP port for the FieldOps backend API | | `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5432/fieldops` | Yes | PostgreSQL connection URL | | `FIELDOPS_GPS_PING_SECONDS` | `30` | Yes | Foreground GPS sampling interval for the Android shell | | `GEOFENCE_ZONES_PATH` | `./plugins/geofence_hub_validator/data/hub_zones.json` | Yes | Polygon definitions for dispatch service hubs | | `PRE_VISIT_LEAD_WINDOW_MINUTES` | `90` | Yes | Lookahead window for senior-specialist pre-visit alerts | | `ATTESTATION_MODE` | `mock` | Yes | Device attestation & KYC adapter mode (`mock` for local dev, `live` for prod) | ## 3. Extension Recipe 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. ## 4. Operations Runbook ### 1. Verify geofence & pre-visit plugins ```bash pytest -q tests_plugins/ ``` ### 2. Run pure TypeScript domain unit suites ```bash cd backend && npx vitest run test/state-codes.test.ts test/trail.test.ts test/dayledger-rules.test.ts ``` ### 3. Export KML polygons to `hub_zones.json` ```bash Update `plugins/geofence_hub_validator/data/hub_zones.json` with `[{hub, polygon}]` coordinates ``` --- ## File: `docs/RESEARCH-2026.md` — 2026 Research & Landscape Notes (docs/RESEARCH-2026.md) # 2026 Open-Source Field Force Management & GPS Architecture Research Open-source field service stacks in 2026 typically force an awkward choice between heavyweight logistics platforms (Fleetbase, Odoo FSM) and standalone telematics servers (Traccar) while leaving mobile app maintenance split across large React Native / Flutter codebases that break on Android background-location policy updates. `fieldops-public` demonstrates the **Thin-Native-Shell + Web-Core** pattern: 1. **7-File Pure-Kotlin Android Shell (`org.fieldops.tracker`):** Handles the *only* capability browsers cannot do reliably — persistent foreground GPS collection (`LocationTrailService`), boot recovery (`BootReceiver`), watchdog restarts, and offline SQLite store-and-forward (`TrailDatabase`). 2. **Instant-Deploy Web & TypeScript Backend (`web/`, `backend/`):** Keeps 95% of business workflows (onboarding, shift rosters, attendance evaluation, command-center live map, and day-ledger close) deployable in seconds without app-store gatekeeping. 3. **Zero-Cost Geospatial & Pre-Visit Plugins (`plugins/`):** Ray-cast point-in-polygon hub validation runs in pure Python over exported GeoJSON/KML polygons before hitting paid geocoding APIs.