# westonludeke/discipline-tracker architecture

> Architecture diagram of the GitHub repository westonludeke/discipline-tracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/westonludeke/discipline-tracker
- Repository: https://github.com/westonludeke/discipline-tracker

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client / Browser"
        Main["main.jsx"]:::frontend
        AppRouter["AppRouter.jsx"]:::frontend
        App["App.jsx"]:::frontend
        CSS["index.css"]:::frontend
        Navigation["Navigation.jsx"]:::frontend
        HomePage["HomePage.jsx"]:::frontend
        GoalsPage["Goals.jsx"]:::frontend
        ReportsPage["Reports.jsx"]:::frontend
        ImportPage["Import.jsx"]:::frontend

        subgraph "UI Components"
            GoalsList["GoalsList.jsx"]:::frontend
            GoalChart["GoalProgressChart.jsx"]:::frontend
            StreakCal["StreakCalendar.jsx"]:::frontend
            MonthlyTable["MonthlyProgressTable.jsx"]:::frontend
            WeeklyReps["WeeklyReports.jsx"]:::frontend
            HistLog["HistoricalLog.jsx"]:::frontend
            Modal["Modal.jsx"]:::frontend
        end

        DataParser["dataParser.js"]:::frontend

        subgraph "API Layer"
            AxiosConfig["axios.js"]:::frontend
            GoalsService["goals.js"]:::frontend
            ProgressService["progress.js"]:::frontend
        end

        Main --> AppRouter
        AppRouter --> App
        App --> Navigation
        App --> CSS
        Navigation --> HomePage
        Navigation --> GoalsPage
        Navigation --> ReportsPage
        Navigation --> ImportPage
        HomePage --> GoalsList
        GoalsPage --> GoalsList
        GoalsList --> GoalChart
        GoalsList --> MonthlyTable
        GoalsList --> StreakCal
        GoalsList --> WeeklyReps
        GoalsList --> HistLog
        GoalsList --> Modal
        GoalChart --> DataParser
        MonthlyTable --> DataParser
        StreakCal --> DataParser
        DataParser --> AxiosConfig
        AxiosConfig --> GoalsService
        AxiosConfig --> ProgressService
        GoalsService -->|"GET/POST /api/goals"| GoalsRoute
        ProgressService -->|"GET/POST /api/weeklyReports"| WeeklyRoute
    end

    subgraph "Server / API"
        Index["index.js"]:::backend
        subgraph "Routes"
            GoalsRoute["goals.js"]:::backend
            WeeklyRoute["weeklyReports.js"]:::backend
        end
        subgraph "Models"
            GoalModel["Goal.js"]:::backend
            ProgressModel["Progress.js"]:::backend
        end

        Index --> GoalsRoute
        Index --> WeeklyRoute
        GoalsRoute --> GoalModel
        WeeklyRoute --> ProgressModel
        GoalModel --> MongoDB
        ProgressModel --> MongoDB
    end

    subgraph "Database"
        MongoDB["MongoDB"]:::db
    end

    subgraph "External Services"
        Atlas["MongoDB Atlas"]:::external
    end

    MongoDB --> Atlas

    click AppRouter "https://github.com/westonludeke/discipline-tracker/blob/main/src/AppRouter.jsx"
    click App "https://github.com/westonludeke/discipline-tracker/blob/main/src/App.jsx"
    click Main "https://github.com/westonludeke/discipline-tracker/blob/main/src/main.jsx"
    click CSS "https://github.com/westonludeke/discipline-tracker/blob/main/src/index.css"
    click AxiosConfig "https://github.com/westonludeke/discipline-tracker/blob/main/src/api/axios.js"
    click GoalsService "https://github.com/westonludeke/discipline-tracker/blob/main/src/api/goals.js"
    click ProgressService "https://github.com/westonludeke/discipline-tracker/blob/main/src/api/progress.js"
    click DataParser "https://github.com/westonludeke/discipline-tracker/blob/main/src/utils/dataParser.js"
    click GoalsList "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/GoalsList.jsx"
    click GoalsPage "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/Goals.jsx"
    click GoalChart "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/GoalProgressChart.jsx"
    click StreakCal "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/StreakCalendar.jsx"
    click MonthlyTable "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/MonthlyProgressTable.jsx"
    click WeeklyReps "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/WeeklyReports.jsx"
    click HistLog "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/HistoricalLog.jsx"
    click Modal "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/Modal.jsx"
    click Navigation "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/Navigation.jsx"
    click HomePage "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/HomePage.jsx"
    click ReportsPage "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/Reports.jsx"
    click ImportPage "https://github.com/westonludeke/discipline-tracker/blob/main/src/components/Import.jsx"
    click Index "https://github.com/westonludeke/discipline-tracker/blob/main/server/index.js"
    click GoalModel "https://github.com/westonludeke/discipline-tracker/blob/main/server/models/Goal.js"
    click ProgressModel "https://github.com/westonludeke/discipline-tracker/blob/main/server/models/Progress.js"
    click GoalsRoute "https://github.com/westonludeke/discipline-tracker/blob/main/server/routes/goals.js"
    click WeeklyRoute "https://github.com/westonludeke/discipline-tracker/blob/main/server/routes/weeklyReports.js"

    classDef frontend fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1
    classDef backend fill:#C8E6C9,stroke:#43A047,color:#1B5E20
    classDef db fill:#FFE0B2,stroke:#FB8C00,color:#E65100
    classDef external fill:#E0E0E0,stroke:#9E9E9E,color:#424242
```
