You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/actions - Server-side mutations (Create, Update, Delete operations)
/app - Next.js App Router pages and API routes
/components - Reusable UI components organized by feature
/ui - Base UI components (buttons, inputs, dialogs)
/layout - Layout components (PageContainer, PageHeader, Section, Grid)
/editor - Plate.js editor components and plugins
/dashboard - Dashboard-specific components
/community - Community feature components
/data - Database queries and data fetching (Read operations)
/hooks - Custom React hooks for shared logic
/lib - Shared utility functions and configurations
/db - Database connection and Prisma client
/validation - Zod schemas for data validation
/imaging - Image processing utilities
/auth - Authentication utilities
/editor - Editor-related utilities
/public - Static assets (images, icons)
/schemas - Additional validation schemas
/types - TypeScript type definitions and DTOs
/prisma - Database schema and migrations
Component Organization (Context7 MCP Principles)
Group related components in feature-specific directories with clear separation of concerns
Keep component files focused on a single responsibility and co-locate related files when beneficial
Use index files for clean imports and separate complex components into smaller, composed parts
Follow the established pattern of using PageContainer, PageHeader, Section, and Grid for consistent layouts
Implement proper component composition patterns with props drilling minimized through context where appropriate
Error Handling (Context7 MCP Enhanced)
Implement robust error handling using the established ServerActionResult<T> pattern with consistent error response formats
Use the centralized error handling utilities in lib/server-action-utils.ts and provide clear user-friendly error messages
Handle Prisma errors consistently using handlePrismaError() function and implement proper validation error handling
Follow the established error handling pattern in server actions with structured error logging
Use error boundaries for React component error handling and handle upload errors gracefully
Implement retry logic for transient failures and provide loading states during async operations
Log errors with appropriate severity levels and include contextual information
Data Management (Context7 MCP Enhanced)
Interact with the database exclusively using Prisma ORM client with generated types for type safety
Implement data operations in separate layers: /actions for mutations, /data for queries
Use the commonSelects patterns for consistent data selection and apply proper error handling
Implement transaction support for complex operations and use Prisma's select for performance optimization
Follow established patterns for server actions with validation and implement proper caching strategies
Handle relationship management carefully and implement soft deletes where appropriate
Use proper indexing for performance-critical queries and database-level constraints
Security Guidelines (Context7 MCP Enhanced)
Validate all user inputs using Zod schemas consistently with proper sanitization
Implement proper authentication and authorization patterns using Auth.js with session management
Sanitize user-generated content before storage and display with proper rate limiting
Use environment variables for sensitive configuration and implement proper logging without exposing data
Follow secure coding practices for database operations and implement proper input validation
Use Content Security Policy (CSP) headers and implement proper error handling without information leakage
Follow established patterns for user data privacy and implement proper backup procedures
Performance Optimization (Context7 MCP Enhanced)
Use React Server Components by default and implement proper loading states with skeleton screens
Use Next.js Image component for all image assets and implement proper caching strategies
Implement proper memoization with React.memo, useMemo, useCallback and use debouncing patterns
Optimize database queries with proper Prisma selections and implement pagination for large datasets
Use streaming for better perceived performance and minimize bundle size with tree shaking
Implement proper lazy loading and use established patterns for optimistic updates
Handle large lists with virtualization when necessary and implement proper preloading
Layout System (Context7 MCP Standardized)
Use the unified layout components from /components/layout/ for consistent page structure:
PageContainer for standardized page wrappers with responsive sizing
PageHeader for unified page headers with consistent typography
Section for standardized content sections with proper spacing
Grid for responsive grid system with consistent breakpoints
Apply consistent spacing patterns and follow responsive design with mobile-first approach
Maintain consistent typography hierarchy across all pages with standardized container sizes
Commands and Tools (Context7 MCP Verified)
Lint and Type Check
Always run pnpm lint and pnpm ts:check before committing changes
Fix all linting and TypeScript errors with pnpm lint:fix for auto-fixable issues
Build and Test
Run pnpm build to ensure production builds work correctly
Run pnpm test to execute all Playwright tests with pnpm test:ui for interactive debugging
Database Operations
Use pnpm db:generate after schema changes and pnpm db:push to sync development database
Use appropriate seed commands for test data management
Context7 MCP Specialized Patterns
Server Action Pattern
// Use the createServerAction utility for consistent server actionsexportconstcreateDocument=createServerAction(createDocSchema,async(data)=>{// Implementation with proper validation, permission checks, and error handling// Return strongly typed results using Prisma generated types},'create','document');
Component Composition Pattern
// Use compound components with consistent prop interfaces<PageContainersize="lg"padding="md"><PageHeadertitle="Page Title"description="Page description"size="md"/><Sectionspacing="md"><SectionHeadertitle="Section Title"description="Section description"/><Gridcols="3"gap="md">{/* Content */}</Grid></Section></PageContainer>
Error Handling Pattern
// Use centralized error handling with proper logging contexttry{// Operation}catch(error){logger.logServerActionError('actionName','resourceName',error,{metadata: {/* contextual data */}});if(errorinstanceofPrisma.PrismaClientKnownRequestError){return{success: false,error: handlePrismaError(error)};}return{success: false,error: 'An unexpected error occurred'};}
Permission Checking Pattern
// Use centralized permission checkingconsthasPermission=awaitcheckDocumentPermission(userId,documentId,'write');if(!hasPermission){logger.logPermissionDenied('update','document',userId,{resourceId: documentId});return{success: false,error: 'Permission denied'};}
Qwen Agent Specific Instructions
Always analyze the existing codebase patterns before implementing new features
Use the established utility functions and helpers rather than reinventing functionality
Follow the file naming conventions: kebab-case for files, PascalCase for components
Prefer named exports over default exports for better tree-shaking
Use the custom logger for all logging operations with appropriate context
Implement comprehensive error handling with user-friendly messages
Ensure all components are properly typed with TypeScript
Use the established validation patterns with Zod schemas
Follow the responsive design principles implemented in the layout components
Implement proper accessibility attributes and semantic HTML