Code Organization
Feature Development
When adding new features:- Create a new directory in
src/features/
- Add feature-specific components and subcomponents
- Keep components focused and reusable
Component Development
Components should follow these guidelines:- Use TypeScript for all components
- Implement proper prop types
- Use shadcn/ui components when possible
- Follow atomic design principles
State Management
When to Use What
-
React Context
- Global UI state
- Theme preferences
- Auth state
-
tRPC + React Query
- Server state
- Data fetching
- Real-time updates
API Development
tRPC Router Structure
Error Handling
- Use custom error classes
- Implement proper error boundaries
- Handle API errors gracefully
Database Operations
Prisma Best Practices
- Use transactions for related operations
- Implement proper error handling
- Use type-safe queries
- Follow naming conventions
Styling Guidelines
Tailwind CSS
- Use utility classes
- Follow the design system
- Use CSS variables for theming
- Implement responsive design
Component Styling
- Use CSS Modules for complex styles
- Implement dark mode support
- Follow accessibility guidelines
Performance
Optimization Techniques
- Use proper image optimization
- Implement code splitting
- Optimize bundle size
- Use proper caching strategies
Security
Best Practices
- Implement proper authentication
- Use secure headers
- Sanitize user input
- Follow OWASP guidelines
Environment Variables
- Use proper secrets management
- Implement environment validation
- Use different configs per environment
- Document all variables in .env.example