Contributing Guidelines
Welcome to PianoRhythm Server! We appreciate your interest in contributing to our project. This guide outlines the process for contributing code, reporting issues, and collaborating effectively.
๐ค Code of Conductโ
Our Commitmentโ
We are committed to providing a welcoming and inclusive environment for all contributors, regardless of background, experience level, or identity.
Expected Behaviorโ
- Be respectful in all interactions
- Be constructive when providing feedback
- Be collaborative and help others learn
- Be patient with newcomers and questions
Unacceptable Behaviorโ
- Harassment, discrimination, or offensive language
- Personal attacks or trolling
- Spam or off-topic discussions
- Sharing private information without consent
๐ Reporting Issuesโ
Before Reportingโ
- Search existing issues to avoid duplicates
- Check documentation for known solutions
- Test with latest version if possible
- Gather relevant information (logs, environment, steps to reproduce)
Issue Templateโ
## Bug Report
**Description**
A clear description of the bug.
**Steps to Reproduce**
1. Step one
2. Step two
3. Step three
**Expected Behavior**
What should happen.
**Actual Behavior**
What actually happens.
**Environment**
- OS: [e.g., Windows 10, Ubuntu 20.04]
- Rust version: [e.g., 1.77.0]
- Server version: [e.g., v0.2.0]
**Additional Context**
Any other relevant information, logs, or screenshots.
Feature Requestsโ
## Feature Request
**Problem Statement**
What problem does this feature solve?
**Proposed Solution**
Describe your proposed solution.
**Alternatives Considered**
Other approaches you've considered.
**Additional Context**
Any other relevant information or examples.
๐ง Development Processโ
Getting Startedโ
- Fork the repository on GitHub
- Clone your fork locally
- Set up development environment (see Development Setup)
- Create a feature branch from
develop - Make your changes following our coding standards
- Test thoroughly (see Testing Guide)
- Submit a pull request
Branch Naming Conventionโ
feature/description- New featuresbugfix/description- Bug fixeshotfix/description- Critical production fixesdocs/description- Documentation updatesrefactor/description- Code refactoring
Commit Message Formatโ
type(scope): brief description
Detailed explanation of the change, including:
- Why the change was made
- What was changed
- Any breaking changes or migration notes
Closes #123
Types:
feat- New featurefix- Bug fixdocs- Documentation changesstyle- Code style changes (formatting, etc.)refactor- Code refactoringtest- Adding or updating testschore- Maintenance tasks
Examples:
feat(websocket): add room password validation
Add password validation for private rooms to ensure only
authorized users can join protected rooms.
- Implement password hashing and verification
- Add validation middleware for room join requests
- Update WebSocket message handling for password errors
Closes #456
๐ Coding Standardsโ
Rust Style Guideโ
We follow the official Rust style guide with these additions:
Code Formattingโ
# Format code before committing
cargo fmt
# Check formatting
cargo fmt -- --check
Lintingโ
# Run clippy for linting
cargo clippy -- -D warnings
# Fix common issues automatically
cargo clippy --fix
Documentationโ
/// Authenticates a user with the provided credentials.
///
/// # Arguments
///
/// * `credentials` - The user's login credentials
/// * `state` - The application state containing database connections
///
/// # Returns
///
/// Returns `Ok(UserSession)` on successful authentication,
/// or `Err(AuthError)` if authentication fails.
///
/// # Examples
///
/// ```rust
/// let credentials = LoginCredentials {
/// username: "user123".to_string(),
/// password: "secure_password".to_string(),
/// };
///
/// match authenticate_user(credentials, &state).await {
/// Ok(session) => println!("User authenticated: {}", session.user_id),
/// Err(e) => eprintln!("Authentication failed: {}", e),
/// }
/// ```
pub async fn authenticate_user(
credentials: LoginCredentials,
state: &AppState,
) -> Result<UserSession, AuthError> {
// Implementation
}
Error Handlingโ
// Use Result types for fallible operations
pub fn parse_user_id(input: &str) -> Result<UserId, ParseError> {
input.parse().map_err(ParseError::InvalidFormat)
}
// Use custom error types
#[derive(Debug, thiserror::Error)]
pub enum AuthError {
#[error("Invalid credentials")]
InvalidCredentials,
#[error("User not found: {user_id}")]
UserNotFound { user_id: String },
#[error("Database error: {0}")]
Database(#[from] DatabaseError),
}
Testingโ
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_authenticate_user_success() {
// Arrange
let credentials = create_valid_credentials();
let state = create_test_state().await;
// Act
let result = authenticate_user(credentials, &state).await;
// Assert
assert!(result.is_ok());
let session = result.unwrap();
assert_eq!(session.user_id, "expected_user_id");
}
#[tokio::test]
async fn test_authenticate_user_invalid_credentials() {
// Arrange
let credentials = create_invalid_credentials();
let state = create_test_state().await;
// Act
let result = authenticate_user(credentials, &state).await;
// Assert
assert!(matches!(result, Err(AuthError::InvalidCredentials)));
}
}
Performance Guidelinesโ
- Avoid unnecessary allocations - Use string slices when possible
- Use appropriate data structures - HashMap for lookups, Vec for sequences
- Profile critical paths - Use benchmarks for performance-sensitive code
- Minimize database queries - Batch operations when possible
- Cache frequently accessed data - Use Redis for hot data
Security Guidelinesโ
- Validate all inputs - Never trust user input
- Use parameterized queries - Prevent SQL injection
- Hash passwords properly - Use bcrypt or similar
- Sanitize outputs - Prevent XSS attacks
- Log security events - Track authentication attempts
- Follow principle of least privilege - Minimal required permissions
๐ Pull Request Processโ
Before Submittingโ
- Ensure tests pass - Run full test suite
- Update documentation - Include relevant docs updates
- Check code coverage - Maintain or improve coverage
- Verify formatting - Run
cargo fmtandcargo clippy - Test manually - Verify changes work as expected
Pull Request Templateโ
## Description
Brief description of changes made.
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing completed
- [ ] Performance impact assessed
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Code is commented where necessary
- [ ] Documentation updated
- [ ] Tests pass locally
- [ ] No new warnings introduced
## Related Issues
Closes #123
Related to #456
Review Processโ
- Automated checks - CI/CD pipeline runs tests and checks
- Code review - Team members review code quality and design
- Testing - Reviewers may test changes locally
- Approval - At least one approval required from maintainers
- Merge - Squash and merge to maintain clean history
Review Criteriaโ
- Functionality - Does the code work as intended?
- Code Quality - Is the code clean, readable, and maintainable?
- Performance - Are there any performance implications?
- Security - Are there any security concerns?
- Testing - Is the code adequately tested?
- Documentation - Is the code properly documented?
๐๏ธ Architecture Decisionsโ
Proposing Changesโ
For significant architectural changes:
- Create an RFC (Request for Comments) issue
- Discuss with maintainers before implementation
- Consider backwards compatibility
- Plan migration strategy if needed
- Update architecture documentation
RFC Templateโ
## RFC: [Title]
**Status:** Draft | Under Review | Accepted | Rejected
### Summary
Brief explanation of the proposed change.
### Motivation
Why is this change needed?
### Detailed Design
Technical details of the proposed solution.
### Alternatives Considered
Other approaches that were considered.
### Migration Strategy
How will existing systems be migrated?
### Unresolved Questions
What questions remain to be resolved?
๐ฏ Contribution Areasโ
High-Priority Areasโ
- Performance optimization - Improve server performance
- Test coverage - Increase test coverage
- Documentation - Improve and expand documentation
- Security - Enhance security measures
- Monitoring - Add better observability
Good First Issuesโ
Look for issues labeled good-first-issue for newcomer-friendly tasks:
- Documentation improvements
- Simple bug fixes
- Test additions
- Code cleanup
Advanced Contributionsโ
- New features - Major functionality additions
- Architecture improvements - System design enhancements
- Performance optimizations - Critical path improvements
- Security enhancements - Security feature additions
๐ Getting Helpโ
Communication Channelsโ
- GitHub Issues - Bug reports and feature requests
- GitHub Discussions - General questions and discussions
- Discord - Real-time chat with the community
- Email - Direct contact with maintainers
Mentorshipโ
New contributors can request mentorship:
- Pair programming sessions
- Code review guidance
- Architecture discussions
- Career advice in open source
๐ Recognitionโ
Contributor Recognitionโ
- Contributors list - All contributors acknowledged
- Release notes - Major contributions highlighted
- Community spotlight - Featured contributor posts
- Swag - Stickers and merchandise for active contributors
Becoming a Maintainerโ
Active contributors may be invited to become maintainers:
- Consistent contributions over time
- Code quality and review skills
- Community involvement and helpfulness
- Technical expertise in relevant areas
Thank you for contributing to PianoRhythm Server! Your contributions help make the platform better for everyone.