Skip to main content

Firestore Data Model

Firestore is the control plane for users, jobs, entitlements, application configuration, audit records, and coach relationships. Large video and report objects live in Cloud Storage; their paths are stored in Firestore.

The executable source of truth is acesense-frontend/firestore.rules plus the writers in acesense-auth-function. This page is an orientation map, not a schema migration system.

Core collectionsโ€‹

CollectionIDPurposeClient access
usersFirebase UIDprofile, consent, entitlement, usage, onboardingowner read; profile/consent fields only for owner writes
jobsserver-generatedupload, orchestration, status, result referencesowner read; presentation fields only for owner updates
sessionsgenerateduser-created session historyowner read/write
users/{uid}/notificationsgeneratedanalysis-ready and account notificationsowner read; owner may change only read
confignamed documentpublic app-version gate and admin configurationconfig/app public-read; other access admin-only

requestUploadPath is the only app-side job creator. Session deletion goes through deleteSession so the job and private Storage artifacts are removed together.

Commerce and operationsโ€‹

CollectionPurposeWrite owner
api_keyshashed API-key metadata, balance, usageCloud Functions
api_keys/{id}/rate_bucketsminute/day rate accountingCloud Functions
api_keys/{id}/balance_adjustmentsbalance audit trailadmin callables
billing_eventsidempotent billing-webhook receiptsCloud Functions
pending_plan_grantsdeferred account grantsCloud Functions
link_codesdownload/campaign redirect registryadmins
download_clicksredirect attribution eventsCloud Functions

Coach modeโ€‹

CollectionPurposeRead access
coachescoach profile and seat statethat coach or admin
coachLinkstwo-party coach/player consent stateeither party or admin
coachNotesappend-only coach feedbacklinked coach/player or admin

Mutations go through callables. An active link does not widen direct reads of a player's users or sessions documents; server callables broker that access.

Feedback, mail, and audit dataโ€‹

  • feedback: authenticated app submissions; append-only to the client.
  • docs_feedback: private-docs feedback written by docsServer.
  • client_errors: bounded client-side diagnostic events.
  • mail: server-only Trigger Email queue.
  • signed_url_audit, moderation_audit, and admin_audit: server-written, admin-readable audit trails.

User document ownershipโ€‹

Users may change profile and UX fields such as display name, locale, tennis profile, notification preferences, onboarding state, and AI consent. Plan, tier, trial dates, subscription limits, usage counters, suspension state, and other entitlement fields are server-owned. Treat the rule allowlist as authoritative whenever a new field is added.

Job relationshipโ€‹

See Job Document for the job state contract and Security Model for rule boundaries.