# bas-hashimi/mastrack architecture

> Architecture diagram of the GitHub repository bas-hashimi/mastrack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bas-hashimi/mastrack
- Repository: https://github.com/bas-hashimi/mastrack

## Overview

MassTrack is a fitness and nutrition dashboard. A user interacts with rendered views; browser actions update application state, and signed-in users load and save that state through the PHP API to MySQL. The visible capabilities include meal planning and nutrition tracking, shopping lists, calorie and macro calculations, training plans, weight tracking, hydration, supplements, and habits. Several view and API details are excerpted only partially, so the graph includes only relationships shown in those excerpts; the README contains no product documentation.

Main entry points: [`src/script/views.js`](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js) (Dashboard views), [`src/script/app.js`](https://github.com/bas-hashimi/mastrack/blob/main/src/script/app.js) (UI actions), [`src/api.php`](https://github.com/bas-hashimi/mastrack/blob/main/src/api.php) (Account and state API), [`src/script/state.js`](https://github.com/bas-hashimi/mastrack/blob/main/src/script/state.js) (App state and sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser application"]
  node_actions["UI actions<br/>[app.js]"]
  node_state["App state and sync<br/>[state.js]"]
  node_views["Dashboard views<br/>[views.js]"]
end

subgraph group_features["Fitness features"]
  node_mealdata["Meal plan data<br/>[data.js]"]
  node_nutrition["Nutrition tracking<br/>[views.js]"]
  node_shopping["Shopping list<br/>[views.js]"]
  node_caloriecalc["Calorie calculator<br/>[views.js]"]
  node_training["Training plans<br/>[views.js]"]
  node_weight["Weight tracking<br/>[views.js]"]
  node_habits["Habit tracking<br/>[views.js]"]
end

subgraph group_backend["Persistence"]
  node_api["Account and state API<br/>[api.php]"]
  node_mysql[("MySQL database<br/>[init.sql]")]
end

node_user(("User"))

node_user -->|"uses dashboard"| node_views
node_views -->|"renders"| node_nutrition
node_views -->|"renders"| node_shopping
node_views -->|"renders"| node_caloriecalc
node_views -->|"renders"| node_training
node_views -->|"renders"| node_weight
node_views -->|"renders"| node_habits
node_views -->|"reads meal plan"| node_mealdata
node_user -->|"triggers actions"| node_actions
node_actions -->|"updates state"| node_state
node_actions -->|"sends auth"| node_api
node_state -->|"loads and saves"| node_api
node_api -->|"reads and writes"| node_mysql

click node_actions "https://github.com/bas-hashimi/mastrack/blob/main/src/script/app.js"
click node_state "https://github.com/bas-hashimi/mastrack/blob/main/src/script/state.js"
click node_views "https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js"
click node_mealdata "https://github.com/bas-hashimi/mastrack/blob/main/src/script/data.js"
click node_nutrition "https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js"
click node_shopping "https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js"
click node_caloriecalc "https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js"
click node_training "https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js"
click node_weight "https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js"
click node_habits "https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js"
click node_api "https://github.com/bas-hashimi/mastrack/blob/main/src/api.php"
click node_mysql "https://github.com/bas-hashimi/mastrack/blob/main/db/init.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_actions,node_state,node_views,node_user toneBlue
class node_mealdata,node_nutrition,node_shopping,node_caloriecalc,node_training,node_weight,node_habits toneAmber
class node_api,node_mysql toneMint
```

## Components

### Browser application

- [UI actions](https://github.com/bas-hashimi/mastrack/blob/main/src/script/app.js): `src/script/app.js`
- [App state and sync](https://github.com/bas-hashimi/mastrack/blob/main/src/script/state.js): `src/script/state.js`
- [Dashboard views](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js): `src/script/views.js`

### Fitness features

- [Meal plan data](https://github.com/bas-hashimi/mastrack/blob/main/src/script/data.js): `src/script/data.js`
- [Nutrition tracking](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js): `src/script/views.js`
- [Shopping list](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js): `src/script/views.js`
- [Calorie calculator](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js): `src/script/views.js`
- [Training plans](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js): `src/script/views.js`
- [Weight tracking](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js): `src/script/views.js`
- [Habit tracking](https://github.com/bas-hashimi/mastrack/blob/main/src/script/views.js): `src/script/views.js`

### Persistence

- [Account and state API](https://github.com/bas-hashimi/mastrack/blob/main/src/api.php): `src/api.php`
- [MySQL database](https://github.com/bas-hashimi/mastrack/blob/main/db/init.sql): `db/init.sql`

### Other components

- **User**

## Connections

- User → Dashboard views: uses dashboard (evidence: `src/script/views.js`)
- Dashboard views → Nutrition tracking: renders (evidence: `src/script/views.js`)
- Dashboard views → Shopping list: renders (evidence: `src/script/views.js`)
- Dashboard views → Calorie calculator: renders (evidence: `src/script/views.js`)
- Dashboard views → Training plans: renders (evidence: `src/script/views.js`)
- Dashboard views → Weight tracking: renders (evidence: `src/script/views.js`)
- Dashboard views → Habit tracking: renders (evidence: `src/script/views.js`)
- Dashboard views → Meal plan data: reads meal plan (evidence: `src/script/views.js`)
- User → UI actions: triggers actions (evidence: `src/script/app.js`)
- UI actions → App state and sync: updates state (evidence: `src/script/app.js`)
- UI actions → Account and state API: sends auth (evidence: `src/script/app.js`)
- App state and sync → Account and state API: loads and saves (evidence: `src/script/state.js`)
- Account and state API → MySQL database: reads and writes (evidence: `src/api.php`)
