Skip to main content

Pivot POS Service Specification

Status: Draft

Last Updated: December 2025 Related Documents: POS Integration Strategy


Overview

This specification defines a standalone POS integration service that operates independently from the main Pivot Firebase infrastructure. The service is built on:

  • Cloud Run for compute (replacing Firebase Functions)
  • BigQuery for data storage (replacing Firebase Realtime Database)
  • Cloud Scheduler for periodic sync jobs
  • TypeScript/Node.js as the runtime

This architecture mirrors the existing pivot-docs and pivot-kpi services, providing a battle-tested deployment pattern.


Why a Separate Service?

ConcernFirebase FunctionsCloud Run Service
Cold Start3-10 seconds<1 second (min instances)
Execution Limit9 minutes max60 minutes max
Memory8GB max32GB max
Concurrency1 per instance80+ per instance
Cost at ScalePer invocationPer CPU-second
DeploymentCoupled to FirebaseIndependent CI/CD
DatabaseFirebase RTDB (NoSQL)BigQuery (Analytics-optimized)

POS integrations require:

  • Long-running data syncs (historical backfills)
  • High write volume, infrequent reads
  • Analytics-friendly query patterns
  • Independent scaling from main app

Document Structure

For Product/Business Stakeholders

  • Overview - Business case, goals, success metrics

For Technical Team


Quick Reference

Service Name: pivot-pos-service Port: 7492 (dev) Repository: pivot-meta/pivot-pos (new) Terraform: pivot-devops/infrastructure/dev/pivot-pos/

Endpoints:

POST /sync/toast/:companyId     - Trigger Toast sync for company
GET /health - Health check
POST /webhooks/toast - Toast webhook receiver (future)

Cloud Scheduler Jobs:

pivot-pos-sync-hourly   - Sync all active POS integrations

Architecture Diagram


Implementation Phases

Phase 1: Foundation

  • Cloud Run service with Express/Fastify
  • BigQuery schema and initial tables
  • Toast authentication implementation
  • Basic sync for employee roster

Phase 2: Core Data

  • Time clock sync (in/out punches)
  • Sales per employee
  • Tips per employee
  • Incremental sync with timestamps

Phase 3: Production Hardening

  • Cloud Scheduler integration
  • Error handling and retries
  • Alerting and monitoring
  • Historical backfill support

Phase 4: Additional POS Systems

  • Square integration
  • Clover integration
  • Silverware integration

Decision Log

DecisionChoiceRationale
StorageBigQuery over PostgreSQLAnalytics-optimized, serverless, cost-effective for write-heavy/read-light workloads
ComputeCloud Run over Cloud FunctionsLonger execution, better cold starts, independent deployment
LanguageTypeScriptTeam familiarity, type safety, matches pivot-kpi
FrameworkExpress.jsSimplicity, ecosystem, matches existing services