Skip to content

Pro stack as platform packages: billing, sync, flags, shared edge utilities #10

Description

@ElbertePlinio

Refs pickforge/pickforge#152 (release umbrella), #132, #151, #133. Extends what's already here: @pickforge/auth (PKCE OAuth + entitlement reader) and supabase/migrations/…profiles_entitlements.sql.

Goal

The Pro stack lands as reusable platform packages, so the next Pickforge app gets accounts, billing, sync, and flags by installing packages instead of copying code. PickForge is the first consumer and the proof.

Packages

  • @pickforge/billing — Stripe kit: webhook Edge Function helpers (idempotent, replay-safe), customer/subscription/credit mirroring into Postgres, credit-ledger schema + TS helpers, Checkout session helper. Pairs with the existing entitlements migration.
  • @pickforge/sync — settings-sync engine from pickforge#151: field-group allowlist, LWW per group, per-machine overrides, data-boundary serialization guards. App supplies the field groups; engine stays generic.
  • @pickforge/flags — minimal runtime feature flags: default-off, typed flag registry per app, settings/debug surface hook. No remote config, no percentage rollouts — this is release gating, not experimentation infra.
  • supabase/functions/_shared/ — shared Edge Function utilities: entitlement check, credit debit, idempotency keys. App-specific functions (e.g. PickForge's Operator router, pickforge#133) compose these; they do not live here.

Boundary rules

  • Packages are UI-free; app UI, product behavior, and offline degradation stay in app repos (same line @pickforge/auth already draws — its README's "billing stays in app repos" note gets updated to point at @pickforge/billing).
  • Build with PickForge as the first consumer; nothing lands here without a consuming PR in pickforge. No speculative config or premature generality.
  • Migrations here are the canonical schema; each app's Supabase project applies them.

Checklist

  • @pickforge/flags (smallest, unblocks every flagged track)
  • @pickforge/billing + schema migrations (consumed by pickforge#132)
  • _shared/ Edge Function utilities (shipped as @pickforge/edge-shared; first consumer: stripe-webhook fn)
  • @pickforge/sync (consumed by pickforge#151 — app slice pending)
  • auth README boundary note updated

Validation

  • Package unit tests + coverage in this repo's bun run check
  • Each package's first consuming PR in pickforge passes its own validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions