How happy-jm/tomato-do works
Project Type & Purpose
• This is a client‐side single-page web application (SPA) without a separate server backend.
• Purpose: Provide a Pomodoro timer, persistent To-Do list (via IndexedDB), user profile (name/photo), badges based on accumulated focus time, and day/night theming.
File Structure
Top-level files & folders:
• index.html, tomato-do.css – the main UI shell & styles
• index.js – application bootstrap & routing to individual modules
• database.js – data‐access layer for IndexedDB (stores: todolist, time, userInfo, report)
• timer.js – Pomodoro timer logic, alarm triggers
• badge.js – computes badge eligibility from “time” store
• inputName.js, inputPropicture.js – UI flows for profile setup
• snd/ – audio assets for alarms
• img/ – static UI images
README
• Confirms IndexedDB schema and explains main features: CRUD To-Do, timer with voice alerts, time tracking, badges, theme toggle.
• No external server or API calls—entirely browser/client‐side.
Main Components & Their Interactions
a. UI Layer (index.html + tomato-do.css)
– Contains placeholders/divs for To-Do list, timer display, badge panel, profile, theme toggle
b. Controller/Module Layer (JavaScript)
– index.js: Initializes modules, orchestrates navigation between views
– inputName.js & inputPropicture.js: Handle user profile setup UI & write to IndexedDB
– timer.js: Implements Pomodoro cycles; on cycle end, invokes snd/*.mp3 via Web Audio API
– badge.js: Reads “time” store, calculates badge levels, updates UI
– database.js: Abstracts IndexedDB operations (open, CRUD for todolist, report, userInfo, time)
c. Data Layer (IndexedDB)
– Four object stores: todolist, time, userInfo, report
– Database.js mediates all reads/writes
d. Assets
– snd folder (alarm audio)
Architectural Patterns & Principles
• Module-based separation of concerns (DAO, UI controllers, business logic)
• Client-side persistence (IndexedDB) in lieu of server
• Event-driven interactions (timer events, user inputs, theme toggle)
• MVC‐lite:
– Model: IndexedDB stores via database.js
– View: index.html + CSS and dynamic DOM updates
– Controller: JavaScript modules