Skip to content

Shared Packages

Product Factory’s shared packages live in packages/ and follow the @repo/<name> convention. They are linked via pnpm workspace protocol (workspace:*).

@repo/shared-types

The type foundation for the entire project.

Exports:

  • Zod schemas — Request/response validation schemas for all API endpoints, organized by domain (schemas/auth.ts, schemas/billing.ts, etc.).
  • TypeScript types — Inferred from Zod schemas for compile-time type safety.
  • Response helpersok(data) and err(code, message) functions for consistent API responses.
  • Env typeEnv interface defining all Cloudflare Worker bindings.

@repo/db-schema

Database schema definitions and utilities.

Exports:

  • Table definitions — 22 Drizzle ORM table schemas matching all D1 databases.
  • createDb(d1) — Factory wrapping D1 binding with Drizzle.
  • createMockD1() — Test helper creating in-memory SQLite databases.
  • AppDatabase — TypeScript type for the Drizzle database instance.

@repo/app-utils

Shared middleware and utility functions for frontend apps.

Exports:

  • authMiddleware — Astro middleware for session verification via the gateway.
  • apiClient — Typed HTTP client for calling gateway endpoints.
  • Turnstile verification — Server-side Cloudflare Turnstile token verification.
  • CORS middleware — Pre-configured CORS headers for Workers.

@repo/ui

React component library built on Radix UI primitives with Tailwind CSS.

Exports:

  • Primitives — Button, Input, Label, Dialog, Select, Tabs, etc.
  • Composed components — FormModal, DataTable, Toaster (Sonner).
  • Utilitiescn() class name merger.

Domain Packages

Each domain service has a corresponding core package:

PackageExports
@repo/billing-coreCreditRepository, OrderRepository, PlanRepository, CouponRepository, CheckinService, SubscriptionRepository
@repo/ai-coreProviderRepository, ModelRepository, ApiKeyRepository, UsageRepository, GatewayClient
@repo/content-corePostRepository, BannerRepository, FriendLinkRepository
@repo/support-coreTicketRepository, MessageRepository, NotificationRepository
@repo/project-coreProjectRepository, AppKeyRepository

All domain repositories accept an AppDatabase instance and expose async query methods.

Note: @repo/auth-core still exists in the repo for legacy tests/reference, but it is no longer part of the runtime authentication path. Runtime auth is handled by worker-auth with Better Auth.

@repo/email-templates

React Email templates for transactional emails.

Templates: Welcome, Password Reset, Payment Receipt, Subscription Changed, Ticket Created, Credits Low.

Templates are rendered to HTML and sent via Resend.