Contributing Guide - dinesh-git17/my-progress-planner GitHub Wiki

Thank you for your interest in contributing to My Progress Planner! This guide will help you get started with contributing to our supportive meal tracking application.

🌟 Our Mission

We're building more than just a meal tracking app - we're creating a supportive digital companion that celebrates users' wellness journeys with genuine care and encouragement.

Core Values

  • Supportive & Encouraging - Every interaction should feel caring
  • Privacy-First - User data security is paramount
  • Accessibility - Everyone should feel welcome
  • Quality - Code should be maintainable and reliable
  • Community - We grow together through collaboration

🎯 Types of Contributions

We welcome various types of contributions:

🐛 Bug Reports

  • Found a bug? Please report it!
  • Include reproduction steps
  • Describe expected vs actual behavior

💡 Feature Requests

  • Have an idea for improvement?
  • Describe the problem you're solving
  • Suggest a solution approach

📝 Documentation

  • Improve existing docs
  • Add missing documentation
  • Fix typos or unclear sections

🔧 Code Contributions

  • Bug fixes
  • New features
  • Performance improvements
  • Test coverage improvements

🎨 Design & UX

  • UI/UX improvements
  • Accessibility enhancements
  • Mobile responsiveness fixes

🚀 Getting Started

1. Fork & Clone

# Fork the repository on GitHub, then:
git clone https://github.com/your-username/my-progress-planner.git
cd my-progress-planner

2. Set Up Development Environment

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your credentials

# Start development server
npm run dev

See Installation Guide for detailed setup instructions.

3. Create a Branch

# Create and switch to feature branch
git checkout -b feature/amazing-feature

# Or for bug fixes
git checkout -b fix/issue-description

🛠️ Development Workflow

Branch Naming Convention

  • feature/description - New features
  • fix/description - Bug fixes
  • docs/description - Documentation updates
  • refactor/description - Code refactoring
  • test/description - Test improvements

Commit Message Format

We use Conventional Commits:

type(scope): description

[optional body]

[optional footer]

Types:

  • feat - New feature
  • fix - Bug fix
  • docs - Documentation
  • style - Formatting, no code change
  • refactor - Code restructuring
  • test - Adding/updating tests
  • chore - Maintenance tasks

Examples:

git commit -m "feat(meals): add meal editing functionality"
git commit -m "fix(auth): resolve login redirect issue"
git commit -m "docs(api): update endpoint documentation"

Code Quality Standards

TypeScript Requirements

  • Strict mode enabled - No any types unless absolutely necessary
  • Proper typing - Define interfaces for all data structures
  • JSDoc comments - Document complex functions
// ✅ Good
interface MealData {
  id: string;
  content: string;
  mealType: 'breakfast' | 'lunch' | 'dinner';
  loggedAt: Date;
}

/**
 * Logs a meal and generates AI response
 * @param mealData - The meal information to log
 * @returns Promise with meal and AI response
 */
async function logMeal(mealData: MealData): Promise<MealResponse> {
  // Implementation
}

// ❌ Avoid
function logMeal(data: any): any {
  // Implementation
}

React Component Standards

// ✅ Good - Functional component with proper typing
interface MealCardProps {
  meal: Meal;
  onEdit?: () => void;
  className?: string;
}

export default function MealCard({ 
  meal, 
  onEdit, 
  className = '' 
}: MealCardProps) {
  return (
    <div className={`meal-card ${className}`}>
      {/* Component content */}
    </div>
  );
}

// ❌ Avoid - Unclear props, missing types
export default function MealCard(props) {
  return <div>{/* content */}</div>;
}

CSS/Tailwind Standards

  • Use Tailwind utilities - Avoid custom CSS when possible
  • Responsive design - Mobile-first approach
  • Accessibility - ARIA labels, focus states, color contrast
// ✅ Good - Responsive, accessible
<button 
  className="
    px-4 py-2 
    bg-pink-500 hover:bg-pink-600 
    text-white font-medium rounded-lg
    focus:outline-none focus:ring-2 focus:ring-pink-500 focus:ring-offset-2
    disabled:opacity-50 disabled:cursor-not-allowed
    transition-colors duration-200
    sm:px-6 sm:py-3
  "
  aria-label="Log breakfast meal"
  disabled={isLoading}
>
  {isLoading ? 'Logging...' : 'Log Meal'}
</button>

Testing Requirements

Unit Tests

Every new feature should include unit tests:

// __tests__/utils/mealValidation.test.ts
import { validateMealContent } from '@/utils/mealValidation';

describe('validateMealContent', () => {
  it('should accept valid meal content', () => {
    const result = validateMealContent('Oatmeal with berries');
    expect(result.isValid).toBe(true);
  });

  it('should reject empty meal content', () => {
    const result = validateMealContent('');
    expect(result.isValid).toBe(false);
    expect(result.error).toContain('required');
  });

  it('should reject meal content that is too long', () => {
    const longContent = 'a'.repeat(501);
    const result = validateMealContent(longContent);
    expect(result.isValid).toBe(false);
  });
});

Integration Tests

Test API endpoints:

// __tests__/api/meals.test.ts
import { createMocks } from 'node-mocks-http';
import handler from '@/app/api/meals/route';

describe('/api/meals', () => {
  it('should log a meal successfully', async () => {
    const { req, res } = createMocks({
      method: 'POST',
      body: {
        mealType: 'breakfast',
        content: 'Scrambled eggs'
      }
    });

    await handler(req, res);

    expect(res._getStatusCode()).toBe(200);
    const data = JSON.parse(res._getData());
    expect(data.error).toBeNull();
    expect(data.data.meal.content).toBe('Scrambled eggs');
  });
});

E2E Tests (Optional)

For critical user journeys:

// e2e/meal-logging.spec.ts
import { test, expect } from '@playwright/test';

test('user can log a meal', async ({ page }) => {
  await page.goto('/');
  await page.click('[data-testid="breakfast-button"]');
  await page.fill('[data-testid="meal-input"]', 'Oatmeal with berries');
  await page.click('[data-testid="log-meal-button"]');
  
  await expect(page.locator('[data-testid="success-message"]')).toBeVisible();
});

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

# Run E2E tests
npm run test:e2e

🎨 UI/UX Guidelines

Design Principles

  • Warm & Encouraging - Use soft colors and friendly language
  • Clean & Minimal - Avoid clutter, focus on essentials
  • Consistent - Follow established patterns
  • Accessible - WCAG 2.1 AA compliance

Color Palette

/* Primary colors */
--color-primary: #f472b6; /* Pink-400 */
--color-primary-dark: #ec4899; /* Pink-500 */

/* Background colors */
--color-bg-primary: #f5ede6; /* Warm beige */
--color-bg-secondary: #ffffff; /* White */

/* Text colors */
--color-text-primary: #374151; /* Gray-700 */
--color-text-secondary: #6b7280; /* Gray-500 */

/* Status colors */
--color-success: #10b981; /* Emerald-500 */
--color-warning: #f59e0b; /* Amber-500 */
--color-error: #ef4444; /* Red-500 */

Typography

  • Headings: DM Sans Bold
  • Body: DM Sans Regular
  • UI Elements: DM Sans Medium

Spacing & Layout

  • Consistent spacing - Use Tailwind's spacing scale
  • Mobile-first - Design for mobile, enhance for desktop
  • Touch-friendly - Minimum 44px touch targets

🔒 Security Guidelines

API Security

// ✅ Good - Validate input, handle errors
export async function POST(request: Request) {
  try {
    const { mealType, content } = await request.json();
    
    // Validate input
    if (!mealType || !['breakfast', 'lunch', 'dinner'].includes(mealType)) {
      return NextResponse.json(
        { error: 'Invalid meal type' }, 
        { status: 400 }
      );
    }
    
    if (!content || content.trim().length === 0) {
      return NextResponse.json(
        { error: 'Meal content is required' }, 
        { status: 400 }
      );
    }
    
    // Sanitize content
    const sanitizedContent = content.trim().slice(0, 500);
    
    // Process request...
    
  } catch (error) {
    console.error('API Error:', error);
    return NextResponse.json(
      { error: 'Internal server error' }, 
      { status: 500 }
    );
  }
}

Environment Variables

  • Never commit secrets - Use .env.local for development
  • Validate required vars - Check at startup
  • Prefix client vars - Use NEXT_PUBLIC_ for client-side

Authentication

  • Check user auth - Validate JWT tokens
  • Use RLS policies - Database-level security
  • Handle auth errors - Graceful error handling

📝 Documentation Standards

Code Documentation

/**
 * Generates an encouraging AI response for a logged meal
 * 
 * @param mealData - The meal information
 * @param userContext - User's streak and history
 * @returns Promise resolving to AI response
 * 
 * @example
 * ```typescript
 * const response = await generateMealResponse({
 *   content: 'Oatmeal with berries',
 *   mealType: 'breakfast'
 * }, {
 *   streak: 5,
 *   previousMeals: []
 * });
 * ```
 */
async function generateMealResponse(
  mealData: MealData,
  userContext: UserContext
): Promise<AIResponse> {
  // Implementation
}

API Documentation

Update the API Documentation when adding endpoints:

#### Log a Meal
```http
POST /api/meals/log

Request Body:

{
  "mealType": "breakfast",
  "content": "Oatmeal with berries"
}

Response:

{
  "data": {
    "meal": {...},
    "aiResponse": "What a nutritious start! 💕"
  },
  "error": null
}

## 🚀 Pull Request Process

### Before Submitting
1. **Test your changes** thoroughly
2. **Update documentation** if needed
3. **Run linting** and fix issues
4. **Write meaningful commit messages**
5. **Keep changes focused** - one feature/fix per PR

### PR Template
```markdown
## Description
Brief description of changes made.

## Type of Change
- [ ] Bug fix
- [ ] New feature  
- [ ] Documentation update
- [ ] Refactoring
- [ ] Performance improvement

## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
- [ ] E2E tests pass (if applicable)

## Screenshots
Include screenshots for UI changes.

## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes
- [ ] Accessibility considered

Review Process

  1. Automated checks must pass
  2. Code review by maintainer
  3. Testing in development environment
  4. Approval and merge

🎯 Good First Issues

New contributors should look for issues labeled:

  • good first issue - Beginner-friendly
  • help wanted - Community contributions welcome
  • documentation - Documentation improvements
  • ui/ux - Design improvements

Example First Contributions

  • Fix typos in documentation
  • Add missing TypeScript types
  • Improve accessibility
  • Add unit tests for utilities
  • Enhance mobile responsiveness

🤝 Community Guidelines

Communication

  • Be respectful and constructive
  • Ask questions if unclear
  • Help others when you can
  • Share knowledge and learnings

Code Reviews

  • Be kind - Remember there's a person behind the code
  • Be specific - Explain the "why" behind suggestions
  • Appreciate good work - Acknowledge well-written code
  • Learn from others - Code reviews are learning opportunities

Issue Reporting

## Bug Report Template

**Describe the bug**
Clear description of what the bug is.

**To Reproduce**
1. Go to '...'
2. Click on '...'
3. See error

**Expected behavior**
What you expected to happen.

**Screenshots**
If applicable, add screenshots.

**Environment:**
- OS: [e.g. iOS, Windows]
- Browser: [e.g. Chrome, Safari]
- Version: [e.g. 22]

**Additional context**
Any other context about the problem.

🏆 Recognition

Contributors who make significant contributions will be:

  • Acknowledged in release notes
  • Listed in contributors section
  • Invited to the core team (for ongoing contributors)

📞 Getting Help

📚 Resources


Thank you for contributing to My Progress Planner! Together, we're building something that truly makes a difference in people's wellness journeys. 💕

⚠️ **GitHub.com Fallback** ⚠️