4.5 KiB
4.5 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Development Commands
Core Development
pnpm dev
- Start development server with content collectionspnpm build
- Build the application and content collectionspnpm start
- Start production serverpnpm lint
- Run Biome linter (use for code quality checks)pnpm format
- Format code with Biome
Database Operations (Drizzle ORM)
pnpm db:generate
- Generate new migration files based on schema changespnpm db:migrate
- Apply pending migrations to the databasepnpm db:push
- Sync schema changes directly to the database (development only)pnpm db:studio
- Open Drizzle Studio for database inspection and management
Content and Email
pnpm content
- Process MDX content collectionspnpm email
- Start email template development server on port 3333
Project Architecture
This is a Next.js 15 full-stack SaaS application with the following key architectural components:
Core Stack
- Framework: Next.js 15 with App Router
- Database: PostgreSQL with Drizzle ORM
- Authentication: Better Auth with social providers (Google, GitHub)
- Payments: Stripe integration with subscription and one-time payments
- UI: Radix UI components with TailwindCSS
- State Management: Zustand for client-side state
- Internationalization: next-intl with English and Chinese locales
- Content: Fumadocs for documentation and MDX for content
- Code Quality: Biome for formatting and linting
Key Directory Structure
src/app/
- Next.js app router with internationalized routingsrc/components/
- Reusable React components organized by featuresrc/lib/
- Utility functions and shared codesrc/db/
- Database schema and migrationssrc/actions/
- Server actions for API operationssrc/stores/
- Zustand state managementsrc/hooks/
- Custom React hookssrc/config/
- Application configuration filessrc/i18n/
- Internationalization setupsrc/mail/
- Email templates and mail functionalitysrc/payment/
- Stripe payment integrationsrc/credits/
- Credit system implementationcontent/
- MDX content files for docs and blogmessages/
- Translation files (en.json, zh.json) for internationalization
Authentication & User Management
- Uses Better Auth with PostgreSQL adapter
- Supports email/password and social login (Google, GitHub)
- Includes user management, email verification, and password reset
- Admin plugin for user management and banning
- Automatic newsletter subscription on user creation
Payment System
- Stripe integration for subscriptions and one-time payments
- Three pricing tiers: Free, Pro (monthly/yearly), and Lifetime
- Credit system with packages for pay-per-use features
- Customer portal for subscription management
Feature Modules
- Blog: MDX-based blog with pagination and categories
- Docs: Fumadocs-powered documentation
- AI Features: Image generation with multiple providers (OpenAI, Replicate, etc.)
- Newsletter: Email subscription system
- Analytics: Multiple analytics providers support
- Storage: S3 integration for file uploads
Development Workflow
- Use TypeScript for all new code
- Follow Biome formatting rules (single quotes, trailing commas)
- Write server actions in
src/actions/
- Use Zustand for client-side state management
- Implement database changes through Drizzle migrations
- Use Radix UI components for consistent UI
- Follow the established directory structure
- Use proper error handling with error.tsx and not-found.tsx
- Leverage Next.js 15 features like Server Actions
- Use
next-safe-action
for secure form submissions
Configuration
- Main config in
src/config/website.tsx
- Environment variables template in
env.example
- Database config in
drizzle.config.ts
- Biome config in
biome.json
with specific ignore patterns - TypeScript config with path aliases (@/* for src/*)
Testing and Quality
- Use Biome for linting and formatting
- TypeScript for type safety
- Environment variables for configuration
- Proper error boundaries and not-found pages
- Zod for runtime validation
Important Notes
- The project uses pnpm as the package manager
- Database schema is in
src/db/schema.ts
with auth, payment, and credit tables - Email templates are in
src/mail/templates/
- The app supports both light and dark themes
- Content is managed through MDX files in the
content/
directory - The project includes comprehensive internationalization support