# nephwf/kaloriinw architecture

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

- Interactive diagram: https://gitdiagram.com/nephwf/kaloriinw
- Repository: https://github.com/nephwf/kaloriinw

## Overview

kaloriiNW is a browser-based calorie and nutrition diary; the README says data stays in localStorage and no server is needed. The main workflow is recording food, water, and activity by day, then reviewing calorie/macronutrient totals and seven-day statistics. The app also supports a product catalog, custom foods, and Mifflin–St Jeor-based targets. The sampled app excerpt shows these responsibilities in app.js, but not all internal calls; the catalog’s use by the app is therefore shown as unverified. Offline caching is implemented by the sampled service worker.

Main entry points: [`app.js`](https://github.com/nephwf/kaloriinw/blob/main/app.js) (Diary app), [`sw.js`](https://github.com/nephwf/kaloriinw/blob/main/sw.js) (Cache worker), [`foods.js`](https://github.com/nephwf/kaloriinw/blob/main/foods.js) (Food catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_diary["Food diary"]
  node_app["Diary app<br/>[app.js]"]
  node_storage[("Browser storage")]
end

subgraph group_reference["Nutrition data"]
  node_catalog[("Food catalog<br/>[foods.js]")]
end

subgraph group_offline["Offline support"]
  node_worker["Cache worker<br/>[sw.js]"]
  node_cache[("Asset cache")]
end

node_user(("Diary user"))

node_user -->|"records meals"| node_app
node_app -->|"stores diary"| node_storage
node_app -.->|"uses catalog"| node_catalog
node_worker -->|"caches assets"| node_cache
node_worker -->|"serves offline"| node_cache

click node_app "https://github.com/nephwf/kaloriinw/blob/main/app.js"
click node_catalog "https://github.com/nephwf/kaloriinw/blob/main/foods.js"
click node_worker "https://github.com/nephwf/kaloriinw/blob/main/sw.js"

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_app,node_storage,node_user toneBlue
class node_catalog toneAmber
class node_worker,node_cache toneMint
```

## Components

### Food diary

- [Diary app](https://github.com/nephwf/kaloriinw/blob/main/app.js): `app.js`
- **Browser storage**

### Nutrition data

- [Food catalog](https://github.com/nephwf/kaloriinw/blob/main/foods.js): `foods.js`

### Offline support

- [Cache worker](https://github.com/nephwf/kaloriinw/blob/main/sw.js): `sw.js`
- **Asset cache**

### Other components

- **Diary user**

## Connections

- Diary user → Diary app: records meals (evidence: `README.md`)
- Diary app → Browser storage: stores diary (evidence: `README.md`)
- Diary app → Food catalog: uses catalog
- Cache worker → Asset cache: caches assets (evidence: `sw.js`)
- Cache worker → Asset cache: serves offline (evidence: `sw.js`)
