Documentation

Technical documentation for the PestControlOS CRM and Android app.

Architecture, security, Firestore model, and feature details for developers and technical reviewers.

CRM: Contract management

Technical specification for contract management in the PestControlOS CRM (PWA).

Data model

  • Firestore: Technician-specific contract collections (e.g. [User] Contracts or per contractKey). Document fields: customer, address, visit frequency, last visit date, next visit (computed or stored), status (Overdue, Due Soon, On Schedule, No Date). Add contract; assign technician; add directly to calendar (creates or links calendar event).
  • Scoping: Contracts are scoped by technician access level. Admin can add/assign to any technician; technician sees only their own contracts. Firestore rules: read/write where request.auth.token.contractKey matches collection or role is admin/super_admin.

Operations

  • Add new contract: Create document in target technician’s contract collection. Assign technician via dropdown; assigned technician receives in-app notification (write to notifications/{user}/items in Firestore).
  • Track visits: Update last visit date; next visit calculated from frequency or stored. Status logic: Overdue (next visit past), Due Soon (within threshold), On Schedule, No Date.
  • Search and filter: Client-side or Firestore query by status, technician, customer name. Counters for Behind/Due/Up-to-date for UI.
  • Add to calendar: Create event in technician’s workview linked to contract; or link existing event. Ensures contract appears on schedule.

Rules

  • Contract collections are namespaced per technician. Rules must allow read/write only for that technician or admin/super_admin. No cross-technician read of contract documents unless admin.