How westonludeke/discipline-tracker works
Project Type and Purpose
• This is a full-stack web application (“Discipline Tracker App”) for tracking personal goals and daily progress over time.
• Frontend: React (Vite, Bootstrap, Chart.js, jQuery, Day.js)
• Backend: Node.js + Express + Mongoose (MongoDB)
• Database: MongoDB (local or Atlas)
File Structure Analysis
• Top-level:
• server/ – Express server entry (index.js), models (Goal.js, Progress.js), routes (goals.js, weeklyReports.js)
• src/ – React app source
– api/ – Axios wrapper + service modules for goals & progress
– components/ – UI components (pages, charts, tables, modal, navigation, calendar, import)
– utils/dataParser.js
– AppRouter.jsx, App.jsx, styles, main.jsx
• Config & tooling: vite.config.js, package.json, ESLint, index.html
Key Architectural Patterns
• Separation of Concerns (frontend vs. backend)
• MVC-style on server: models → controllers/ routes → middleware
• API-driven UI: React calls Express REST endpoints via Axios
• Stateless server; persistent storage in MongoDB
• Modular React: components per feature, router handles page navigation
Main Components & Interactions
A. Frontend (React SPA)
– AppRouter: defines routes for Home, Goals, Reports, Import pages
– API layer (src/api): axios.js config + endpoints goals.js, progress.js
– UI components:
• GoalsList, GoalProgressChart, StreakCalendar, MonthlyProgressTable, WeeklyReports, HistoricalLog, Modal, Navigation
– Utilities: dataParser formats raw API data for charts & tables
– CSS: Bootstrap + custom styles
B. Backend (Express API)
– index.js: sets up Express, middleware (CORS, Morgan, bodyParser), connects to MongoDB
– Routes: /api/goals, /api/weeklyReports
– Models: Mongoose schemas for Goal and Progress
C. Database (MongoDB)
– goal documents (target mins, schedule)
– progress documents (date, actual minutes)
D. External Services (optional)
– MongoDB Atlas (if used)
– Chart.js (frontend charting)
Data Flow:
1. User interacts with UI → triggers an Axios call in src/api →
2. Express route handler in server/routes → Mongoose query/update →
3. MongoDB returns data → Express serializes JSON →
4. Frontend receives JSON → dataParser processes → UI updates components (charts, tables)
Final Checklist
• [ ] Clear labels for each module (React components, API services, Express routes, DB)
• [ ] Annotations for frameworks/libraries (Vite, Bootstrap, Chart.js, Axios, Mongoose)
• [ ] Container outlines grouping related files/components