Firestore data model
Collections and their roles in PestControlOS.
Core collections
- users : Profile and role data keyed by Firebase Auth UID. Used for permissions and display.
- customers : Customer records (name, contact, addresses). Owned by organisation.
- sites : Physical locations (subcollection or top-level). Linked to customers.
- jobs : Visits/treatments. Link to site, technician, status, timestamps.
- previewRequests : Demo/signup requests from the marketing site. Create-only; no client read.
Important patterns
- Documents are keyed by auto-ID or stable IDs (e.g. UID). No sensitive data in IDs.
- Subcollections are used where a 1–many relationship is always accessed in context (e.g. notes under a job).
- Security rules enforce organisation/tenant isolation and role-based access. No cross-tenant reads.
Indexes
Composite indexes are defined for common queries (e.g. jobs by technician + date, jobs by site + status). Deploy via firestore.indexes.json.