This guide covers development workflows, best practices, and tools for contributing to Relief Connect.
- Node.js 18.x or higher
- PostgreSQL 14.x or higher
- Yarn 4.x (via Corepack)
- Git
- VS Code (recommended) or your preferred IDE
Follow the Quick Start Guide to set up your development environment.
# Install all dependencies
yarn install
# Build all workspaces
yarn build:all
# Type checking
yarn type-check
# Docker commands
yarn docker:build
yarn docker:up
yarn docker:down
yarn docker:logs# Development server with hot reload
yarn api:dev
# Build TypeScript
yarn api:build
# Start production server
yarn api:start
# Lint code
yarn api:lint
# Fix linting issues
yarn api:lint:fix# Development server (port 3001)
yarn web:dev
# Build for production
yarn web:build
# Start production server
yarn web:start
# Type check
yarn web:type-check
# Lint
yarn web:lint
# Fix linting
yarn web:lint:fix# Build shared library
yarn shared:build
# Watch mode (auto-rebuild on changes)
yarn shared:watchgit checkout -b feature/your-feature-name- Write code following the project's style guide
- Add tests if applicable
- Update documentation
# Start backend
yarn api:dev
# Start frontend (in another terminal)
yarn web:dev
# Run type checking
yarn type-check
# Run linters
yarn api:lint
yarn web:lintgit add .
git commit -m "feat: add new feature description"Follow Conventional Commits format:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changesrefactor:- Code refactoringtest:- Adding testschore:- Maintenance tasks
git push origin feature/your-feature-nameCreate a Pull Request on GitHub.
- Use TypeScript strict mode
- Prefer interfaces over types for object shapes
- Use explicit return types for functions
- Avoid
anytype (useunknownif needed)
Files:
- Components:
PascalCase.tsx - Services:
kebab-case-service.ts - Utilities:
kebab-case.ts - Types:
kebab-case.ts
Variables and Functions:
- camelCase for variables and functions
- PascalCase for classes and components
- UPPER_SNAKE_CASE for constants
- Descriptive names (avoid abbreviations)
Database:
- camelCase for model properties
- PascalCase for model classes
Backend:
Controller → Service → DAO → Model
Frontend:
Page → Component → Service → API
- External libraries
- Internal modules
- Types/interfaces
- Relative imports
// External
import React from 'react';
import { useRouter } from 'next/router';
// Internal
import { useAuth } from '../../hooks/useAuth';
import { helpRequestService } from '../../services';
// Types
import { IHelpRequest } from '../../types/help-request';
// Relative
import './styles.css';Layered Architecture:
- Controllers handle HTTP requests/responses
- Services contain business logic
- DAOs handle data access
- Models define data structure
Error Handling:
- Use centralized error handler middleware
- Return consistent error response format
- Log errors appropriately
Validation:
- Use class-validator decorators
- Validate at controller level
- Return clear error messages
Component Structure:
- Functional components with hooks
- Separate presentational and container components
- Reusable UI components in
components/ui/
State Management:
- React Context for global state (Auth)
- useState for local component state
- useMemo for derived state
- useEffect for side effects
API Communication:
- Use service layer (not direct fetch calls)
- Centralized API client
- Error handling in services
- Type-safe API calls
# Run all tests
yarn test
# Run tests in watch mode
yarn test:watch
# Run tests with coverage
yarn test:coverageBackend Tests:
- Unit tests for services
- Integration tests for API endpoints
- Test database operations
Frontend Tests:
- Component tests with React Testing Library
- Service tests
- E2E tests (if applicable)
VS Code Launch Configuration:
Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug API",
"runtimeExecutable": "yarn",
"runtimeArgs": ["api:dev"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}Debugging Tips:
- Use
console.logfor quick debugging - Use debugger breakpoints
- Check database queries in logs
- Verify environment variables
Browser DevTools:
- React DevTools extension
- Network tab for API calls
- Console for errors
- Application tab for localStorage
VS Code Debugging:
{
"type": "node",
"request": "launch",
"name": "Debug Next.js",
"runtimeExecutable": "yarn",
"runtimeArgs": ["web:dev"],
"console": "integratedTerminal"
}# Create migration
npx sequelize-cli migration:generate --name migration-name
# Run migrations
npx sequelize-cli db:migrate
# Rollback
npx sequelize-cli db:migrate:undo# Run seeders
npx sequelize-cli db:seed:all
# Run specific seeder
npx sequelize-cli db:seed --seed seed-file-nameUse Sequelize query methods:
// Find all
const users = await UserModel.findAll();
// Find one
const user = await UserModel.findByPk(id);
// Create
const newUser = await UserModel.create(data);
// Update
await user.update(data);
// Delete
await user.destroy();- Create Controller Method:
// controllers/example_controller.ts
export class ExampleController {
async getExample(req: Request, res: Response) {
// Implementation
}
}- Create Service Method:
// services/example_service.ts
export class ExampleService {
async getExample(id: number) {
// Business logic
}
}- Create Route:
// routes/example/example_router.ts
router.get('/:id',
authenticate,
authorize(UserRole.USER),
exampleController.getExample
);- Register Route:
// routes/router_manager.ts
this.mainRouter.use('/api/example', exampleRouter);Use tools like Postman or Insomnia:
- Import API collection
- Set environment variables
- Test endpoints
- Verify responses
- Create file in
apps/web/src/pages/ - Export default component
- Add routing (automatic with file-based routing)
- Create component in
apps/web/src/components/ - Use TypeScript interfaces for props
- Follow component structure:
interface ComponentProps {
// Props definition
}
export default function Component({ prop }: ComponentProps) {
// Component logic
return (
// JSX
);
}import { helpRequestService } from '../../services';
const response = await helpRequestService.getAllHelpRequests();
if (response.success) {
// Handle success
}- Create model in
apps/api/src/models/ - Define Sequelize model with decorators
- Add to model index
- Create DAO
- Create service
- Create controller
- Create routes
- Add to
libs/shared/src/enums/ - Export from enum index
- Use in models and DTOs
- Update in
libs/shared/src/ - Rebuild shared library:
yarn shared:build - Use in both frontend and backend
- Use database indexes
- Optimize queries (avoid N+1)
- Use connection pooling
- Cache frequently accessed data
- Paginate large datasets
- Code splitting
- Lazy load components
- Optimize images
- Use React.memo for expensive components
- Debounce search inputs
# Rebuild shared library
yarn shared:build
# Clear TypeScript cache
rm -rf node_modules/.cache# Reinstall dependencies
rm -rf node_modules
yarn install- Verify PostgreSQL is running
- Check environment variables
- Test connection:
psql -U postgres -d relief_connect
# Find process using port
lsof -i :3000
# Kill process
kill -9 <PID>feature/- New featuresfix/- Bug fixesdocs/- Documentationrefactor/- Refactoringtest/- Tests
Follow Conventional Commits:
feat: add user registration endpoint
fix: resolve database connection issue
docs: update API documentation
refactor: reorganize service layer
test: add unit tests for auth service
- Create feature branch
- Make changes and commit
- Push to remote
- Create PR with description
- Address review comments
- Merge after approval
- Username:
pasindusampath - Password:
77889900
- Username:
test-club - Password:
123456789
- No password required.
- They can log in using only their unique username.
- You can create additional volunteer club accounts through the Admin Panel.
- Postman - API testing
- pgAdmin - PostgreSQL GUI
- VS Code - IDE
- React DevTools - Browser extension
← Back to README | Previous: Deployment | Next: Contributing →