Contributing Guide

Guidelines and best practices for contributing to MiyoList

๐Ÿš€ Getting Started

Thank you for considering contributing to MiyoList! We welcome contributions from the community.

  1. Fork the repository on GitHub
  2. Clone your fork locally
  3. Create a new branch for your feature/fix
  4. Make your changes following our guidelines
  5. Test thoroughly before submitting
  6. Submit a pull request with clear description

๐Ÿ“ Code Style Guidelines

Dart/Flutter Conventions

  • Follow Effective Dart style guide
  • Use lowerCamelCase for variables and methods
  • Use UpperCamelCase for classes
  • Use snake_case for file names
  • Always use const constructors when possible
  • Prefer final over var when variable won't change

Code Organization

  • Keep files under 500 lines when possible
  • One class per file (with exceptions for small helper classes)
  • Group imports: dart libraries, package imports, relative imports
  • Use meaningful variable and function names
  • Add comments for complex logic

Example Code Style

// Good โœ…
class AnimeService {
  final ApiClient _apiClient;
  
  const AnimeService(this._apiClient);
  
  Future<List<Anime>> fetchAnimeList({
    required String userId,
    int page = 1,
  }) async {
    try {
      final response = await _apiClient.query(query);
      return response.map((e) => Anime.fromJson(e)).toList();
    } catch (e) {
      throw ApiException('Failed to fetch anime list: $e');
    }
  }
}

// Bad โŒ
class anime_service {
  var apiClient;
  
  anime_service(this.apiClient);
  
  fetchAnimeList(userId, page) async {
    var response = await apiClient.query(query);
    return response.map((e) => Anime.fromJson(e)).toList();
  }
}

โœจ Feature Development

Before Starting

  • Check if there's an existing issue or discussion about the feature
  • Create a new issue to discuss major features before implementing
  • Make sure the feature aligns with project goals
  • Review existing similar features for consistency

Feature Structure

lib/features/your_feature/
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ models/          # Data models
โ”‚   โ”œโ”€โ”€ repositories/    # Data repositories
โ”‚   โ””โ”€โ”€ services/        # API services
โ”œโ”€โ”€ presentation/
โ”‚   โ”œโ”€โ”€ pages/           # UI pages
โ”‚   โ”œโ”€โ”€ widgets/         # Feature-specific widgets
โ”‚   โ””โ”€โ”€ providers/       # State management
โ””โ”€โ”€ domain/
    โ””โ”€โ”€ usecases/        # Business logic

State Management

MiyoList uses Riverpod for state management:

final animeListProvider = FutureProvider.autoDispose
    .family<List<Anime>, String>((ref, userId) async {
  final service = ref.read(animeServiceProvider);
  return service.fetchAnimeList(userId: userId);
});

๐Ÿงช Testing Requirements

All new features and bug fixes should include tests:

Unit Tests

  • Test business logic and data models
  • Mock external dependencies
  • Aim for 80%+ code coverage
test('Anime.fromJson creates valid object', () {
  final json = {'id': 1, 'title': 'Test Anime'};
  final anime = Anime.fromJson(json);
  
  expect(anime.id, 1);
  expect(anime.title, 'Test Anime');
});

Widget Tests

  • Test UI components and interactions
  • Verify correct rendering
  • Test user input handling

Running Tests

# Run all tests
flutter test

# Run specific test file
flutter test test/features/anime/anime_test.dart

# Run with coverage
flutter test --coverage

๐Ÿ“ค Pull Request Guidelines

PR Checklist

  • โœ… Code follows project style guidelines
  • โœ… All tests pass locally
  • โœ… New code is covered by tests
  • โœ… Documentation is updated
  • โœ… Commit messages are clear and descriptive
  • โœ… PR description explains changes and motivation
  • โœ… No merge conflicts with main branch

PR Title Format

type(scope): brief description

Examples:
feat(anime): add advanced filtering options
fix(auth): resolve OAuth redirect issue
docs(readme): update installation instructions
refactor(search): improve query performance
test(manga): add unit tests for MangaService

Types

  • 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

๐ŸŒฟ Branch Strategy

  • main - Stable release branch
  • develop - Development branch (if exists)
  • feature/feature-name - New features
  • fix/bug-description - Bug fixes
  • docs/documentation-update - Documentation

Creating a Branch

git checkout -b feature/advanced-search
# Make your changes
git add .
git commit -m "feat(search): add advanced filtering"
git push origin feature/advanced-search

๐Ÿ‘€ Code Review Process

All contributions go through code review:

  • Maintainers will review your PR within 3-5 days
  • Address feedback and requested changes
  • Keep discussions constructive and respectful
  • Be open to suggestions and alternative approaches
  • Update PR based on review comments

๐Ÿ’ก Tip

Break large features into smaller, reviewable PRs. This speeds up the review process and makes it easier to merge.

๐Ÿค Community Guidelines

  • Be respectful and professional
  • Welcome newcomers and help them contribute
  • Provide constructive feedback
  • Keep discussions on-topic
  • Follow our Code of Conduct

๐Ÿ“š Helpful Resources