Deterministic, testable, and operationally credible reference implementation of an offline-first Point of Sale (POS) system with batch synchronization.
This project is organized as a monorepo using NPM Workspaces:
- apps/api: NestJS backend service with Prisma and PostgreSQL.
- apps/web: Next.js frontend application with IndexedDB.
- packages/sync-contract: Shared Zod schemas and TypeScript types (the "Single Source of Truth").
- infra: Docker orchestration and database configuration.
- docs: Architecture Decision Records (ADRs), technical guides, and runbooks.
- Idempotency: Client-generated keys (
externalId) with server-sideON CONFLICTenforcement. - State Machine: Explicit sync transitions (
PENDING->IN_FLIGHT->SYNCED|RETRYABLE_ERROR|FATAL_ERROR|DEAD_LETTER). - Database Discipline: Versioned migrations via Prisma (no manual SQL execution in production).
- API Hardening: Versioned endpoints (
v1/pos/sync) with strict runtime validation.
- Node.js >= 20
- Docker & Docker Compose
# Clone and enter
git clone https://github.com/IndexGrid/offline-first-sync-queue.git
cd offline-first-sync-queue
# Start infrastructure and apps
docker-compose -f infra/docker-compose.yml up -dAccess the dashboard at http://localhost:3000 and the API at http://localhost:3001.
# Install all dependencies
npm install
# Build shared contract first
npm run build -w packages/sync-contract
# Start services
npm run dev # (If global dev script is configured)
# OR
npm run start:dev -w apps/api
npm run dev -w apps/web- Backend Logs: Structured Winston logs with request correlation.
- Frontend Telemetry: Real-time sync queue depth and status distribution signals.
Licensed under MIT. Copyright (c) 2026 Index Grid.