Contribution Guide
This guide provides information for developers who want to contribute to the ATP project.
Development Setup
-
Prerequisites
-
Fork and Clone the Repository
# Fork the repository on GitHub first
# Then clone your fork
git clone https://github.com/YOUR_USERNAME/atp.git
cd atp
# Add the original repository as upstream
git remote add upstream https://github.com/mycel-labs/atp.git -
Install Dependencies
# Install Rust dependencies
cargo build -
Start the Local Replica
dfx start --background
-
Deploy Locally
dfx deploy
Development Workflow
Branching Strategy
main
- The main branch containing stable codedevelop
- Development branch for integrating featuresfeature/feature-name
- Feature branches for new developmentfix/bug-name
- Bug fix branches
Making Changes
-
Create a Feature Branch
git checkout -b feature/your-feature-name
-
Make Your Changes
- Follow the code style and architecture patterns in the existing codebase
- Add tests for new functionality
- Update documentation as needed
-
Run Tests
cargo test
-
Format Your Code
cargo fmt
-
Check for Linting Issues
cargo clippy
-
Commit Your Changes
git add .
git commit -m "feat: add your feature description"Follow the Conventional Commits format:
feat:
for new featuresfix:
for bug fixesdocs:
for documentation changestest:
for adding or modifying testsrefactor:
for code refactoringchore:
for routine tasks, maintenance, etc.
-
Push Your Changes
git push -u origin feature/your-feature-name
-
Create a Pull Request
- Go to your fork on GitHub
- Click "Compare & pull request"
- Create a new pull request from your fork's feature branch to the original repository's
develop
branch - Fill in the PR template with details about your changes
Code Standards
Rust Style Guide
- Follow the Rust API Guidelines
- Use meaningful variable and function names
- Add documentation comments (
///
) for public functions and types - Keep functions small and focused on a single responsibility
- Use proper error handling with
Result
types
Testing
- Write unit tests for all new functionality
- Ensure tests are deterministic and don't depend on external state
- Use mocks for external dependencies when appropriate
- Aim for high test coverage, especially for critical components
Documentation
- Update documentation when making changes to the API
- Document complex algorithms or business logic
- Keep the README and other documentation up to date
- Use clear and concise language
Canister Development Guidelines
State Management
- Use stable memory for persistent state
- Implement proper upgrade hooks (
pre_upgrade
andpost_upgrade
) - Be mindful of memory usage and cycles consumption
Security Considerations
- Validate all inputs from users and other canisters
- Implement proper access control for sensitive operations
- Be careful with inter-canister calls and their failure modes
- Follow the principle of least privilege
Performance
- Optimize for cycles usage
- Use query calls when possible instead of update calls
- Be mindful of the size of messages passed between canisters
- Consider batching operations when appropriate
Getting Help
If you need help or have questions about contributing:
- Open an issue on GitHub
- Join the community discussions
- Check the existing documentation and code comments
Thank you for contributing to ATP!