# zrygx/java-nutrition-tracker architecture

> Architecture diagram of the GitHub repository zrygx/java-nutrition-tracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zrygx/java-nutrition-tracker
- Repository: https://github.com/zrygx/java-nutrition-tracker

## Overview

A local, in-memory command-line nutrition tracker. The user creates credentials and a calorie goal, logs in (with a three-attempt limit), then uses the menu to create, view, update, or delete dated food entries. Daily logs hold foods and calculate macro totals; viewing compares calories with the user's goal. Evidence is limited to the README and the provided source excerpts; no persistent storage or external integrations are shown.

Main entry points: [`src/main/NutritionTracker.java`](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java) (Tracker menu), [`src/main/DailyLog.java`](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/DailyLog.java) (Daily log and totals), [`src/main/Food.java`](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/Food.java) (Food and nutrients), [`src/main/User.java`](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/User.java) (Account and login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and access"]
  node_tracker["Tracker menu"]
  node_account["Account and login<br/>[User.java]"]
end

subgraph group_tracking["Food tracking"]
  node_create["Create daily log"]
  node_view["View and analyze"]
  node_update["Update food entry"]
  node_delete["Delete food entry"]
  node_history["In-memory history"]
end

subgraph group_domain["Nutrition domain"]
  node_daily_log["Daily log and totals<br/>[DailyLog.java]"]
  node_food["Food and nutrients<br/>[Food.java]"]
end

node_user_actor(("User"))

node_user_actor -->|"uses"| node_tracker
node_tracker -->|"authenticates"| node_account
node_tracker -->|"dispatches"| node_create
node_tracker -->|"dispatches"| node_view
node_tracker -->|"dispatches"| node_update
node_tracker -->|"dispatches"| node_delete
node_create -->|"adds log"| node_history
node_create -->|"creates"| node_daily_log
node_create -->|"creates"| node_food
node_create -->|"adds food"| node_daily_log
node_view -->|"searches"| node_history
node_view -->|"prints log"| node_daily_log
node_view -->|"reads goal"| node_account
node_update -->|"searches"| node_history
node_update -->|"updates fields"| node_food
node_delete -->|"searches"| node_history
node_delete -->|"removes food"| node_daily_log
node_daily_log -->|"stores and totals"| node_food

click node_tracker "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java"
click node_account "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/User.java"
click node_create "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java"
click node_view "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java"
click node_update "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java"
click node_delete "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java"
click node_history "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java"
click node_daily_log "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/DailyLog.java"
click node_food "https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/Food.java"

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_tracker,node_account,node_user_actor toneBlue
class node_create,node_view,node_update,node_delete,node_history toneAmber
class node_daily_log,node_food toneMint
```

## Components

### CLI and access

- [Tracker menu](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java): `src/main/NutritionTracker.java`
- [Account and login](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/User.java): `src/main/User.java`

### Food tracking

- [Create daily log](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java): `src/main/NutritionTracker.java`
- [View and analyze](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java): `src/main/NutritionTracker.java`
- [Update food entry](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java): `src/main/NutritionTracker.java`
- [Delete food entry](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java): `src/main/NutritionTracker.java`
- [In-memory history](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/NutritionTracker.java): `src/main/NutritionTracker.java`

### Nutrition domain

- [Daily log and totals](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/DailyLog.java): `src/main/DailyLog.java`
- [Food and nutrients](https://github.com/zrygx/java-nutrition-tracker/blob/master/src/main/Food.java): `src/main/Food.java`

### Other components

- **User**

## Connections

- User → Tracker menu: uses (evidence: `README.md`)
- Tracker menu → Account and login: authenticates (evidence: `src/main/NutritionTracker.java`)
- Tracker menu → Create daily log: dispatches (evidence: `src/main/NutritionTracker.java`)
- Tracker menu → View and analyze: dispatches (evidence: `src/main/NutritionTracker.java`)
- Tracker menu → Update food entry: dispatches (evidence: `src/main/NutritionTracker.java`)
- Tracker menu → Delete food entry: dispatches (evidence: `src/main/NutritionTracker.java`)
- Create daily log → In-memory history: adds log (evidence: `src/main/NutritionTracker.java`)
- Create daily log → Daily log and totals: creates (evidence: `src/main/NutritionTracker.java`)
- Create daily log → Food and nutrients: creates (evidence: `src/main/NutritionTracker.java`)
- Create daily log → Daily log and totals: adds food (evidence: `src/main/NutritionTracker.java`)
- View and analyze → In-memory history: searches (evidence: `src/main/NutritionTracker.java`)
- View and analyze → Daily log and totals: prints log (evidence: `src/main/NutritionTracker.java`)
- View and analyze → Account and login: reads goal (evidence: `src/main/NutritionTracker.java`)
- Update food entry → In-memory history: searches (evidence: `src/main/NutritionTracker.java`)
- Update food entry → Food and nutrients: updates fields (evidence: `src/main/NutritionTracker.java`)
- Delete food entry → In-memory history: searches (evidence: `src/main/NutritionTracker.java`)
- Delete food entry → Daily log and totals: removes food (evidence: `src/main/NutritionTracker.java`)
- Daily log and totals → Food and nutrients: stores and totals (evidence: `src/main/DailyLog.java`)
