Practical Project 1: Daily Focus & Habit Tracker
Difficulty: Beginner (Recommended First Project)
Estimated Effort: 1 weekend (working in small, calm 30–45 minute sessions)
Core Skills Practiced: Tight MVP scoping, intentional UI design, vertical-slice implementation, timezone bug debugging, unit & integration testing, Git workflow, and simple deployment.
Overview
In this walkthrough, you will build a calm Daily Focus & Habit Tracker—a focused single-user web app where someone picks 1–5 daily habits, checks them off for today, and sees their daily completion count persist across page refreshes.
We intentionally avoid bloated features (no social feeds, no login walls in v1, no decorative charts) so you master the complete 9-phase workflow cleanly.
Phase 1: Idea & Product Thinking
Problem Statement
Self-directed learners and remote workers want to track 3–5 simple daily habits in under 10 seconds a day, because complex productivity apps feel overwhelming and end up abandoned after week one.
Challenging AI Assumptions
- AI initially suggested: "Add user accounts, streak leaderboards, push notifications, and weekly analytics charts!"
- Your engineering decision: Reject all four. A single person opening their tracker on their primary computer/phone does not need a login wall in v1, and leaderboards add clutter.
MVP Scope
- Essential (In Scope for v1):
- View today's habits with a simple
completed / totalcounter. - Add a new habit (1–80 characters).
- Toggle a habit complete/incomplete for today's date.
- Delete a habit cleanly.
- View today's habits with a simple
- Out of Scope (Later): User accounts, multi-device sync, reminders, streaks history graphs, dark mode toggle.
Phase 2: Requirements & Planning
Sample User Stories & Acceptance Criteria
- Story 1 (Add Habit): As a learner, I want to add a daily habit so it appears in today's checklist.
- Blank or whitespace-only titles are rejected with an inline message.
- Valid titles appear immediately and survive a browser refresh.
- Story 2 (Toggle Complete): As a learner, I want to check off a habit for today so I can track daily progress.
- Clicking toggles completion visually and updates the
X / Y donecounter. - Completion state persists across browser refresh for today's date.
- Clicking toggles completion visually and updates the
- Story 3 (Delete Habit): As a learner, I want to remove an unwanted habit so my list stays tidy.
- Clicking Delete removes the habit immediately and updates the counter.
Development Plan (Milestones)
- Milestone 1: Initialize repo,
.gitignore,docs/, and verify blank starter runs onlocalhost. - Milestone 2 (Slice 1): Database table +
GET/POST /api/habits+ Today Screen list & Add form + verify persistence. - Milestone 3 (Slice 2):
PATCH /api/habits/:id/toggle&DELETE /api/habits/:id+ UI controls. - Milestone 4: Fix edge cases, write automated tests, review security/code, deploy & smoke test.
Phase 3: UI/UX & Design
Screen Inventory (1 Screen!)
/(Today Screen): Header with today's readable date +X / Ypill, inline "Add habit" form, clean habit list (plus friendly empty state when 0 habits exist).
Text Wireframe
+----------------------------------------------------+
| Daily Focus Tue, Dec 2 [1 / 3] |
+----------------------------------------------------+
| [ e.g. Read 15 pages... ] [ + Add ] |
+----------------------------------------------------+
| [x] Read 15 pages [Delete] |
| [ ] Walk 20 minutes [Delete] |
| [ ] Drink 2L water [Delete] |
+----------------------------------------------------+
Design Direction Rules
- Tone: Calm paper index card (
#FAF9F6page background,#FFFFFFcard,#1E293Btext,#15803Dgreen accent). - Avoid: Purple gradients, floating cards with random percentages, cramped icon toolbars.
- Mobile check: Single centered column (
max-width: 600px), large tap targets (>= 44pxheight).
Phase 4: System Design & Architecture
Chosen Stack (Simple & Portable)
- Option Chosen: Single unified web server (e.g., Node.js + Express or Python + FastAPI serving clean HTML/CSS/JS frontend files) backed by SQLite locally (or PostgreSQL if deploying to a stateless host).
- Why: Zero separate frontend build servers to coordinate, easy for beginners to read end-to-end, works cleanly in every AI agent.
Data Model
habitstable:id(integer primary key),title(text, not null),last_completed_date(textYYYY-MM-DD, nullable),created_at(timestamp).
Phase 5: Project Setup
(See Lesson 5.3: Setting Up Your Database for a step-by-step walkthrough of SQLite vs. PostgreSQL.)
- Create a folder
daily-focus-trackerand rungit init. - Add
docs/prd.md,docs/design-direction.md,docs/architecture.md. - Create
.gitignore(excluding.env,node_modules/,.venv/,*.dblocal database files) and.env.example(PORT=3000,DATABASE_URL=./data/habits.db). - Set up your local SQLite database & table: No separate database software is needed for SQLite—have your starter setup script create
./data/habits.dband run your initialhabitstable creation query automatically on startup (or via adb:migratescript). - Scaffold the minimal starter server with one
GET /api/healthendpoint checking database connectivity ({"ok": true, "database": "connected"}) and oneindex.htmlshowing"Daily Focus"onhttp://localhost:3000. - Run
git status, verify.envand*.dbdo not appear, commit"chore: initial project skeleton and docs", and push to GitHub.
Phase 6: AI-Assisted Implementation (One Slice at a Time)
Slice 1 Prompt Pattern (Inspect -> Plan -> Backend -> Frontend)
- Inspect & Plan: Ask the agent to read
docs/prd.mdanddocs/architecture.md, inspect existing files, and propose the exact files for Milestone 2 (habitstable +GET/POST /api/habits+ Add form). - Backend first: Implement
habitsschema creation andGET /api/habits+POST /api/habits(checkingtitle.trim()length 1–80, returning400with a clear JSON error if empty).- Verify yourself: Test
GET /api/habitsandPOST /api/habits(both valid and empty""title) before touching HTML/JS.
- Verify yourself: Test
- Frontend second: Connect
index.html+app.jsto fetch and render habits, show the friendly empty state whenhabits.length === 0, and handlePOSTerrors inline.- Verify yourself: Add 2 habits, refresh the page, confirm they remain; submit blank spaces, confirm inline error appears.
- Slice 2: Repeat the exact same workflow on a new branch (
feat/toggle-and-delete) forPATCHtoggle andDELETE.
Phase 7: Debugging & Quality
Classic Beginner Bug Caught Here (Timezone Mismatch!)
Suppose at 9:30 PM local time you check off a habit, refresh the page, and it shows unchecked!
- Investigate instead of guessing: Inspect Browser DevTools Network response for
GET /api/habits->last_completed_datesays"2026-12-03", while your browser's local date is"2026-12-02"! - Root Cause: The server used UTC (
new Date().toISOString().slice(0, 10)), which already flipped to tomorrow in UTC while your laptop was still on today's evening date! - Targeted Fix: Pass the user's local
YYYY-MM-DDdate explicitly from the browser (or compute consistently using the agreed date logic) and add a unit/integration test checking date comparison.
Automated Tests to Write & Run
- Unit test:
validateHabitTitle(" ")returns an error;validateHabitTitle("Read")passes. - Integration tests:
POST /api/habitswith valid title returns201and appears inGET /api/habits.POST /api/habitswith blank title returns400.DELETE /api/habits/:idremoves the item and returns404if deleted twice.
Phase 8: Git & Collaboration
- Keep each milestone on its own short branch (
feat/create-list-habits,feat/toggle-delete,test/api-coverage). - Check
git diffbefore committing—make sure no leftoverconsole.log("debug")lines remain. - Push each branch to GitHub, open a Pull Request, read the Files changed diff in GitHub, and merge into
main.
Phase 9: Deployment & Verification
- Check persistence before deploying: If your chosen host resets local disk files on redeploy, switch the production connection from a local SQLite file to a managed PostgreSQL database (or attach a persistent volume).
- Configure
PORT(provided by host) andDATABASE_URLin the hosting dashboard's Environment Variables. - Deploy
mainand run the Incognito Smoke Test:- Open the
https://URL on desktop and on your phone. - Confirm empty state loads cleanly.
- Add 2 habits, check 1 off, refresh -> both habits and check state survive.
- Delete 1 habit, refresh -> stays deleted.
- Inspect hosting Runtime Logs -> zero
500errors.
- Open the
Next Walkthrough: Project 2: Personal Bookmark & Reading Vault →