Overview
Maintaining high code quality standards ensures that Horse Trust remains maintainable, scalable, and reliable. This guide outlines our coding conventions and best practices.TypeScript Guidelines
All code in Horse Trust is written in TypeScript for type safety and better developer experience.Type Safety
Always use explicit types:any type:
TypeScript Configuration
Backend (server/tsconfig.json)
Frontend (client/tsconfig.json)
Code Style
General Principles
- Write clean, readable code - Code is read more often than it’s written
- Be consistent - Follow existing patterns in the codebase
- Keep it simple - Avoid over-engineering solutions
- Document when necessary - Explain complex logic and business rules
Naming Conventions
Variables and Functions - Use camelCase:File Naming
- Components - PascalCase:
UserProfile.tsx,DonationCard.tsx - Utilities - camelCase:
formatDate.ts,validateEmail.ts - Constants - camelCase:
apiConfig.ts,routePaths.ts
Frontend Standards (Next.js)
Component Structure
React Best Practices
- Use functional components with hooks
- Destructure props in function parameters
- Use TypeScript interfaces for props
- Keep components small and focused
- Extract reusable logic into custom hooks
ESLint Configuration
We use ESLint with Next.js configuration:Backend Standards (Express.js)
API Route Structure
API Response Format
Success response:Error Handling
Security Best Practices
Environment Variables
NEVER commit sensitive data:Input Validation
Always validate user input:Authentication
Use JWT for authentication:Testing Standards
Write Tests for:
- New features - Ensure functionality works as expected
- Bug fixes - Prevent regression
- Critical paths - Authentication, payments, data processing
- Utility functions - Pure functions are easy to test
Test Structure
Documentation Standards
Code Comments
Comment complex logic:Performance Guidelines
Database Queries
React Performance
Pre-Commit Checklist
Before committing your code:- Code follows TypeScript standards
- All tests pass
- ESLint shows no errors
- No console.log statements (use proper logging)
- No commented-out code
- Environment variables not hardcoded
- Code is properly formatted
- Complex logic is documented
Code Review Focus Areas
When reviewing code, pay attention to:- Type safety - Proper TypeScript usage
- Error handling - Try-catch blocks, validation
- Security - No exposed credentials, proper authentication
- Performance - Efficient queries, proper caching
- Readability - Clear naming, good structure
- Testing - Adequate test coverage
Code quality is everyone’s responsibility. Take pride in your code and help maintain our high standards.
Resources
Getting Help
If you have questions about code standards:- Contact the repository maintainer
- Reach out to the team: S02-26-Equipo-33-Web-App
- Review existing code for examples

