Skip to content

Latest commit

 

History

History
675 lines (503 loc) · 17 KB

File metadata and controls

675 lines (503 loc) · 17 KB

Contributing to LearnLens 🎓

Thank you for your interest in contributing to LearnLens! This project is designed as a progressive learning tutorial for JavaScript, and we welcome contributions from learners, educators, and developers alike.

🎯 Project Mission

LearnLens is an educational platform that teaches JavaScript through building a real webcam filter application. Our goal is to help learners master JavaScript concepts from React basics to machine learning in the browser.

🌟 Ways to Contribute

For Learners 📚

As someone going through the tutorial, you can contribute by:

  1. Report confusing sections - Help us improve explanations
  2. Suggest additional examples - Share what helped you understand
  3. Share your progress - Post your completed projects
  4. Ask questions - Your questions help improve documentation
  5. Fix typos or errors - Even small corrections matter!

For Educators 👨‍🏫

As an instructor or mentor, you can contribute by:

  1. Classroom feedback - Share how the tutorial works in your classes
  2. Additional exercises - Suggest practice problems for each level
  3. Assessment materials - Create quizzes or project rubrics
  4. Supplementary guides - Add teaching notes or lesson plans
  5. Accessibility improvements - Help make content more inclusive

For Developers 💻

As an experienced developer, you can contribute by:

  1. Code improvements - Enhance existing features
  2. New features - Add educational features that teach concepts
  3. Performance optimizations - Improve app performance
  4. New filter effects - Create interesting visual effects
  5. Documentation - Improve technical explanations
  6. Create level branches - Help build the learning branches

🎓 Understanding the Learning Structure

8 Progressive Levels

The project is divided into 8 levels, each teaching specific concepts:

Level Topic Key Concepts
1 React Basics Components, State, Hooks
2 Webcam & Canvas WebRTC, Canvas API
3 Filters & Effects CSS Filters, Color Theory
4 Photo Capture Canvas to Image, Downloads
5 Stickers & Drag Events, Drag-and-Drop
6 AI Integration APIs, Async/Await
7 AI Vision Multimodal AI, Image Analysis
8 Face Detection TensorFlow.js, ML Models

Branch Structure

  • main - Complete working code (reference implementation)
  • level-N-topic - Learning branches with TODOs for students
  • level-N-solution - Solution branches for reference

Documentation Structure

  • README.md - Main project overview and learning roadmap
  • docs/README-LEVEL-N.md - Detailed tutorials for each level
  • CONTRIBUTING.md - This file (contribution guidelines)
  • .env.example - Environment variable template

🐛 Reporting Issues

For Learners: Reporting Confusion

If something in the tutorial is unclear:

**Issue**: Confusing explanation in Level 3

**Section**: README-LEVEL-3.md - "Color Theory Basics"

**What's confusing**:
The explanation of HSL vs RGB doesn't include examples of when to use each.

**Suggestion**:
Add a comparison table or real-world examples of when HSL is better than RGB.

**Your background**:
Beginner - completed Levels 1-2

For Everyone: Reporting Bugs

Before creating a bug report:

  • Check existing issues to avoid duplicates
  • Verify the bug exists in the latest version
  • Try to reproduce it consistently

When reporting a bug:

**Bug**: Camera doesn't stop when switching modes

**Steps to reproduce**:
1. Start webcam in Level 2
2. Switch to Photos mode
3. Camera indicator stays on

**Expected**: Camera should stop
**Actual**: Camera keeps running

**Level**: Level 2 - Webcam & Canvas

**Environment**:
- Browser: Chrome 120
- OS: Windows 11
- Node: v18.0.0

💡 Suggesting Improvements

Educational Content Suggestions

We especially welcome suggestions for:

  1. Better Explanations

    **Level**: 4
    **Topic**: Base64 encoding
    **Current**: Technical explanation
    **Suggestion**: Add visual diagram showing how base64 works
    **Why**: Visual learners would benefit from seeing the encoding process
  2. Additional Challenges

    **Level**: 5
    **Challenge**: Multi-finger pinch-to-zoom for stickers
    **Concepts taught**: Touch events, gesture recognition
    **Difficulty**: Advanced
    **Learning value**: Teaches advanced touch event handling
  3. Better Examples

    **Level**: 6
    **Current example**: Basic API call
    **Suggested example**: API call with retry logic and exponential backoff
    **Reason**: Teaches real-world error handling patterns

Feature Suggestions

When suggesting new features, consider the educational value:

**Feature**: GIF Export

**Educational Value**:
- Teaches: File APIs, ArrayBuffer, binary data manipulation
- Level: 4 (after Photo Capture)
- Complexity: Intermediate

**Implementation approach**:
- Use gif.js library
- Teach: npm package integration, third-party libraries
- Documentation: Explain how GIF encoding works

**Why it fits the curriculum**:
Natural progression after learning image capture and manipulation.

🔧 Development Setup

Prerequisites

  • Node.js v14 or higher
  • npm or yarn
  • Git
  • Modern web browser
  • Webcam (for testing camera features)
  • Google Gemini API key (for AI features)

Setup Steps

  1. Fork and clone

    # Fork on GitHub, then:
    git clone https://github.com/YOUR-USERNAME/LearnLens.git
    cd LearnLens
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env
    # Add your Gemini API key to .env
  4. Start development server

    npm start
  5. Create your branch

    git checkout -b feature/your-contribution

📝 Educational Code Guidelines

Writing Code for Learners

Code in this project should be educational first:

1. Prioritize Clarity Over Cleverness

// ❌ Clever but confusing for learners
const result = data.reduce((a, b) => ({...a, [b.id]: b}), {});

// ✅ Clear and educational
const result = {};
data.forEach(item => {
  result[item.id] = item;
});

// Or with explanatory comments:
const result = data.reduce((accumulator, item) => {
  // Build an object where each item's ID is the key
  return { ...accumulator, [item.id]: item };
}, {});

2. Add Educational Comments

Comments should explain why and what learners gain:

// ❌ Obvious comment
// Set the filter
setActiveFilter(filterName);

// ✅ Educational comment
// Update active filter state, which triggers a re-render
// This demonstrates React's reactive data flow pattern
setActiveFilter(filterName);
// ✅ Explain complex concepts
// We use requestAnimationFrame instead of setInterval because:
// 1. It syncs with browser repaints (smoother animation)
// 2. It pauses when tab is hidden (saves CPU)
// 3. It runs at optimal ~60 FPS automatically
requestAnimationFrame(renderLoop);

3. Progressive Complexity

Code should match the level's learning objectives:

// Level 1 (React Basics) - Simple, direct
const [count, setCount] = useState(0);
const increment = () => setCount(count + 1);

// Level 4 (Advanced) - More sophisticated
const [count, setCount] = useState(0);
const increment = useCallback(() => {
  setCount(prevCount => prevCount + 1);
}, []);

4. Avoid Advanced Patterns Too Early

Wait until appropriate levels to introduce:

  • Level 1-2: Basic hooks, props, state
  • Level 3-4: useCallback, useMemo (only if beneficial)
  • Level 5-6: Custom hooks, context
  • Level 7-8: Performance optimization patterns

5. Include Learning TODOs

For level branches, add educational TODOs:

// TODO: Implement the capturePhoto function
// HINT: Use canvas.toDataURL() to convert canvas to image
// LEARNING: This teaches you how browsers represent images as data
const capturePhoto = () => {
  // Your code here
};

JavaScript Style Guide

Follow these conventions for consistency:

// ✅ Use functional components with hooks
const MyComponent = () => {
  const [state, setState] = useState(initial);
  return <div>{state}</div>;
};

// ✅ Use descriptive names
const [isLoading, setIsLoading] = useState(false);
const [userProfile, setUserProfile] = useState(null);

// ✅ Handle errors gracefully with user-friendly messages
try {
  const stream = await navigator.mediaDevices.getUserMedia({ video: true });
} catch (error) {
  console.error('Camera error:', error);
  setError('Unable to access camera. Please check permissions.');
}

// ✅ Clean up resources in useEffect
useEffect(() => {
  const interval = setInterval(() => {}, 1000);
  return () => clearInterval(interval);
}, []);

CSS Guidelines

/* ✅ Use descriptive class names */
.filter-button { }
.filter-button.active { }

/* ✅ Follow existing naming conventions */
.section-header { }
.section-content { }

/* ✅ Comment complex CSS for learners */
/* Glassmorphism effect: semi-transparent background with blur */
.card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

📚 Documentation Guidelines

Writing Tutorials

When contributing to level READMEs:

  1. Start with learning objectives

    ## 📚 Learning Objectives
    
    By the end of this level, you will be able to:
    - ✅ Understand concept A
    - ✅ Implement feature B
    - ✅ Apply pattern C
  2. Explain concepts before code

    • What is it?
    • Why do we use it?
    • When should you use it?
    • How does it work?
  3. Provide multiple examples

    • Simple example first
    • Complex example second
    • Real-world use case third
  4. Add practice exercises

    • Guided tasks (step-by-step)
    • Challenges (problem-solving)
    • Extensions (creative exploration)
  5. Include common pitfalls

    **Common Mistake:**
    ❌ Forgetting to cleanup listeners
    
    **Correct Approach:**
    ✅ Always remove event listeners in cleanup function

Documentation Structure

# Level N: Topic 📚

## Learning Objectives
## What You'll Build
## Concepts Covered
  ### Concept 1
    - Explanation
    - Code examples
    - Visual diagrams
  ### Concept 2
    ...
## Implementation Guide
  ### Step 1
  ### Step 2
  ...
## Practice Tasks
## Testing Your Knowledge
  ### Quiz Questions
  ### Challenges
## Additional Resources
## Key Takeaways
## Ready for Next Level?

✅ Testing

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm test -- --watch

# Run tests with coverage
npm test -- --coverage

Writing Tests for Educational Code

Tests should also be educational:

describe('Filter functionality', () => {
  test('applies grayscale filter when button clicked', () => {
    // LEARNING: Testing React components with user interactions
    render(<App />);

    // Find the button (accessible by text)
    const grayscaleButton = screen.getByText(/grayscale/i);

    // Simulate user click
    fireEvent.click(grayscaleButton);

    // Verify the filter was applied
    expect(grayscaleButton).toHaveClass('active');
  });
});

📤 Submitting Changes

Commit Guidelines

Use clear, educational commit messages:

# ✅ Good - describes what and why
git commit -m "Add sticker rotation feature to Level 5"
git commit -m "Fix canvas cleanup in useEffect for Level 2"
git commit -m "Improve base64 explanation in Level 4 README"

# ❌ Bad - too vague
git commit -m "update"
git commit -m "fix bug"
git commit -m "changes"

Commit Message Format

<type>(<level>): <description>

<body explaining educational value>

<footer>

Types:

  • feat - New feature (code or educational content)
  • fix - Bug fix
  • docs - Documentation improvements
  • tutorial - Tutorial content updates
  • example - New examples or exercises
  • refactor - Code improvements (maintaining functionality)

Examples:

feat(level-3): Add color picker for custom filters

- Adds color picker UI component
- Teaches input[type="color"] usage
- Demonstrates real-time state updates
- Includes practice exercise for HSL conversion

Addresses #45
docs(level-6): Improve async/await explanation

- Add visual flowchart of async execution
- Include common pitfalls section
- Add more real-world examples
- Simplify Promise chaining explanation

Helps learners understand asynchronous patterns better.

Pull Request Process

  1. Ensure educational value

    • Does this help learners understand concepts better?
    • Is it appropriate for the target level?
    • Does it follow the progressive learning path?
  2. Update documentation

    • Update README-LEVEL-N.md if needed
    • Add code comments explaining concepts
    • Update main README if adding features
  3. Test thoroughly

    • Test in multiple browsers
    • Verify camera/AI features work
    • Check that examples run correctly
    • Validate all code snippets
  4. Create Pull Request

    • Fill out the template
    • Explain educational impact
    • Include screenshots if visual
    • Link related issues

Pull Request Template

## Description
Brief description of changes and their educational value

## Type of Contribution
- [ ] Tutorial content (documentation, examples)
- [ ] Code feature (new functionality)
- [ ] Bug fix
- [ ] Educational improvements (better explanations)

## Target Level(s)
Which levels does this affect? (Level 1-8, or General)

## Educational Value
How does this help learners?
- What concepts does it teach?
- What skills will learners gain?
- How does it fit in the curriculum?

## Related Issues
Closes #issue-number

## Testing
- [ ] Code works in development
- [ ] Examples are accurate and tested
- [ ] No console errors
- [ ] Tested in Chrome/Firefox/Safari
- [ ] Accessible (keyboard navigation, screen readers)

## Screenshots (if applicable)
Add screenshots or GIFs demonstrating the feature

## Checklist
- [ ] Code includes educational comments
- [ ] Documentation updated
- [ ] Examples are clear and tested
- [ ] Follows project style guidelines
- [ ] No new warnings or errors
- [ ] Appropriate for target learning level

🎯 Contribution Ideas

Good First Contributions

Perfect for beginners:

  • Fix typos in documentation
  • Improve code comments with better explanations
  • Add examples to existing tutorials
  • Create quiz questions for level READMEs
  • Improve error messages to be more helpful
  • Add visual diagrams to explain concepts

Intermediate Contributions

For those with some experience:

  • Create new challenges for practice sections
  • Add new filter effects with explanations
  • Improve accessibility features
  • Create video walkthroughs of levels
  • Write supplementary guides (e.g., "Debugging Tips")
  • Add keyboard shortcuts with documentation

Advanced Contributions

For experienced developers:

  • Create new learning levels (Level 9+)
  • Build assessment tools for educators
  • Add advanced features (video recording, effects timeline)
  • Create alternative implementations (Vue.js version, etc.)
  • Performance optimizations with educational explanations
  • Create teaching resources (slides, workshop materials)

🏅 Recognition

Contributors are recognized in:

  • README.md - Contributors section
  • Release notes - Feature acknowledgments
  • Documentation - Author credits
  • Special thanks - In tutorial materials

📞 Getting Help

  • Questions about learning: Open a GitHub Discussion
  • Questions about contributing: Comment on issues
  • Bug reports: Create an issue with "bug" label
  • Feature suggestions: Create an issue with "enhancement" label
  • Security concerns: Email maintainers privately

📜 Code of Conduct

Our Values

  • Be welcoming - This is a learning environment for all skill levels
  • Be patient - Everyone learns at their own pace
  • Be helpful - Share knowledge generously
  • Be respectful - Value diverse perspectives and experiences
  • Be constructive - Offer helpful feedback, not criticism

Expected Behavior

  • Use welcoming and inclusive language
  • Respect different viewpoints and experiences
  • Accept constructive feedback gracefully
  • Focus on what's best for learners
  • Show empathy toward other contributors

Unacceptable Behavior

  • Gatekeeping or elitism ("this is obvious")
  • Dismissing beginners' questions
  • Harassment or discriminatory language
  • Publishing others' private information
  • Unprofessional or disrespectful conduct

🎉 Thank You!

This project exists to help people learn JavaScript. Every contribution, whether it's:

  • Fixing a typo
  • Clarifying a confusing explanation
  • Adding a new feature
  • Helping another learner

...makes this educational resource better for everyone.

You're not just writing code—you're helping others learn to code. 🚀


Happy teaching and learning! 🎓

Questions? Open an issue or discussion—we're here to help!