Thank you for your interest in contributing to Sarva! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Process
- Pull Request Process
- Coding Standards
- Commit Message Guidelines
- Testing Guidelines
This project adheres to a Code of Conduct that all contributors must follow:
- Be respectful and inclusive
- Welcome newcomers and help them get started
- Focus on constructive feedback
- Respect different viewpoints and experiences
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/sarva.git cd sarva - Add upstream remote:
git remote add upstream https://github.com/YOUR_ORG/sarva.git
- Create a feature branch:
git checkout -b feature/your-feature-name
Before starting work, sync your fork:
git checkout develop
git pull upstream develop
git push origin developgit checkout -b feature/SAR-123-add-featureBranch naming convention:
feature/SAR-XXX-description- New featuresbugfix/SAR-XXX-description- Bug fixeshotfix/SAR-XXX-description- Production hotfixesdocs/description- Documentation updates
- Write clean, maintainable code
- Follow existing code style
- Add tests for new functionality
- Update documentation as needed
# Run tests
npm test
# Check code quality
npm run lint
npm run typecheck
# Run e2e tests
npm run test:e2eFollow our commit message guidelines:
git add .
git commit -m "feat(messaging): add group chat functionality"git push origin feature/SAR-123-add-feature- Go to GitHub and create a pull request
- Fill out the PR template completely
- Link related Linear issues
- Request review from relevant team members
- Code follows project coding standards
- Tests added for new functionality
- All tests pass locally
- Documentation updated
- Linear issue linked
- No merge conflicts
- PR title follows convention
- PR description is complete
<type>(<scope>): <short description>
Examples:
feat(wallet): add multi-currency support
fix(auth): resolve token expiration issue
docs(api): update authentication endpoints
chore(deps): upgrade React to v18
Types:
feat- New featurefix- Bug fixdocs- Documentation changesstyle- Code style changes (formatting)refactor- Code refactoringperf- Performance improvementstest- Adding or updating testschore- Maintenance tasks
- Automated Checks: CI/CD pipeline runs automatically
- Code Review: At least 2 approvals required
- Testing: QA team tests on staging
- Approval: Tech lead final approval
- Merge: Squash and merge to develop
- DRY: Don't Repeat Yourself
- SOLID: Follow SOLID principles
- KISS: Keep It Simple, Stupid
- Clean Code: Write self-documenting code
// Use TypeScript for type safety
interface User {
id: string;
email: string;
name: string;
}
// Use async/await over promises
async function fetchUser(id: string): Promise<User> {
const response = await api.get(`/users/${id}`);
return response.data;
}
// Use meaningful variable names
const activeUsers = users.filter(user => user.isActive);
// Avoid magic numbers
const MAX_LOGIN_ATTEMPTS = 3;
const SESSION_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes// Use functional components with hooks
import { useState, useEffect } from 'react';
interface Props {
userId: string;
onUpdate?: (user: User) => void;
}
export const UserProfile: React.FC<Props> = ({ userId, onUpdate }) => {
const [user, setUser] = useState<User | null>(null);
useEffect(() => {
fetchUser(userId).then(setUser);
}, [userId]);
return <div>{user?.name}</div>;
};// Use dependency injection
class UserService {
constructor(
private userRepository: UserRepository,
private emailService: EmailService
) {}
async createUser(data: CreateUserDto): Promise<User> {
const user = await this.userRepository.create(data);
await this.emailService.sendWelcome(user.email);
return user;
}
}
// Use proper error handling
try {
const user = await userService.createUser(data);
return res.json(user);
} catch (error) {
if (error instanceof ValidationError) {
return res.status(400).json({ error: error.message });
}
throw error; // Let global error handler deal with it
}# Use type hints
from typing import Optional, List
def get_user(user_id: str) -> Optional[User]:
"""Fetch user by ID.
Args:
user_id: The unique identifier for the user
Returns:
User object if found, None otherwise
"""
return User.query.get(user_id)
# Use list comprehensions
active_users = [user for user in users if user.is_active]
# Follow PEP 8
MAX_LOGIN_ATTEMPTS = 3
SESSION_TIMEOUT = 1800 # seconds<type>(<scope>): <subject>
<body>
<footer>
feat(wallet): add multi-currency support
- Added currency conversion service
- Updated wallet balance to support multiple currencies
- Added currency selector in UI
Closes SAR-123
feat: New featurefix: Bug fixdocs: Documentationstyle: Formatting changesrefactor: Code refactoringperf: Performance improvementtest: Adding testschore: Maintenance
Use the service or module name:
auth- Authentication servicewallet- Wallet servicemessaging- Messaging serviceui- UI componentsapi- API changes
Reference Linear issues in commits:
feat(messaging): add group chat
Implements group messaging functionality with member management.
SAR-123
This will automatically link the commit to the Linear issue.
describe('UserService', () => {
describe('createUser', () => {
it('should create a new user with valid data', async () => {
const userData = { email: 'test@example.com', name: 'Test User' };
const user = await userService.createUser(userData);
expect(user).toBeDefined();
expect(user.email).toBe(userData.email);
});
it('should throw error with invalid email', async () => {
const userData = { email: 'invalid', name: 'Test' };
await expect(userService.createUser(userData))
.rejects.toThrow(ValidationError);
});
});
});- Aim for 80%+ code coverage
- All new features must have tests
- Critical paths must have 100% coverage
# Unit tests
npm run test:unit
# Integration tests
npm run test:integration
# E2E tests
npm run test:e2e
# Coverage report
npm run test:coverageUse GitHub labels to categorize issues and PRs:
bug- Bug reportsenhancement- Feature requestsdocumentation- Documentation updatesgood first issue- Good for newcomershelp wanted- Need community helppriority: high- High prioritystatus: in progress- Work in progressstatus: blocked- Blocked by dependencies
- Slack: Join #dev-help channel
- GitHub Discussions: Ask questions
- Linear: Comment on issues
- Email: dev-team@sarva.app
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Featured on our website
Thank you for contributing to Sarva! π