# radishguyy/caloria architecture

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

- Interactive diagram: https://gitdiagram.com/radishguyy/caloria
- Repository: https://github.com/radishguyy/caloria

## Overview

Caloria is a gamified nutrition tracker paired with a virtual pet and social co-op features. The principal workflow is to record a meal—optionally using an AI nutrition scan—then review and save it; the app tracks nutrition against goals and connects food logging with pet care and rewards. Other major capabilities include pet evolution and customization, friends and streaks, recaps, notifications, and wallet/NFT features. Some subsystem links are based on README descriptions or import references; unsampled implementations are not treated as inspected.

Main entry points: [`src/db/index.ts`](https://github.com/radishguyy/caloria/blob/main/src/db/index.ts) (PostgreSQL data), [`src/components/diary/ReviewScanModal.tsx`](https://github.com/radishguyy/caloria/blob/main/src/components/diary/ReviewScanModal.tsx) (Scan review), [`src/store/use-pet-store.ts`](https://github.com/radishguyy/caloria/blob/main/src/store/use-pet-store.ts) (Pet state), [`src/app/api/friends`](https://github.com/radishguyy/caloria/tree/main/src/app/api/friends) (Friends API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_nutrition["Nutrition and diary"]
  node_diary["Meal diary"]
  node_scan_ui["Scan review"]
  node_scan_api["Nutrition scan API<br/>[route.ts]"]
  node_scan_provider["Scan providers<br/>[scan-provider.ts]"]
  node_assessment["Product assessment"]
  node_food_store["Food log state<br/>[use-food-store.ts]"]
  node_quest_engine["Goal and quest engine<br/>[quest-engine.ts]"]
end

subgraph group_pet["Pet and customization"]
  node_pet_ui["Pet experience"]
  node_pet_preview["Pet preview<br/>[avatar-preview.tsx]"]
  node_pet_store["Pet state<br/>[use-pet-store.ts]"]
  node_pet_needs["Pet needs engine<br/>[needs-engine.ts]"]
  node_pet_decay["Pet decay evaluator<br/>[decay-evaluator.ts]"]
  node_customization["Pet customization"]
  node_character_catalog["Character assets<br/>[catalog.ts]"]
end

subgraph group_social["Social and engagement"]
  node_social_ui["Friends and co-op"]
  node_friends_api["Friends API"]
  node_streak_service["Streak service<br/>[streak-service.ts]"]
  node_recaps["Nutrition recaps"]
  node_notifications["Push notifications<br/>[push-service.ts]"]
end

subgraph group_platform["Identity and persistence"]
  node_auth["Authentication<br/>[server.ts]"]
  node_actions["Server actions"]
  node_database[("PostgreSQL data<br/>[index.ts]")]
  node_schema["Domain schema"]
end

subgraph group_experience["App experience"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_tour["Guided tour<br/>[TourProvider.tsx]"]
  node_tour_store["Tour state<br/>[use-tour-store.ts]"]
  node_web3["Wallet and NFTs"]
end

node_user(("User"))

node_user -->|"records meals"| node_diary
node_user -->|"scans food"| node_scan_ui
node_scan_ui -->|"saves scan"| node_actions
node_scan_api -->|"extracts nutrition"| node_scan_provider
node_scan_api -->|"uses categories"| node_assessment
node_scan_ui -->|"assesses product"| node_assessment
node_scan_ui -->|"updates state"| node_food_store
node_food_store -->|"evaluates goals"| node_quest_engine
node_quest_engine -.->|"uses nutrition calculations"| node_schema
node_user -->|"cares for pet"| node_pet_ui
node_pet_ui -.->|"renders pet"| node_pet_preview
node_pet_preview -->|"reads pet state"| node_pet_store
node_pet_store -->|"checks needs"| node_pet_needs
node_pet_store -->|"evaluates decay"| node_pet_decay
node_pet_store -->|"loads character"| node_character_catalog
node_user -->|"customizes pet"| node_customization
node_user -->|"joins co-op"| node_social_ui
node_social_ui -.->|"manages friends"| node_friends_api
node_friends_api -->|"authenticates requests"| node_auth
node_friends_api -->|"reads and writes"| node_database
node_user -->|"views recaps"| node_recaps
node_recaps -->|"reads and writes"| node_database
node_user -->|"receives alerts"| node_notifications
node_streak_service -->|"updates streak data"| node_database
node_user -->|"signs in"| node_auth
node_actions -.->|"persists domain changes"| node_database
node_database -->|"uses definitions"| node_schema
node_user -->|"opens app"| node_dashboard
node_dashboard -.->|"shows pet"| node_pet_ui
node_tour -->|"uses tour state"| node_tour_store
node_user -->|"uses wallet features"| node_web3

click node_diary "https://github.com/radishguyy/caloria/tree/main/src/app/diary"
click node_scan_ui "https://github.com/radishguyy/caloria/blob/main/src/components/diary/ReviewScanModal.tsx"
click node_scan_api "https://github.com/radishguyy/caloria/blob/main/src/app/api/nutrition/scan/route.ts"
click node_scan_provider "https://github.com/radishguyy/caloria/blob/main/src/lib/nutrition/scan-provider.ts"
click node_assessment "https://github.com/radishguyy/caloria/blob/main/src/lib/nutrition/product-assessment.ts"
click node_food_store "https://github.com/radishguyy/caloria/blob/main/src/store/use-food-store.ts"
click node_quest_engine "https://github.com/radishguyy/caloria/blob/main/src/lib/gamification/quest-engine.ts"
click node_pet_ui "https://github.com/radishguyy/caloria/tree/main/src/app/pet"
click node_pet_preview "https://github.com/radishguyy/caloria/blob/main/src/components/pet/avatar-preview.tsx"
click node_pet_store "https://github.com/radishguyy/caloria/blob/main/src/store/use-pet-store.ts"
click node_pet_needs "https://github.com/radishguyy/caloria/blob/main/src/lib/pet/needs-engine.ts"
click node_pet_decay "https://github.com/radishguyy/caloria/blob/main/src/lib/pet/decay-evaluator.ts"
click node_customization "https://github.com/radishguyy/caloria/tree/main/src/app/pet-customization"
click node_character_catalog "https://github.com/radishguyy/caloria/blob/main/src/lib/character-assets/catalog.ts"
click node_social_ui "https://github.com/radishguyy/caloria/tree/main/src/app/social"
click node_friends_api "https://github.com/radishguyy/caloria/tree/main/src/app/api/friends"
click node_streak_service "https://github.com/radishguyy/caloria/blob/main/src/lib/server/streak-service.ts"
click node_recaps "https://github.com/radishguyy/caloria/tree/main/src/app/api/recaps"
click node_notifications "https://github.com/radishguyy/caloria/blob/main/src/lib/server/push-service.ts"
click node_auth "https://github.com/radishguyy/caloria/blob/main/src/lib/supabase/server.ts"
click node_actions "https://github.com/radishguyy/caloria/tree/main/src/app/actions"
click node_database "https://github.com/radishguyy/caloria/blob/main/src/db/index.ts"
click node_schema "https://github.com/radishguyy/caloria/tree/main/src/db/schema"
click node_dashboard "https://github.com/radishguyy/caloria/blob/main/src/app/dashboard/page.tsx"
click node_tour "https://github.com/radishguyy/caloria/blob/main/src/components/tour/TourProvider.tsx"
click node_tour_store "https://github.com/radishguyy/caloria/blob/main/src/store/use-tour-store.ts"
click node_web3 "https://github.com/radishguyy/caloria/tree/main/src/lib/web3"

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_diary,node_scan_ui,node_scan_api,node_scan_provider,node_assessment,node_food_store,node_quest_engine,node_user toneBlue
class node_pet_ui,node_pet_preview,node_pet_store,node_pet_needs,node_pet_decay,node_customization,node_character_catalog toneAmber
class node_social_ui,node_friends_api,node_streak_service,node_recaps,node_notifications toneMint
class node_auth,node_actions,node_database,node_schema toneRose
class node_dashboard,node_tour,node_tour_store,node_web3 toneIndigo
```

## Components

### Nutrition and diary

- [Meal diary](https://github.com/radishguyy/caloria/tree/main/src/app/diary): `src/app/diary`
- [Scan review](https://github.com/radishguyy/caloria/blob/main/src/components/diary/ReviewScanModal.tsx): `src/components/diary/ReviewScanModal.tsx`
- [Nutrition scan API](https://github.com/radishguyy/caloria/blob/main/src/app/api/nutrition/scan/route.ts): `src/app/api/nutrition/scan/route.ts`
- [Scan providers](https://github.com/radishguyy/caloria/blob/main/src/lib/nutrition/scan-provider.ts): `src/lib/nutrition/scan-provider.ts`
- [Product assessment](https://github.com/radishguyy/caloria/blob/main/src/lib/nutrition/product-assessment.ts): `src/lib/nutrition/product-assessment.ts`
- [Food log state](https://github.com/radishguyy/caloria/blob/main/src/store/use-food-store.ts): `src/store/use-food-store.ts`
- [Goal and quest engine](https://github.com/radishguyy/caloria/blob/main/src/lib/gamification/quest-engine.ts): `src/lib/gamification/quest-engine.ts`

### Pet and customization

- [Pet experience](https://github.com/radishguyy/caloria/tree/main/src/app/pet): `src/app/pet`
- [Pet preview](https://github.com/radishguyy/caloria/blob/main/src/components/pet/avatar-preview.tsx): `src/components/pet/avatar-preview.tsx`
- [Pet state](https://github.com/radishguyy/caloria/blob/main/src/store/use-pet-store.ts): `src/store/use-pet-store.ts`
- [Pet needs engine](https://github.com/radishguyy/caloria/blob/main/src/lib/pet/needs-engine.ts): `src/lib/pet/needs-engine.ts`
- [Pet decay evaluator](https://github.com/radishguyy/caloria/blob/main/src/lib/pet/decay-evaluator.ts): `src/lib/pet/decay-evaluator.ts`
- [Pet customization](https://github.com/radishguyy/caloria/tree/main/src/app/pet-customization): `src/app/pet-customization`
- [Character assets](https://github.com/radishguyy/caloria/blob/main/src/lib/character-assets/catalog.ts): `src/lib/character-assets/catalog.ts`

### Social and engagement

- [Friends and co-op](https://github.com/radishguyy/caloria/tree/main/src/app/social): `src/app/social`
- [Friends API](https://github.com/radishguyy/caloria/tree/main/src/app/api/friends): `src/app/api/friends`
- [Streak service](https://github.com/radishguyy/caloria/blob/main/src/lib/server/streak-service.ts): `src/lib/server/streak-service.ts`
- [Nutrition recaps](https://github.com/radishguyy/caloria/tree/main/src/app/api/recaps): `src/app/api/recaps`
- [Push notifications](https://github.com/radishguyy/caloria/blob/main/src/lib/server/push-service.ts): `src/lib/server/push-service.ts`

### Identity and persistence

- [Authentication](https://github.com/radishguyy/caloria/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Server actions](https://github.com/radishguyy/caloria/tree/main/src/app/actions): `src/app/actions`
- [PostgreSQL data](https://github.com/radishguyy/caloria/blob/main/src/db/index.ts): `src/db/index.ts`
- [Domain schema](https://github.com/radishguyy/caloria/tree/main/src/db/schema): `src/db/schema`

### App experience

- [Dashboard](https://github.com/radishguyy/caloria/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Guided tour](https://github.com/radishguyy/caloria/blob/main/src/components/tour/TourProvider.tsx): `src/components/tour/TourProvider.tsx`
- [Tour state](https://github.com/radishguyy/caloria/blob/main/src/store/use-tour-store.ts): `src/store/use-tour-store.ts`
- [Wallet and NFTs](https://github.com/radishguyy/caloria/tree/main/src/lib/web3): `src/lib/web3`

### Other components

- **User**

## Connections

- User → Meal diary: records meals
- User → Scan review: scans food
- Scan review → Server actions: saves scan (evidence: `src/components/diary/ReviewScanModal.tsx`)
- Nutrition scan API → Scan providers: extracts nutrition (evidence: `src/app/api/nutrition/scan/route.ts`)
- Nutrition scan API → Product assessment: uses categories (evidence: `src/app/api/nutrition/scan/route.ts`)
- Scan review → Product assessment: assesses product (evidence: `src/components/diary/ReviewScanModal.tsx`)
- Scan review → Food log state: updates state (evidence: `src/components/diary/ReviewScanModal.tsx`)
- Food log state → Goal and quest engine: evaluates goals (evidence: `src/store/use-food-store.ts`)
- Goal and quest engine → Domain schema: uses nutrition calculations
- User → Pet experience: cares for pet
- Pet experience → Pet preview: renders pet
- Pet preview → Pet state: reads pet state (evidence: `src/components/pet/avatar-preview.tsx`)
- Pet state → Pet needs engine: checks needs (evidence: `src/store/use-pet-store.ts`)
- Pet state → Pet decay evaluator: evaluates decay (evidence: `src/store/use-pet-store.ts`)
- Pet state → Character assets: loads character (evidence: `src/store/use-pet-store.ts`)
- User → Pet customization: customizes pet
- User → Friends and co-op: joins co-op
- Friends and co-op → Friends API: manages friends
- Friends API → Authentication: authenticates requests (evidence: `src/app/api/friends/route.ts`)
- Friends API → PostgreSQL data: reads and writes (evidence: `src/app/api/friends/route.ts`)
- User → Nutrition recaps: views recaps
- Nutrition recaps → PostgreSQL data: reads and writes (evidence: `src/app/api/recaps/generate/route.ts`)
- User → Push notifications: receives alerts
- Streak service → PostgreSQL data: updates streak data (evidence: `src/lib/server/streak-service.ts`)
- User → Authentication: signs in
- Server actions → PostgreSQL data: persists domain changes
- PostgreSQL data → Domain schema: uses definitions (evidence: `src/db/index.ts`)
- User → Dashboard: opens app
- Dashboard → Pet experience: shows pet
- Guided tour → Tour state: uses tour state (evidence: `src/components/tour/TourProvider.tsx`)
- User → Wallet and NFTs: uses wallet features
