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 helpers —
ok(data)anderr(code, message)functions for consistent API responses. - Env type —
Envinterface 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).
- Utilities —
cn()class name merger.
Domain Packages
Each domain service has a corresponding core package:
| Package | Exports |
|---|---|
@repo/billing-core | CreditRepository, OrderRepository, PlanRepository, CouponRepository, CheckinService, SubscriptionRepository |
@repo/ai-core | ProviderRepository, ModelRepository, ApiKeyRepository, UsageRepository, GatewayClient |
@repo/content-core | PostRepository, BannerRepository, FriendLinkRepository |
@repo/support-core | TicketRepository, MessageRepository, NotificationRepository |
@repo/project-core | ProjectRepository, AppKeyRepository |
All domain repositories accept an AppDatabase instance and expose async query methods.
Note:
@repo/auth-corestill exists in the repo for legacy tests/reference, but it is no longer part of the runtime authentication path. Runtime auth is handled byworker-authwith 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.