Thank you for your interest in contributing to the Earning Robot project! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Coding Standards
- Testing
- Pull Request Process
- Be respectful and inclusive
- Provide constructive feedback
- Focus on the code, not the person
- Help others learn and grow
- Fork the repository
- Clone your fork
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Python 3.8+
- Git
- Virtual environment tool
# Clone your fork
git clone https://github.com/YOUR_USERNAME/robot.git
cd robot
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
pip install -r tests/requirements.txt
# Copy example env
cp .env.example .env
# Edit .env with test credentials
# Run tests
pytest tests/ -vUse GitHub Issues to report bugs. Include:
- Clear description of the issue
- Steps to reproduce
- Expected vs actual behavior
- System information (OS, Python version)
- Relevant logs or error messages
Example:
Title: API returns 500 on invalid task ID
Description:
When calling GET /api/task/{task_id} with an invalid ID,
the API returns 500 instead of 404.
Steps to Reproduce:
1. Start the server
2. Call: curl http://localhost:5000/api/task/99999
3. Observe 500 error
Expected: 404 Not Found
Actual: 500 Internal Server Error
Environment: Ubuntu 22.04, Python 3.10
Use GitHub Issues with the "enhancement" label. Include:
- Clear description of the feature
- Use cases and benefits
- Possible implementation approach
- Any breaking changes
- Pick an Issue: Look for issues tagged "good first issue" or "help wanted"
- Comment: Let others know you're working on it
- Create Branch: Use descriptive names
- Write Code: Follow coding standards
- Test: Add tests for new features
- Document: Update docs as needed
- Submit PR: Create a pull request
Follow PEP 8 style guide:
# Good
def calculate_profit(income, expenses):
"""Calculate net profit from income and expenses."""
return income - expenses
# Bad
def calc(i,e):
return i-e- Functions:
snake_case - Classes:
PascalCase - Constants:
UPPER_SNAKE_CASE - Private:
_leading_underscore
# Good
class AIProvider:
MAX_RETRIES = 3
def __init__(self):
self._api_key = None
def generate_response(self, prompt):
pass
# Bad
class ai_provider:
maxRetries = 3
def GenerateResponse(self, prompt):
passUse clear docstrings for all public functions:
def create_task(prompt, provider='openai'):
"""
Create and execute an AI task.
Args:
prompt (str): The user's question or request
provider (str): AI provider name (default: 'openai')
Returns:
dict: Task result with response, cost, and metadata
Raises:
ValueError: If provider is invalid
APIError: If AI API call fails
"""
passOrganize imports in this order:
# Standard library
import os
import sys
from datetime import datetime
# Third-party
import requests
from flask import Flask
# Local
from backend.config import Config
from backend.database import DatabaseAlways handle errors gracefully:
# Good
try:
result = ai_provider.generate_response(prompt)
return result
except APIError as e:
logger.error(f"API error: {e}")
return {'error': 'Service temporarily unavailable'}
except Exception as e:
logger.error(f"Unexpected error: {e}")
return {'error': 'An error occurred'}
# Bad
result = ai_provider.generate_response(prompt) # May crash
return resultUse appropriate log levels:
import logging
logger = logging.getLogger(__name__)
# Debug: Detailed diagnostic info
logger.debug(f"Request payload: {data}")
# Info: General informational messages
logger.info("Task completed successfully")
# Warning: Something unexpected but not critical
logger.warning("API rate limit approaching")
# Error: Error occurred but app continues
logger.error(f"Failed to process task: {e}")
# Critical: Serious error, app may not continue
logger.critical("Database connection lost")All new features should include tests:
import pytest
from backend.database import Database, Task
def test_create_task():
"""Test task creation"""
db = Database(':memory:').initialize()
session = db.get_session()
task = Task(
task_type='test',
ai_provider='openai',
input_text='Test question',
status='pending'
)
session.add(task)
session.commit()
# Verify
retrieved = session.query(Task).first()
assert retrieved is not None
assert retrieved.task_type == 'test'
session.close()# Run all tests
pytest tests/ -v
# Run specific test file
pytest tests/test_basic.py -v
# Run with coverage
pytest tests/ --cov=backend --cov=billing
# Run specific test
pytest tests/test_basic.py::test_create_task -vAim for 80%+ code coverage for new features.
- Code follows style guidelines
- All tests pass
- New tests added for new features
- Documentation updated
- No unnecessary changes
- Commit messages are clear
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
How was this tested?
## Checklist
- [ ] Code follows style guidelines
- [ ] Tests pass
- [ ] Documentation updated
- [ ] No breaking changes (or documented)- Submit PR: Create pull request with clear description
- CI Checks: Wait for automated tests to pass
- Code Review: Maintainers will review your code
- Address Feedback: Make requested changes
- Approval: Once approved, PR will be merged
- Celebrate: Your contribution is now part of the project! 🎉
Use clear, descriptive commit messages:
# Good
git commit -m "Add support for Mistral AI provider"
git commit -m "Fix: Handle 404 errors in task endpoint"
git commit -m "Docs: Update API documentation with examples"
# Bad
git commit -m "Fix bug"
git commit -m "Changes"
git commit -m "WIP"# Create feature branch
git checkout -b feature/add-gemini-support
# Make changes
# ... code ...
# Run tests
pytest tests/ -v
# Commit
git add .
git commit -m "Add Gemini AI provider support"
# Push
git push origin feature/add-gemini-support
# Create PR on GitHub# Create fix branch
git checkout -b fix/task-404-error
# Fix the bug
# ... code ...
# Add test that would have caught the bug
# ... test code ...
# Verify fix
pytest tests/ -v
# Commit
git commit -m "Fix: Return 404 for invalid task IDs"
# Push and create PR
git push origin fix/task-404-error- Web dashboard UI
- More AI provider integrations
- Enhanced security features
- Performance optimizations
- Extended test coverage
- Add more example scripts
- Improve error messages
- Add input validation
- Documentation improvements
- Code cleanup and refactoring
- Docker containerization
- Kubernetes deployment
- Rate limiting
- Caching layer
- Metrics and monitoring
- Multi-language support
- Questions: Open a GitHub Discussion
- Bugs: Open a GitHub Issue
- Chat: Join our community (if available)
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Given credit in documentation
Thank you for contributing to Earning Robot! 🚀