# tristandurden/habit-hero architecture

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

- Interactive diagram: https://gitdiagram.com/tristandurden/habit-hero
- Repository: https://github.com/tristandurden/habit-hero

## Overview

Habit Hero is a habit-tracking application: users manage habits, record completions, and visualize progress, with folders, lists, timers, and reminders as related features. The graph follows the documented product capabilities and sampled API behavior; some client-side wiring is inferred from the file tree, so uncertain links are omitted.

Main entry points: [`lib/prisma.ts`](https://github.com/tristandurden/habit-hero/blob/main/lib/prisma.ts) (Prisma access), [`lib/auth.ts`](https://github.com/tristandurden/habit-hero/blob/main/lib/auth.ts) (Authentication), [`app/dashboard/page.tsx`](https://github.com/tristandurden/habit-hero/blob/main/app/dashboard/page.tsx) (Dashboard), [`app/components/habits/HabitCard.tsx`](https://github.com/tristandurden/habit-hero/blob/main/app/components/habits/HabitCard.tsx) (Habit views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_habit_views["Habit views<br/>[HabitCard.tsx]"]
  node_calendar_views["Calendar views<br/>[Calendar.tsx]"]
  node_list_views["List views<br/>[ItemsTable.tsx]"]
  node_timer_ui["Timer UI<br/>[Timer.tsx]"]
  node_timer_state["Timer state<br/>[timerStore.ts]"]
end

subgraph group_habits["Habit tracking"]
  node_habit_api["Habit API<br/>[route.ts]"]
  node_habit_logs["Completion logs<br/>[route.ts]"]
  node_habit_store["Habit state<br/>[habitStore.tsx]"]
  node_habit_sync["Habit sync<br/>[useHabitSync.ts]"]
end

subgraph group_organization["Organization and sync"]
  node_folders_api["Folder API<br/>[route.ts]"]
  node_lists_api["List API<br/>[route.ts]"]
  node_list_items_api["List items API<br/>[route.ts]"]
  node_sync_data["Sync download<br/>[route.ts]"]
  node_sync_ops["Sync operations<br/>[route.ts]"]
end

subgraph group_platform["Services and storage"]
  node_push_ui["Push settings"]
  node_cron["Reminder scheduler<br/>[route.ts]"]
  node_actions["Notification actions<br/>[actions.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_database[("MySQL database")]
  node_prisma["Prisma access<br/>[prisma.ts]"]
end

node_user(("User"))
node_web_push["Push service"]

node_user -->|"opens"| node_dashboard
node_dashboard -->|"shows"| node_habit_views
node_dashboard -->|"shows"| node_calendar_views
node_dashboard -->|"shows"| node_list_views
node_dashboard -->|"shows"| node_timer_ui
node_habit_views -->|"updates"| node_habit_store
node_habit_store -->|"syncs state"| node_habit_sync
node_habit_sync -->|"submits changes"| node_sync_ops
node_habit_sync -->|"fetches data"| node_sync_data
node_habit_views -->|"manages habits"| node_habit_api
node_habit_api -->|"reads and writes"| node_prisma
node_habit_logs -->|"reads logs"| node_prisma
node_folders_api -->|"reads and writes"| node_prisma
node_lists_api -->|"reads and writes"| node_prisma
node_list_items_api -->|"reads and writes"| node_prisma
node_sync_data -->|"loads user data"| node_prisma
node_sync_ops -->|"applies queued changes"| node_prisma
node_prisma -->|"queries"| node_database
node_timer_ui -->|"controls"| node_timer_state
node_user -->|"configures alerts"| node_push_ui
node_push_ui -->|"subscribes or tests"| node_actions
node_cron -->|"loads habits"| node_prisma
node_cron -->|"sends reminders"| node_actions
node_actions -->|"dispatches"| node_web_push
node_user -->|"signs in"| node_auth
node_habit_api -->|"checks session"| node_auth
node_folders_api -->|"checks session"| node_auth
node_lists_api -->|"checks session"| node_auth
node_sync_data -->|"checks session"| node_auth
node_sync_ops -->|"checks session"| node_auth

click node_dashboard "https://github.com/tristandurden/habit-hero/blob/main/app/dashboard/page.tsx"
click node_habit_views "https://github.com/tristandurden/habit-hero/blob/main/app/components/habits/HabitCard.tsx"
click node_calendar_views "https://github.com/tristandurden/habit-hero/blob/main/app/components/calendars/Calendar.tsx"
click node_list_views "https://github.com/tristandurden/habit-hero/blob/main/app/components/lists/ItemsTable.tsx"
click node_timer_ui "https://github.com/tristandurden/habit-hero/blob/main/app/components/timer/Timer.tsx"
click node_habit_api "https://github.com/tristandurden/habit-hero/blob/main/app/api/habits/route.ts"
click node_habit_logs "https://github.com/tristandurden/habit-hero/blob/main/app/api/habitlog/route.ts"
click node_habit_store "https://github.com/tristandurden/habit-hero/blob/main/app/habitStore.tsx"
click node_habit_sync "https://github.com/tristandurden/habit-hero/blob/main/app/hooks/habits/useHabitSync.ts"
click node_folders_api "https://github.com/tristandurden/habit-hero/blob/main/app/api/folders/route.ts"
click node_lists_api "https://github.com/tristandurden/habit-hero/blob/main/app/api/lists/route.ts"
click node_list_items_api "https://github.com/tristandurden/habit-hero/blob/main/app/api/lists/%5Bid%5D/items/route.ts"
click node_sync_data "https://github.com/tristandurden/habit-hero/blob/main/app/api/sync-data/route.ts"
click node_sync_ops "https://github.com/tristandurden/habit-hero/blob/main/app/api/sync/route.ts"
click node_timer_state "https://github.com/tristandurden/habit-hero/blob/main/app/timerStore.ts"
click node_push_ui "https://github.com/tristandurden/habit-hero/blob/main/app/pwa/PushNotificationManager.tsx"
click node_cron "https://github.com/tristandurden/habit-hero/blob/main/app/api/cron/notifications/route.ts"
click node_actions "https://github.com/tristandurden/habit-hero/blob/main/app/actions.ts"
click node_auth "https://github.com/tristandurden/habit-hero/blob/main/lib/auth.ts"
click node_prisma "https://github.com/tristandurden/habit-hero/blob/main/lib/prisma.ts"

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_dashboard,node_habit_views,node_calendar_views,node_list_views,node_timer_ui,node_timer_state,node_user toneBlue
class node_habit_api,node_habit_logs,node_habit_store,node_habit_sync toneAmber
class node_folders_api,node_lists_api,node_list_items_api,node_sync_data,node_sync_ops toneMint
class node_push_ui,node_cron,node_actions,node_auth,node_database,node_prisma toneRose
class node_web_push toneIndigo
```

## Components

### User experience

- [Dashboard](https://github.com/tristandurden/habit-hero/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Habit views](https://github.com/tristandurden/habit-hero/blob/main/app/components/habits/HabitCard.tsx): `app/components/habits/HabitCard.tsx`
- [Calendar views](https://github.com/tristandurden/habit-hero/blob/main/app/components/calendars/Calendar.tsx): `app/components/calendars/Calendar.tsx`
- [List views](https://github.com/tristandurden/habit-hero/blob/main/app/components/lists/ItemsTable.tsx): `app/components/lists/ItemsTable.tsx`
- [Timer UI](https://github.com/tristandurden/habit-hero/blob/main/app/components/timer/Timer.tsx): `app/components/timer/Timer.tsx`
- [Timer state](https://github.com/tristandurden/habit-hero/blob/main/app/timerStore.ts): `app/timerStore.ts`

### Habit tracking

- [Habit API](https://github.com/tristandurden/habit-hero/blob/main/app/api/habits/route.ts): `app/api/habits/route.ts`
- [Completion logs](https://github.com/tristandurden/habit-hero/blob/main/app/api/habitlog/route.ts): `app/api/habitlog/route.ts`
- [Habit state](https://github.com/tristandurden/habit-hero/blob/main/app/habitStore.tsx): `app/habitStore.tsx`
- [Habit sync](https://github.com/tristandurden/habit-hero/blob/main/app/hooks/habits/useHabitSync.ts): `app/hooks/habits/useHabitSync.ts`

### Organization and sync

- [Folder API](https://github.com/tristandurden/habit-hero/blob/main/app/api/folders/route.ts): `app/api/folders/route.ts`
- [List API](https://github.com/tristandurden/habit-hero/blob/main/app/api/lists/route.ts): `app/api/lists/route.ts`
- [List items API](https://github.com/tristandurden/habit-hero/blob/main/app/api/lists/%5Bid%5D/items/route.ts): `app/api/lists/[id]/items/route.ts`
- [Sync download](https://github.com/tristandurden/habit-hero/blob/main/app/api/sync-data/route.ts): `app/api/sync-data/route.ts`
- [Sync operations](https://github.com/tristandurden/habit-hero/blob/main/app/api/sync/route.ts): `app/api/sync/route.ts`

### Services and storage

- [Push settings](https://github.com/tristandurden/habit-hero/blob/main/app/pwa/PushNotificationManager.tsx): `app/pwa/PushNotificationManager.tsx`
- [Reminder scheduler](https://github.com/tristandurden/habit-hero/blob/main/app/api/cron/notifications/route.ts): `app/api/cron/notifications/route.ts`
- [Notification actions](https://github.com/tristandurden/habit-hero/blob/main/app/actions.ts): `app/actions.ts`
- [Authentication](https://github.com/tristandurden/habit-hero/blob/main/lib/auth.ts): `lib/auth.ts`
- **MySQL database**
- [Prisma access](https://github.com/tristandurden/habit-hero/blob/main/lib/prisma.ts): `lib/prisma.ts`

### Other components

- **User**
- **Push service**

## Connections

- User → Dashboard: opens
- Dashboard → Habit views: shows
- Dashboard → Calendar views: shows
- Dashboard → List views: shows
- Dashboard → Timer UI: shows
- Habit views → Habit state: updates
- Habit state → Habit sync: syncs state
- Habit sync → Sync operations: submits changes
- Habit sync → Sync download: fetches data
- Habit views → Habit API: manages habits
- Habit API → Prisma access: reads and writes
- Completion logs → Prisma access: reads logs
- Folder API → Prisma access: reads and writes
- List API → Prisma access: reads and writes
- List items API → Prisma access: reads and writes
- Sync download → Prisma access: loads user data
- Sync operations → Prisma access: applies queued changes
- Prisma access → MySQL database: queries
- Timer UI → Timer state: controls
- User → Push settings: configures alerts
- Push settings → Notification actions: subscribes or tests
- Reminder scheduler → Prisma access: loads habits
- Reminder scheduler → Notification actions: sends reminders
- Notification actions → Push service: dispatches
- User → Authentication: signs in
- Habit API → Authentication: checks session
- Folder API → Authentication: checks session
- List API → Authentication: checks session
- Sync download → Authentication: checks session
- Sync operations → Authentication: checks session
