A MagicMirror module for tracking daily habits with completion status. Habits reset at the end of each day and can be toggled by clicking on them.
- 📅 Daily habit tracking with automatic reset
- ✅ Click to toggle habit completion status
- 🎯 Visual progress bar showing completion percentage
- 🎨 Modern, responsive design with strikethrough for completed habits
- 💾 Persistent data storage via backend API
- 🔄 Real-time updates
-
Clone this repository or copy the
MMM-HabitTrackerfolder to your MagicMirror modules directory:cd ~/MagicMirror/modules git clone https://github.com/rydercalmdown/magic_mirror.git MMM-HabitTracker
-
Install backend dependencies:
cd MMM-HabitTracker npm install express cors -
Add the module to your MagicMirror configuration in
config/config.js:{ module: "MMM-HabitTracker", position: "top_right", config: { updateInterval: 2000, // Update every two seconds habits: [ "Brush teeth", "Floss", "Exercise", "Read for 30 minutes", "Meditate" ], backendUrl: "http://localhost:5000", showCompletedCount: true, showProgressBar: true } }
The module requires a simple backend API to store habit data. The backend can be run as a daemon using PM2 for automatic restart and management.
One-command setup (recommended)
make installThis will install all dependencies and set up the backend daemon.
Manual setup
# Install dependencies only
npm install express cors
# Setup backend daemon
make setup
# (Optional) Set up auto-start on boot
make setup-backend-daemon| Command | Description |
|---|---|
make install |
Install all dependencies and setup backend |
make setup |
Run the automated backend setup script |
make start-backend |
Start the backend daemon |
make stop-backend |
Stop the backend daemon |
make restart-backend |
Restart the backend daemon |
make status-backend |
Check backend status |
make logs-backend |
View backend logs |
make setup-backend-daemon |
Set up auto-start on boot |
make setup-systemd |
Set up systemd service (requires sudo) |
All setup and utility scripts are located in the scripts/ directory:
scripts/setup-backend.sh- Main automated setup script (portable across systems)scripts/setup-systemd.sh- Systemd service setup (portable across systems)scripts/start-backend.sh- Simple backend startup script
Note: All scripts automatically detect their location and work on any system (macOS, Linux, Raspberry Pi, etc.).
The backend will run on http://localhost:5000 by default.
GET /api/habits?date=YYYY-MM-DD- Get habits for a specific datePOST /api/habits- Save habits for a specific dateGET /api/health- Health check endpointGET /api/habits/all- Get all habits data (for debugging)
| Option | Type | Default | Description |
|---|---|---|---|
updateInterval |
Number | 60000 | Update interval in milliseconds |
habits |
Array | ["Brush teeth", "Floss", "Exercise", "Read for 30 minutes", "Meditate"] |
List of habits to track |
backendUrl |
String | "http://localhost:5000" |
Backend API URL |
showCompletedCount |
Boolean | true |
Show completed count in progress bar |
showProgressBar |
Boolean | true |
Show progress bar |
- Install and setup:
make install(installs dependencies and starts backend) - Start your MagicMirror
- Click on any habit to toggle its completion status
- Habits automatically reset at the end of each day
- Completed habits are displayed with strikethrough text
- Install and setup:
make install - Start backend:
make start-backend - Stop backend:
make stop-backend - Restart backend:
make restart-backend - Check status:
make status-backend - View logs:
make logs-backend - Auto-start on boot:
make setup-backend-daemon
magic_mirror/
├── data/ # Data storage directory
│ └── habits_data.json # Habit tracking data
├── scripts/ # Setup and utility scripts
│ ├── setup-backend.sh
│ ├── setup-systemd.sh
│ └── start-backend.sh
├── logs/ # PM2 log files
├── module.js # MagicMirror module
├── MMM-HabitTracker.css # Module styling
├── backend.js # Backend API server
├── ecosystem.config.js # PM2 configuration
└── Makefile # Build and management commands
Habit data is stored in data/habits_data.json in the project directory. The data structure is:
{
"2024-01-15": [
{
"name": "Brush teeth",
"completed": true,
"date": "2024-01-15"
},
{
"name": "Floss",
"completed": false,
"date": "2024-01-15"
}
]
}Edit the habits array in your MagicMirror config:
habits: [
"Brush teeth",
"Floss",
"Exercise",
"Read for 30 minutes",
"Meditate",
"Drink 8 glasses of water",
"Take vitamins"
]The module uses MMM-HabitTracker.css for styling. You can customize colors, fonts, and layout by modifying this file.
- Backend not responding: Make sure the backend server is running on the correct port
- Habits not saving: Check that the backend has write permissions to the module directory
- Module not loading: Verify the module is properly installed in the MagicMirror modules directory
To modify the module:
- Edit
module.jsfor functionality changes - Edit
MMM-HabitTracker.cssfor styling changes - Edit
backend.jsfor API changes - Restart MagicMirror to see changes
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
For issues and questions, please open an issue on the GitHub repository.