Overview
BudgetBee follows a set of coding standards to ensure consistency, quality, and maintainability across the codebase. We follow the Google Style Guidelines as our foundation.Consistency is key. When in doubt, follow the patterns established in the existing codebase.
Primary Branch
We usemain as our primary branch. All development should:
- Branch off from
main - Be tested thoroughly before merging
- Pass all CI checks
- Be reviewed by at least one other developer
Code Formatting
BudgetBee uses Prettier for consistent code formatting across the codebase.Configuration
Prettier is configured at the root level with plugins for:- TypeScript/JavaScript
- Tailwind CSS class sorting
- Import organization
- SQL formatting
Available Commands
Run formatting before committing - Set up a pre-commit hook to automatically format code.
TypeScript Guidelines
Type Safety
- Always use explicit types for function parameters and return values
- Avoid using
any- useunknownif type is truly unknown - Leverage TypeScript’s type inference where appropriate
- Use strict mode
Example
API Type Naming Conventions
API Type Naming
Follow a consistent pattern for API endpoint types
Pattern
All types for API endpoints should follow this format:Type Suffixes
QueryParams- URL query parametersResponseBody- Response data structureRequestBody- Request payload structure
Examples
Date Serialization
This applies to:- Query parameters
- Request body
- URL path segments
- Form data
Example
Database Guidelines
Index Naming
All database indexes should follow this format:Examples
Migration Naming
All migration files should follow this format:Examples
Migrations are run in alphabetical order, so the date prefix ensures correct execution order.
React Component Guidelines
Component Structure
Naming Conventions
- Use PascalCase for components:
MyComponent - Use camelCase for functions:
handleClick - Use camelCase for variables:
isLoading - Prefix boolean props with
is,has,should:isOpen,hasError - Prefix event handlers with
on:onClick,onSubmit
Import Organization
Imports are automatically organized by Prettier with the following order:- External packages
- Internal packages (
@budgetbee/*) - Relative imports
- Type imports
File Naming
- Use kebab-case for files:
user-profile.tsx - Use PascalCase for component files:
UserProfile.tsx(optional) - Use lowercase for utility files:
utils.ts,constants.ts - Use
.tsxfor React components - Use
.tsfor TypeScript utilities
Testing
Test File Location
Place test files next to the code they test:Test Naming
Git Commit Messages
Follow conventional commit format:Types
feat- New featurefix- Bug fixdocs- Documentation changesstyle- Code style changes (formatting)refactor- Code refactoringtest- Adding or updating testschore- Maintenance tasks
Examples
Code Review Guidelines
When reviewing code:Best Practices
Be Explicit
Prefer explicit code over clever code. Clarity is more valuable than brevity.
Handle Errors
Always handle potential errors and edge cases. Never silently fail.
Write Tests
Test critical functionality. Aim for meaningful coverage, not just high percentages.
Document Complexity
Add comments for complex logic or non-obvious decisions. Let the code explain what, comments explain why.
Performance
- Avoid unnecessary re-renders in React
- Use React.memo for expensive components
- Leverage Next.js caching strategies
- Optimize database queries
- Use pagination for large datasets
- Implement proper loading states
Security
- Validate all user input
- Sanitize data before database queries
- Use parameterized queries
- Implement proper authentication checks
- Follow OWASP security guidelines
- Keep dependencies updated
Next Steps
Getting Started
Set up your local development environment
Project Structure
Understand the monorepo architecture

