Thank you for your interest in contributing to SmartBrain! This document provides guidelines for contributing to the project.
- Code of Conduct
- Getting Started
- How to Contribute
- Development Setup
- Code Style
- Testing
- Pull Request Process
- Model Contribution Guidelines
- Commit Guidelines
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please read CODE_OF_CONDUCT.md before contributing.
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/SmartBrain.git - Add upstream remote:
git remote add upstream https://github.com/SolanaRemix/SmartBrain.git - Create a new branch:
git checkout -b feature/your-feature-name
Before creating bug reports, please check existing issues to avoid duplicates.
When creating a bug report, include:
- Clear title and description
- Steps to reproduce the behavior
- Expected behavior
- Actual behavior
- Screenshots (if applicable)
- Environment details (OS, Node.js version, etc.)
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:
- Clear title and description
- Use case and rationale
- Possible implementation approach
- Alternative solutions considered
- Pick an issue or create one
- Comment on the issue to let others know you're working on it
- Fork the repository and create a branch
- Make your changes
- Write or update tests
- Update documentation
- Submit a pull request
# Clone the repository
git clone https://github.com/YOUR_USERNAME/SmartBrain.git
cd SmartBrain
# Install dependencies
npm install
# Copy environment template
cp .env.example .env
# Edit .env with your configuration
# Run bootstrap script
./scripts/bootstrap.sh
# Run tests
npm test
# Run linter
npm run lint
# Run audit script
./scripts/audit.shWe follow JavaScript Standard Style with some modifications.
- Use 2 spaces for indentation
- Use single quotes for strings
- Add semicolons at the end of statements
- Use
constfor constants,letfor variables - Use meaningful variable and function names
- Add JSDoc comments for public APIs
/**
* Validates model metadata against schema
* @param {Object} metadata - The model metadata
* @param {Object} schema - The validation schema
* @returns {boolean} True if valid, false otherwise
*/
function validateMetadata(metadata, schema) {
if (!metadata || !schema) {
return false;
}
// Validation logic
return true;
}- ESLint:
.eslintrc.json - Prettier:
.prettierrc - EditorConfig:
.editorconfig
Run linting:
npm run lint
npm run lint:fix # Auto-fix issuesWe use a test-driven development approach.
- Write unit tests for new functions
- Write integration tests for new features
- Aim for >80% code coverage
- Use descriptive test names
describe('ModelValidator', () => {
describe('validateMetadata', () => {
it('should return true for valid metadata', () => {
const metadata = { name: 'test', version: '1.0.0' };
const result = validateMetadata(metadata);
expect(result).toBe(true);
});
it('should return false for invalid metadata', () => {
const metadata = { name: 'test' }; // missing version
const result = validateMetadata(metadata);
expect(result).toBe(false);
});
});
});# Run all tests
npm test
# Run unit tests only
npm run test:unit
# Run integration tests only
npm run test:integration
# Run with coverage
npm run test:coverage
# Watch mode
npm run test:watch- Update documentation for any changed functionality
- Add or update tests for your changes
- Ensure all tests pass (
npm test) - Run linting (
npm run lint) - Update CHANGELOG.md with your changes
- Follow commit message conventions (see below)
- Request review from maintainers
- Code follows the project's style guidelines
- Self-review completed
- Comments added for complex code
- Documentation updated
- No new warnings generated
- Tests added/updated and passing
- Dependent changes merged
- CHANGELOG.md updated
Use conventional commits format:
type(scope): description
Examples:
feat(inference): add batch prediction support
fix(training): resolve checkpoint loading issue
docs(readme): update installation instructions
When contributing ML models:
- Create model directory in
/models/<model-name> - Add metadata.json following the schema in
/models/metadata/schema.json - Include README.md with:
- Model description
- Training details
- Usage examples
- Performance metrics
- License information
{
"name": "model-name",
"version": "1.0.0",
"description": "Model description",
"framework": "tensorflow",
"task": "classification",
"author": "Your Name",
"created_at": "2025-01-11T00:00:00Z",
"metrics": {
"accuracy": 0.95,
"f1_score": 0.94
}
}Before submitting:
# Validate model
./scripts/validate-model.sh models/your-model
# Ensure validation passes- Models >100MB should use Git LFS
- Consider model compression techniques
- Provide download links for large models
We follow Conventional Commits.
<type>(<scope>): <subject>
<body>
<footer>
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- style: Code style changes (formatting, etc.)
- refactor: Code refactoring
- test: Adding or updating tests
- chore: Maintenance tasks
- perf: Performance improvements
feat(inference): add GPU acceleration support
Implements CUDA-based inference for faster predictions.
Includes automatic fallback to CPU when GPU unavailable.
Closes #123
fix(training): resolve memory leak in data loader
The data loader was not properly releasing memory after
each epoch. This fix ensures proper cleanup.
Update documentation when:
- Adding new features
- Changing APIs
- Modifying configurations
- Adding dependencies
Documentation locations:
README.md- Main project documentationdocs/- Detailed documentation- Code comments - For complex logic
- JSDoc - For public APIs
- Open a discussion on GitHub Discussions
- Ask in issues with the
questionlabel - Contact maintainers
Contributors will be recognized in:
- CHANGELOG.md
- GitHub contributors list
- Project documentation
Thank you for contributing to SmartBrain! 🧠