Project Structure
此内容尚不支持你的语言。
Product Factory is a pnpm monorepo managed with Turborepo. The codebase is organized into three top-level directories: apps/ for deployable applications, packages/ for shared libraries, and docs/ for internal engineering documentation.
Directory Layout
├── apps/│ ├── web/ # Marketing site + blog + user dashboard│ ├── admin/ # Admin console│ ├── platform/ # Platform workspace (future)│ ├── docs/ # Documentation site (Starlight)│ ├── worker-gateway/ # API gateway (Hono + Cloudflare Workers)│ ├── worker-auth/ # Authentication service│ ├── worker-billing/ # Billing and credits service│ ├── worker-ai/ # AI service (provider management, chat, completions)│ ├── worker-content/ # Content management service│ ├── worker-support/ # Support ticket service│ └── worker-admin/ # Admin backend service├── packages/│ ├── shared-types/ # Zod schemas, API contracts, type definitions│ ├── app-utils/ # Shared middleware, API helpers, auth utilities│ ├── ui/ # React + Radix UI component library│ ├── auth-core/ # Legacy auth package kept only for old tests/reference│ ├── billing-core/ # Billing repository and domain logic│ ├── ai-core/ # AI provider/model repository and gateway client│ ├── content-core/ # Content repository and domain logic│ ├── support-core/ # Support ticket repository and domain logic│ ├── project-core/ # Project/app-key management│ ├── email-templates/ # React Email templates│ └── db-schema/ # Drizzle ORM table definitions and database factory├── docs/ # Internal engineering docs (specs, plans)└── turbo.json # Turborepo pipeline configurationApps
Frontend Apps
| App | Port | Purpose |
|---|---|---|
web | 4322 | Marketing pages, blog, user dashboard, login/register |
admin | 4321 | Admin console for managing all platform resources |
docs | 4323 | Product documentation (this site) |
All frontend apps use Astro 5 with React Islands for interactive components.
Worker Services
| Worker | Purpose | Database |
|---|---|---|
worker-gateway | API gateway, session verification, request routing | No dedicated D1 database |
worker-auth | Better Auth handler, user profiles | auth-db |
worker-billing | Credits, subscriptions, orders, checkout | billing-db |
worker-ai | AI provider management, chat, completions, usage | ai-db |
worker-content | Blog posts, banners, friend links | content-db |
worker-support | Support tickets, messages, notifications | support-db |
worker-admin | Project management, user management, logs | admin-db |
All workers use Hono as the HTTP framework and Cloudflare D1 for data storage via Drizzle ORM.
Packages
Shared packages follow the @repo/<name> naming convention and are linked via pnpm workspaces.
| Package | Purpose |
|---|---|
shared-types | Zod schemas for API validation, TypeScript types, shared constants |
app-utils | Middleware (auth, CORS, rate limiting), API client helpers, Turnstile verification |
ui | React component library built on Radix UI primitives with Tailwind CSS |
db-schema | Drizzle ORM table definitions, createDb() factory, test helpers |
auth-core | Legacy package only; runtime auth lives in worker-auth + Better Auth |
billing-core | Credits, subscriptions, orders, pricing plan repositories |
ai-core | AI provider, model, API key, usage repositories |
content-core | Blog post, banner, friend link repositories |
support-core | Ticket, message, notification repositories |
project-core | Project and app-key management |
email-templates | React Email templates for transactional emails |
Build System
Turborepo manages the build pipeline. Key commands:
| Command | Description |
|---|---|
pnpm dev | Start all apps and workers in development mode |
pnpm build | Build all packages and apps |
pnpm test | Run all test suites |
pnpm typecheck | Type-check all packages and apps |
pnpm lint | Run Biome linting and formatting checks |