# markadvalorem/habit-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/markadvalorem/habit-tracker
- Repository: https://github.com/markadvalorem/habit-tracker

## Overview

Habit Tracker is an offline-first mobile habit manager: users create and organize habits, record completions, then review progress through statistics and badges. The app keeps habits and settings on-device, schedules local reminders, and offers exports and personalization. The graph follows the documented product scope and source-index relationships; some screens and integrations were not excerpted, so their internal wiring is omitted where it cannot be verified.

Main entry points: [`lib/habit-context.tsx`](https://github.com/markadvalorem/habit-tracker/blob/main/lib/habit-context.tsx) (Habit state), [`app/(tabs)/statistics.tsx`](https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/statistics.tsx) (Statistics screen), [`app/(tabs)/settings.tsx`](https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/settings.tsx) (Settings screen), [`app/add-habit.tsx`](https://github.com/markadvalorem/habit-tracker/blob/main/app/add-habit.tsx) (Habit editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Habit experience"]
  node_home["Today’s habits<br/>[index.tsx]"]
  node_editor["Habit editor<br/>[add-habit.tsx]"]
  node_detail["Habit detail<br/>[&#91;id&#93;.tsx]"]
  node_archive["Archived habits"]
end

subgraph group_insights["Progress insights"]
  node_statistics["Statistics screen<br/>[statistics.tsx]"]
  node_heatmap["Annual heatmap<br/>[annual-heatmap.tsx]"]
  node_monthly["Monthly chart<br/>[monthly-chart.tsx]"]
  node_trends["Trend chart<br/>[trend-chart.tsx]"]
  node_weekly["Weekly comparison"]
  node_badges["Badges screen<br/>[badges.tsx]"]
  node_badgecalc["Badge rules<br/>[badges.ts]"]
end

subgraph group_appstate["App state and setup"]
  node_habitstate["Habit state<br/>[habit-context.tsx]"]
  node_storage[("AsyncStorage")]
  node_languageinit["Language state"]
  node_onboarding["Onboarding<br/>[onboarding.tsx]"]
  node_onboardstate["Onboarding state"]
  node_tutorial["Interactive tutorial"]
end

subgraph group_settings["Personalization and reminders"]
  node_settingsscreen["Settings screen<br/>[settings.tsx]"]
  node_export["CSV / HTML export<br/>[export-service.ts]"]
  node_scheduler["Local reminders"]
  node_language["Language selection"]
end

subgraph group_shared["Shared UI and logic"]
  node_timerange["Time range picker"]
  node_timepicker["Time picker<br/>[time-picker.tsx]"]
  node_calendar["Completion calendar"]
  node_streaks["Streak calculations<br/>[streak-utils.ts]"]
  node_timeutils["Time utilities<br/>[time-utils.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_home
node_user -->|"creates habits"| node_editor
node_user -->|"reviews progress"| node_statistics
node_user -->|"configures"| node_settingsscreen
node_home -->|"reads and updates"| node_habitstate
node_editor -->|"creates or edits"| node_habitstate
node_detail -->|"reads habit data"| node_habitstate
node_detail -->|"renders completions"| node_calendar
node_archive -->|"manages archive"| node_habitstate
node_habitstate -->|"persists data"| node_storage
node_habitstate -->|"schedules reminders"| node_scheduler
node_habitstate -->|"validates times"| node_timeutils
node_statistics -->|"reads completion data"| node_habitstate
node_statistics -->|"renders"| node_heatmap
node_statistics -->|"renders"| node_monthly
node_statistics -->|"renders"| node_trends
node_statistics -->|"renders"| node_weekly
node_badges -->|"reads progress"| node_habitstate
node_badges -->|"gets badge rules"| node_badgecalc
node_settingsscreen -->|"updates settings"| node_habitstate
node_settingsscreen -->|"exports records"| node_export
node_settingsscreen -->|"manages vacation reminder"| node_scheduler
node_settingsscreen -->|"configures preferences"| node_storage
node_language -->|"sets language"| node_languageinit
node_languageinit -->|"persists selection"| node_storage
node_onboarding -->|"records progress"| node_onboardstate
node_editor -->|"opens time range"| node_timerange
node_timerange -->|"uses"| node_timepicker
node_export -->|"calculates streaks"| node_streaks

click node_home "https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/index.tsx"
click node_editor "https://github.com/markadvalorem/habit-tracker/blob/main/app/add-habit.tsx"
click node_detail "https://github.com/markadvalorem/habit-tracker/blob/main/app/habit-detail/%5Bid%5D.tsx"
click node_archive "https://github.com/markadvalorem/habit-tracker/blob/main/app/archived-habits.tsx"
click node_habitstate "https://github.com/markadvalorem/habit-tracker/blob/main/lib/habit-context.tsx"
click node_statistics "https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/statistics.tsx"
click node_heatmap "https://github.com/markadvalorem/habit-tracker/blob/main/components/annual-heatmap.tsx"
click node_monthly "https://github.com/markadvalorem/habit-tracker/blob/main/components/monthly-chart.tsx"
click node_trends "https://github.com/markadvalorem/habit-tracker/blob/main/components/trend-chart.tsx"
click node_weekly "https://github.com/markadvalorem/habit-tracker/blob/main/components/weekly-comparison.tsx"
click node_badges "https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/badges.tsx"
click node_badgecalc "https://github.com/markadvalorem/habit-tracker/blob/main/lib/badges.ts"
click node_settingsscreen "https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/settings.tsx"
click node_export "https://github.com/markadvalorem/habit-tracker/blob/main/lib/export-service.ts"
click node_scheduler "https://github.com/markadvalorem/habit-tracker/blob/main/lib/notification-scheduler.ts"
click node_language "https://github.com/markadvalorem/habit-tracker/blob/main/app/language-select.tsx"
click node_languageinit "https://github.com/markadvalorem/habit-tracker/blob/main/lib/language-init-context.tsx"
click node_onboarding "https://github.com/markadvalorem/habit-tracker/blob/main/app/onboarding.tsx"
click node_onboardstate "https://github.com/markadvalorem/habit-tracker/blob/main/lib/onboarding-context.tsx"
click node_tutorial "https://github.com/markadvalorem/habit-tracker/blob/main/lib/tutorial-context.tsx"
click node_timerange "https://github.com/markadvalorem/habit-tracker/blob/main/components/time-range-modal.tsx"
click node_timepicker "https://github.com/markadvalorem/habit-tracker/blob/main/components/time-picker.tsx"
click node_calendar "https://github.com/markadvalorem/habit-tracker/blob/main/components/calendar-grid-advanced.tsx"
click node_streaks "https://github.com/markadvalorem/habit-tracker/blob/main/lib/streak-utils.ts"
click node_timeutils "https://github.com/markadvalorem/habit-tracker/blob/main/lib/time-utils.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_home,node_editor,node_detail,node_archive,node_user toneBlue
class node_statistics,node_heatmap,node_monthly,node_trends,node_weekly,node_badges,node_badgecalc toneAmber
class node_habitstate,node_storage,node_languageinit,node_onboarding,node_onboardstate,node_tutorial toneMint
class node_settingsscreen,node_export,node_scheduler,node_language toneRose
class node_timerange,node_timepicker,node_calendar,node_streaks,node_timeutils toneIndigo
```

## Components

### Habit experience

- [Today’s habits](https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`
- [Habit editor](https://github.com/markadvalorem/habit-tracker/blob/main/app/add-habit.tsx): `app/add-habit.tsx`
- [Habit detail](https://github.com/markadvalorem/habit-tracker/blob/main/app/habit-detail/%5Bid%5D.tsx): `app/habit-detail/[id].tsx`
- [Archived habits](https://github.com/markadvalorem/habit-tracker/blob/main/app/archived-habits.tsx): `app/archived-habits.tsx`

### Progress insights

- [Statistics screen](https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/statistics.tsx): `app/(tabs)/statistics.tsx`
- [Annual heatmap](https://github.com/markadvalorem/habit-tracker/blob/main/components/annual-heatmap.tsx): `components/annual-heatmap.tsx`
- [Monthly chart](https://github.com/markadvalorem/habit-tracker/blob/main/components/monthly-chart.tsx): `components/monthly-chart.tsx`
- [Trend chart](https://github.com/markadvalorem/habit-tracker/blob/main/components/trend-chart.tsx): `components/trend-chart.tsx`
- [Weekly comparison](https://github.com/markadvalorem/habit-tracker/blob/main/components/weekly-comparison.tsx): `components/weekly-comparison.tsx`
- [Badges screen](https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/badges.tsx): `app/(tabs)/badges.tsx`
- [Badge rules](https://github.com/markadvalorem/habit-tracker/blob/main/lib/badges.ts): `lib/badges.ts`

### App state and setup

- [Habit state](https://github.com/markadvalorem/habit-tracker/blob/main/lib/habit-context.tsx): `lib/habit-context.tsx`
- **AsyncStorage**
- [Language state](https://github.com/markadvalorem/habit-tracker/blob/main/lib/language-init-context.tsx): `lib/language-init-context.tsx`
- [Onboarding](https://github.com/markadvalorem/habit-tracker/blob/main/app/onboarding.tsx): `app/onboarding.tsx`
- [Onboarding state](https://github.com/markadvalorem/habit-tracker/blob/main/lib/onboarding-context.tsx): `lib/onboarding-context.tsx`
- [Interactive tutorial](https://github.com/markadvalorem/habit-tracker/blob/main/lib/tutorial-context.tsx): `lib/tutorial-context.tsx`

### Personalization and reminders

- [Settings screen](https://github.com/markadvalorem/habit-tracker/blob/main/app/(tabs)/settings.tsx): `app/(tabs)/settings.tsx`
- [CSV / HTML export](https://github.com/markadvalorem/habit-tracker/blob/main/lib/export-service.ts): `lib/export-service.ts`
- [Local reminders](https://github.com/markadvalorem/habit-tracker/blob/main/lib/notification-scheduler.ts): `lib/notification-scheduler.ts`
- [Language selection](https://github.com/markadvalorem/habit-tracker/blob/main/app/language-select.tsx): `app/language-select.tsx`

### Shared UI and logic

- [Time range picker](https://github.com/markadvalorem/habit-tracker/blob/main/components/time-range-modal.tsx): `components/time-range-modal.tsx`
- [Time picker](https://github.com/markadvalorem/habit-tracker/blob/main/components/time-picker.tsx): `components/time-picker.tsx`
- [Completion calendar](https://github.com/markadvalorem/habit-tracker/blob/main/components/calendar-grid-advanced.tsx): `components/calendar-grid-advanced.tsx`
- [Streak calculations](https://github.com/markadvalorem/habit-tracker/blob/main/lib/streak-utils.ts): `lib/streak-utils.ts`
- [Time utilities](https://github.com/markadvalorem/habit-tracker/blob/main/lib/time-utils.ts): `lib/time-utils.ts`

### Other components

- **User**

## Connections

- User → Today’s habits: uses (evidence: `README.md`)
- User → Habit editor: creates habits (evidence: `README.md`)
- User → Statistics screen: reviews progress (evidence: `README.md`)
- User → Settings screen: configures (evidence: `README.md`)
- Today’s habits → Habit state: reads and updates (evidence: `app/(tabs)/index.tsx`)
- Habit editor → Habit state: creates or edits (evidence: `app/add-habit.tsx`)
- Habit detail → Habit state: reads habit data (evidence: `app/habit-detail/[id].tsx`)
- Habit detail → Completion calendar: renders completions (evidence: `app/habit-detail/[id].tsx`)
- Archived habits → Habit state: manages archive (evidence: `app/archived-habits.tsx`)
- Habit state → AsyncStorage: persists data (evidence: `README.md`)
- Habit state → Local reminders: schedules reminders (evidence: `lib/habit-context.tsx`)
- Habit state → Time utilities: validates times (evidence: `lib/habit-context.tsx`)
- Statistics screen → Habit state: reads completion data (evidence: `app/(tabs)/statistics.tsx`)
- Statistics screen → Annual heatmap: renders (evidence: `app/(tabs)/statistics.tsx`)
- Statistics screen → Monthly chart: renders (evidence: `app/(tabs)/statistics.tsx`)
- Statistics screen → Trend chart: renders (evidence: `app/(tabs)/statistics.tsx`)
- Statistics screen → Weekly comparison: renders (evidence: `app/(tabs)/statistics.tsx`)
- Badges screen → Habit state: reads progress (evidence: `app/(tabs)/badges.tsx`)
- Badges screen → Badge rules: gets badge rules (evidence: `app/(tabs)/badges.tsx`)
- Settings screen → Habit state: updates settings (evidence: `app/(tabs)/settings.tsx`)
- Settings screen → CSV / HTML export: exports records (evidence: `app/(tabs)/settings.tsx`)
- Settings screen → Local reminders: manages vacation reminder (evidence: `app/(tabs)/settings.tsx`)
- Settings screen → AsyncStorage: configures preferences (evidence: `README.md`)
- Language selection → Language state: sets language (evidence: `README.md`)
- Language state → AsyncStorage: persists selection (evidence: `lib/language-init-context.tsx`)
- Onboarding → Onboarding state: records progress (evidence: `app/onboarding.tsx`)
- Habit editor → Time range picker: opens time range (evidence: `app/add-habit.tsx`)
- Time range picker → Time picker: uses (evidence: `components/time-range-modal.tsx`)
- CSV / HTML export → Streak calculations: calculates streaks (evidence: `lib/export-service.ts`)
