DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • Project 1: The Performance-First Dashboard
  • Project 2: Accessible Video Player
  • Project 3: Markdown Blog Engine
  • Project 4: Browser-Based Code Editor
  • Project 5: Multi-Tab Whiteboard
  • Project 6: Infinite Scroll Image Gallery
  • Project 7: Recipe Optimizer & Converter
  • Project 8: Budget Tracker with Charts
  • Project 9: Typing Speed Test
  • Project 10: Weather App with Time-Travel
  • Project 11: CSS Grid Layout Builder
  • Project 12: Password Vault (Frontend Only)
  • Project 13: Kanban Board (Trello Clone)
  • Project 14: Quiz App with Leaderboard
  • Project 15: Habit Tracker (GitHub Style)
  • Project 16: E-commerce Product Page
  • Project 17: Unit Converter (Expert Mode)
  • Project 18: Music Visualizer
  • Project 19: Flashcard Learning App
  • Project 20: Custom Form Validator
  • Project 21: Virtual Terminal
  • Project 22: Pomodoro Timer (Focus Pro)
  • Project 23: SVG Path Editor
  • Project 24: Movie Database Matchmaker
  • Project 25: Interactive Resume / Portfolio
  • Project 26: Recipe Scraper UI
  • Project 27: Crypto Tracker (Real-Time)
  • Project 28: Find My Pet (PWA)
  • Project 29: Markdown-to-Slide Tool
  • Project 30: Browser Health Dashboard
← From Beginner to Expert in Fundamentals of Frontend

Project 15: Habit Tracker (GitHub Style)

40 min read
SVG GenerationDate MathematicsColor MappingTooltip PositioningStreak CalculationYear Comparison

📋 Project Brief

Build a 365-day visual habit tracker inspired by GitHub's contribution graph. This project requires programmatic SVG generation, date mathematics (leap years, day-of-week offsets), and intensity-based color mapping.

✅ Feature Requirements

Feature 1: SVG Grid Generation

Acceptance Criteria:

  • Generate a grid of 365 (or 366) <rect> elements representing each day of the year
  • Layout: 7 rows (Mon-Sun) × 52-53 columns (weeks)
  • Each cell is ~12×12px with 2px gap
  • Month labels appear above the grid at the correct column positions
  • Day labels (Mon, Wed, Fri) appear on the left side

Feature 2: Intensity Color Mapping

Acceptance Criteria:

  • 0 habits = lightest gray; 1 = light green; 2-3 = medium green; 4+ = dark green
  • Color scale must be customizable (e.g., blue theme, orange theme)
  • A legend at the bottom shows: "Less" [□ □ □ □ □] "More"

Feature 3: Date Math Logic

Acceptance Criteria:

  • Correctly handle leap years (366 days)
  • The grid starts on the correct day-of-week for January 1st
  • Today's date is visually highlighted with a border
  • Future dates are not clickable/interactive

Feature 4: Tooltip System

Acceptance Criteria:

  • Hovering over a cell shows: date, number of habits completed, and habit names
  • The tooltip follows the cursor or anchors to the cell
  • Tooltip must not overflow the viewport edges

Feature 5: Yearly Comparison

Acceptance Criteria:

  • A year selector dropdown allows viewing previous years
  • A "Year in Review" summary shows: total active days, longest streak, most productive month
  • Side-by-side comparison mode to view two years simultaneously

📊 Data Model

FieldTypeDescription
dateYYYY-MM-DD stringThe day
habitsArray of stringsHabit names completed that day
countNumberTotal habits completed (derived)

🧪 Testing Checklist

  • Unit test: leap year detection
  • Unit test: day-of-week calculation for January 1st of any year
  • Unit test: color intensity mapping from count to color
  • Unit test: streak calculation (consecutive days with count > 0)
  • Integration test: clicking a day toggles a habit and updates the grid color

🚀 Stretch Goals

  • Add multiple habit categories with separate color themes
  • Implement daily notifications/reminders
  • Add a "Share Your Year" image export
  • Weekly and monthly summary views

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.