How mohamadalghish93/mood-tracker works
Project type and purpose
• This is primarily a developer‐focused CLI tool (“moodtracker”) with an optional lightweight web dashboard.
• Its core purpose is to record and report “mood” entries on each git commit, storing them in a SQLite database, and to provide stats via CLI or a small HTTP server.
File structure
• Top level:
• index.js – CLI entrypoint (registered under “bin” in package.json)
• server.js – Express-based web dashboard server
• mood.db – SQLite storage file
• package.json / package-lock.json – dependency metadata and configuration (defines the CLI executable)
• views/index.ejs – HTML template for the dashboard
• .gitignore – excludes node_modules, mood.db (optional), etc.
• No distinct “frontend” folder – this is a server‐rendered application.
• No microservices – everything lives in a single Node.js process (CLI or HTTP server modes).
README for additional insights
• Commands:
• moodtracker add <emoji> [text] → writes a new record to SQLite
• moodtracker stats → queries SQLite and outputs to stdout
• Optional Git hook (post-commit) automatically calls the CLI
• node server.js → boots a visual mood dashboard (web UI)
Main components and interactions
a. Components
1. User’s Shell / Git Workflow
2. Git Hook (post-commit) → triggers CLI
3. CLI Application (index.js)
4. SQLite Database (mood.db)
5. HTTP Server (server.js, Express)
6. Templating Engine (EJS in views/index.ejs)
7. Browser / Web Client (dashboard UI)
b. Relationships & Data Flow
• CLI “add” → writes INSERT to SQLite
• CLI “stats” → reads SELECTs from SQLite → stdout
• HTTP Server → on GET / → reads from SQLite → EJS renders HTML → Browser
• Git Hook → invokes CLI “add” automatically after git commit
c. Architectural patterns & design principles
• Single‐process Node.js binary serving two modes (CLI vs. HTTP)
• Data layer: single SQLite file (embedded database)
• Presentation: server-side HTML templating (EJS)
• Separation of concerns:
– CLI commands vs. web dashboard code paths
– Persistence isolated behind a small “DB access” module (could be index.js or a helper)
d. Key technologies & libraries
• Node.js (runtime)
• Express (server.js)
• EJS (views/index.ejs)
• sqlite3 or better-sqlite3 npm module for DB I/O
• Git (hook integration)
• npm / package.json “bin” field for CLI installation