Skip to content

Latest commit

 

History

History
403 lines (321 loc) · 11.4 KB

File metadata and controls

403 lines (321 loc) · 11.4 KB

Contributing to Predictive Crowd Intelligence

Thank you for your interest in contributing to the Predictive Crowd Intelligence platform! This document provides guidelines and information for contributors.

🌟 How to Contribute

We welcome contributions in many forms:

  • 🐛 Bug reports and fixes
  • 🚀 New features and enhancements
  • 📚 Documentation improvements
  • 🧪 Test coverage improvements
  • 🌍 Translations and localization
  • 💡 Ideas and feature suggestions

🚀 Getting Started

Prerequisites

  • Backend: Python 3.9+ with FastAPI knowledge
  • Frontend: Node.js 18+ with React/TypeScript experience
  • Tools: Git, Docker (optional)
  • APIs: Basic understanding of REST APIs and computer vision concepts

Development Setup

  1. Clone the repository

    git clone https://github.com/your-org/predictive-crowd-intelligence
    cd predictive-crowd-intelligence
  2. Backend Setup

    cd backend
    python -m venv venv
    source venv/bin/activate  # Windows: venv\Scripts\activate
    pip install -r requirements.txt
    uvicorn app.main:app --reload --port 8000
  3. Frontend Setup

    cd frontend
    npm install
    npm run dev
  4. Environment Variables

    # Create .env file in backend directory
    GOOGLE_MAPS_API_KEY=your_key_here
    AMADEUS_API_KEY=your_key_here
    AMADEUS_API_SECRET=your_secret_here

🐛 Reporting Bugs

When reporting bugs, please include:

  • Clear description of the issue
  • Steps to reproduce the problem
  • Expected vs actual behavior
  • Screenshots if applicable
  • Environment details (OS, browser, versions)
  • Error messages or console output

Use our bug report template:

## Bug Description
Brief description of the bug

## Steps to Reproduce
1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error

## Expected Behavior
What you expected to happen

## Actual Behavior
What actually happened

## Environment
- OS: [e.g., Windows 11, macOS 12.0]
- Browser: [e.g., Chrome 91, Firefox 89]
- Version: [e.g., v1.2.3]

🚀 Feature Requests

For new features:

  • Search existing issues to avoid duplicates
  • Describe the problem you're trying to solve
  • Explain your proposed solution
  • Consider alternatives you've thought about
  • Provide mockups/examples if helpful

📝 Pull Request Process

Before Submitting

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Follow coding standards (see below)
  4. Add tests for new functionality
  5. Update documentation as needed
  6. Test thoroughly on multiple platforms

Pull Request Guidelines

  • Clear title summarizing the change
  • Detailed description of what and why
  • Link related issues using keywords (fixes #123)
  • Include screenshots for UI changes
  • Request review from maintainers

Pull Request Template

## Description
Brief description of changes

## 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
- [ ] Tests pass locally
- [ ] New tests added for new functionality
- [ ] Manual testing completed

## Screenshots
Include screenshots for UI changes

## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] Documentation updated
- [ ] No new warnings introduced

🎨 Coding Standards

Backend (Python)

# Use descriptive variable names
def get_mobile_congestion_data(location_id: str, radius_km: float) -> MobileCongestionData:
    """
    Fetch mobile network congestion data for a specific location.
    
    Args:
        location_id: Unique identifier for the location
        radius_km: Search radius in kilometers
        
    Returns:
        MobileCongestionData: Congestion analysis results
    """
    pass

# Follow PEP 8 style guide
# Use type hints
# Add docstrings for all functions
# Keep functions focused and small

Frontend (TypeScript/React)

// Use descriptive component names
interface MobileDataProps {
  locationId: string;
  onDataUpdate: (data: MobileCongestionData) => void;
}

const MobileAnalysisCard: React.FC<MobileDataProps> = ({ locationId, onDataUpdate }) => {
  // Use meaningful variable names
  const [congestionData, setCongestionData] = useState<MobileCongestionData | null>(null);
  
  // Add JSDoc comments for complex functions
  /**
   * Fetches and processes mobile congestion data
   */
  const fetchData = useCallback(async () => {
    // Implementation
  }, [locationId]);

  return (
    // Implementation
  );
};

General Guidelines

  • Clear, descriptive names for variables, functions, and classes
  • Consistent formatting using provided linters
  • Comprehensive comments for complex logic
  • Error handling for all external API calls
  • Input validation for all user inputs
  • Security best practices (no hardcoded secrets, input sanitization)

🧪 Testing Guidelines

Backend Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=app tests/

# Run specific test file
pytest tests/test_mobile_congestion.py

Frontend Testing

# Run tests
npm test

# Run with coverage
npm run test:coverage

# Run E2E tests
npm run test:e2e

Test Requirements

  • Unit tests for all new functions
  • Integration tests for API endpoints
  • Component tests for React components
  • E2E tests for critical user journeys
  • Minimum 80% code coverage for new features

📚 Documentation

Code Documentation

  • Docstrings for all Python functions
  • JSDoc comments for TypeScript functions
  • README updates for new features
  • API documentation for new endpoints
  • Architecture docs for significant changes

Documentation Standards

def analyze_satellite_imagery(
    image_data: bytes, 
    location: Tuple[float, float],
    confidence_threshold: float = 0.8
) -> CrowdAnalysisResult:
    """
    Analyze satellite imagery for crowd density estimation.
    
    Uses YOLO v8 and CrowdNet models to detect and count people
    in satellite imagery with confidence scoring.
    
    Args:
        image_data: Raw satellite image bytes
        location: (latitude, longitude) tuple for the image
        confidence_threshold: Minimum confidence for detection (0.0-1.0)
        
    Returns:
        CrowdAnalysisResult: Analysis results with crowd density,
                           confidence score, and detection metadata
                           
    Raises:
        ValueError: If image_data is invalid or location is out of bounds
        APIError: If external services are unavailable
        
    Examples:
        >>> result = analyze_satellite_imagery(
        ...     image_data=satellite_bytes,
        ...     location=(48.8566, 2.3522),  # Paris coordinates
        ...     confidence_threshold=0.9
        ... )
        >>> print(f"Crowd level: {result.crowd_level}")
    """

🏗️ Architecture Guidelines

Backend Architecture

app/
├── api/                 # API endpoints
├── core/                # Configuration and security
├── models/              # Data models and schemas
├── services/            # Business logic
├── utils/               # Utility functions
└── tests/               # Test files

Frontend Architecture

src/
├── components/          # Reusable UI components
├── services/            # API and external services
├── hooks/               # Custom React hooks
├── utils/               # Utility functions
├── types/               # TypeScript type definitions
└── tests/               # Test files

Design Patterns

  • Single Responsibility: Each function/class has one clear purpose
  • Dependency Injection: Use FastAPI's dependency system
  • Separation of Concerns: Keep UI, business logic, and data separate
  • Error Boundaries: Handle errors gracefully at appropriate levels

🌍 Internationalization

We welcome translations! To add a new language:

  1. Create language file: frontend/src/i18n/locales/{language}.json
  2. Add translations: Copy from en.json and translate values
  3. Update i18n config: Add language to supported list
  4. Test thoroughly: Ensure UI handles text length variations

📊 Performance Guidelines

Backend Performance

  • Async operations for all I/O
  • Caching for expensive computations
  • Database indexing for query optimization
  • Rate limiting for API endpoints
  • Monitoring for performance metrics

Frontend Performance

  • Lazy loading for components and routes
  • Memoization for expensive calculations
  • Virtual scrolling for large lists
  • Image optimization for satellite imagery
  • Bundle splitting for faster loading

🔒 Security Considerations

  • Input validation on all user inputs
  • SQL injection prevention using parameterized queries
  • XSS protection with proper escaping
  • API rate limiting to prevent abuse
  • Secure headers for all responses
  • Environment variables for all secrets
  • Regular dependency updates for security patches

🤝 Code Review Process

For Reviewers

  • Be constructive and suggest improvements
  • Focus on code quality, security, and maintainability
  • Test the changes locally if possible
  • Check documentation and test coverage
  • Approve promptly once issues are resolved

For Contributors

  • Respond to feedback promptly and professionally
  • Make requested changes or explain why you disagree
  • Keep discussions focused on the code
  • Be patient during the review process

🏆 Recognition

Contributors will be recognized in:

  • CONTRIBUTORS.md file
  • Release notes for significant contributions
  • Project documentation for major features
  • Community showcases for exceptional work

📞 Getting Help

Community Channels

Mentoring

New contributors can request mentoring for:

  • First contributions: Getting started with the codebase
  • Complex features: Architecture and design guidance
  • Best practices: Code quality and testing approaches

📋 Contributor License Agreement

By contributing to this project, you agree that:

  • Your contributions will be licensed under the Apache 2.0 License
  • You have the right to submit your contributions
  • You understand this is an open-source project
  • Your contributions may be used in derivative works

🎯 Roadmap

Check our project roadmap for:

  • Planned features and their timelines
  • Areas needing help and skill requirements
  • Long-term vision and architecture evolution
  • Community priorities and voting

📄 Code of Conduct

This project adheres to a code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to maintainers@predictive-crowd-intelligence.org.


Thank you for contributing to Predictive Crowd Intelligence! Together, we're building the future of intelligent tourism technology. 🚀