Skip to content

Latest commit

 

History

History
161 lines (106 loc) · 5.97 KB

CLAUDE.md

File metadata and controls

161 lines (106 loc) · 5.97 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Development Commands

Development and Testing

# Start development server with debugging
pnpm dev

# Build for production
pnpm build

# Start production server
pnpm start

# Run tests
pnpm test              # Run all tests
pnpm test:unit         # Run unit tests only
pnpm test:e2e          # Run E2E tests
pnpm test:e2e:serial   # Run E2E tests serially
pnpm test:e2e:ui       # Run E2E tests with UI
pnpm test:coverage     # Run tests with coverage

# Code quality
pnpm format            # Format code and fix linting
pnpm lint              # Run linting
pnpm lint:fix          # Fix linting issues
pnpm lint:strict       # Run strict linting

Database and Schema

# Generate Prisma client
pnpm postinstall

# Database operations handled via Prisma CLI
# Database schema defined in prisma/schema.prisma

Architecture Overview

Tech Stack

  • Frontend: Next.js 15 with App Router, React 19, TypeScript
  • Styling: Tailwind CSS v4 with ShadCN/UI components
  • State Management: Zustand stores
  • Database: Prisma with PostgreSQL
  • Authentication: NextAuth v5
  • Testing: Vitest with Playwright E2E testing

Key Directories and Files

This section outlines the primary directories and key files, grouped by functionality, to help navigate the codebase. It includes core services, state management, UI components, API routes, utilities, authentication, and configuration.

Core Services

  • `app/services/***

State Management

  • app/stores/ - Zustand stores
  • app/interfaces/ - TypeScript interfaces

UI Components and Providers

  • app/components/ - Reusable components
  • app/components/xxx/ - xxx-specific componentsg

API Routes

  • app/api/ - Next.js API routes handling core functionality
  • app/llms.txt/route.ts - Dynamic endpoint for LLM model catalog (SEO-friendly)

Utilities and Helpers

  • app/utils/ - Shared utilities
  • app/lib/ - Library functions for Prisma DB access (prisma.ts), auth helpers (auth-helpers.ts)
  • app/lib/utils.ts - General-purpose utilities (e.g., cn() for classNames, toast notifications)

Authentication and Configuration

  • app/auth/ - Authentication pages and flows (e.g., verify-email/page.tsx for email verification)
  • lib/prisma.ts - Prisma client initialization and database connection pooling
  • .env.local - Environment variables
  • prisma/schema.prisma - Database schema defining

Testing and Documentation

  • test/ - Test suites (unit in test/unit/, E2E with Playwright in test/e2e/, integration in test/integration/)
  • docs/ - Architecture docs, use cases, bug fixes, and implementation summaries (e.g., docs/architecture-*.md)
  • docs/ARCHI.md - Comprehensive technical architecture specification for NextJS Starter Kit application
  • docs/PRD.md - Product requirements document detailing the core problem and MVP features

Development Guidelines

Store Development

  • Use normalized entity-relation patterns for performance
  • Always update both entities and relations together
  • Follow the existing state update patterns for consistency

Testing Strategy

  • Unit tests focus on services and utilities (test/unit/)
  • E2E tests use Playwright for full workflow testing (test/e2e/)
  • Integration tests combine service layer testing (test/integration/)

Performance Optimizations

  • Optimized rendering with Zustand state selectors
  • Context window management to prevent overflow

Typescript imports

  • "@/*" is link to @app
  • "auth" is link to @auth

Then always use @ import insted of relative/absolute path

logging

  • Never use console.xxx but use use a managed logger => log.xxx (import { log } from '@/utils/logger';)

Cursor Rules Integration

Cursor AI uses a rules system in .cursor/rules/ (.mdc files) to guide code generation and editing. These rules enforce project standards, best practices, and architecture patterns. Key rules (prioritized by importance) are summarized below; refer to the full files for detailed instructions.

Core and Agent Behavior

  • 000-agent.mdc: Defines agent behavior, tool usage, and response guidelines for Cursor interactions.
  • core.mdc: Fundamental project rules, including mode switching, tool selection, and task decomposition.
  • memory-bank.mdc: Memory management rules for context retention across sessions.

Best Practices and Conventions

  • 001-best-practise.mdc: General coding standards, error handling, performance tips, and security practices.
  • 100-naming-conventions.mdc: Naming rules for variables, functions, components, and files (e.g., camelCase for JS, PascalCase for components).
  • 103-readme.mdc: Guidelines for writing READMEs, documentation, and changelog entries.

Component Development

  • 101-client-components.mdc: Rules for React client components, hooks, and state management with Zustand.
  • 102-create-components.mdc: Patterns for creating new components, including ShadCN integration and accessibility.
  • 107-server-components.mdc: Next.js server components, data fetching, and SSR/SSG best practices.
  • 108-shadcn-ui.mdc: ShadCN/UI component usage, customization, and Tailwind integration.
  • 109-streaming-components.mdc: Streaming UI patterns for real-time AI responses, SSE handling, and LlmResponseRenderer.

Backend and Data

  • 104-nextjs-backend.mdc: API routes, server actions, authentication (NextAuth), and middleware rules.
  • 106-postgres.mdc: Prisma schema management, database migrations, queries, and PostgreSQL optimizations.

Refactoring and Updates

  • 300-refactor-ref-react-19.mdc: Guidelines for refactoring to React 19 features, hooks updates, and compatibility.

Usage Note: When using Cursor, these rules are automatically applied. For Claude Code or other tools, adapt these patterns manually. If a rule file is missing or needs updates, check the .cursor/rules directory.