# dsragul/green-habit-tracker architecture

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

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

## Overview

This is an eco-habits rewards app: users track sustainability impact, submit proof of completed tasks, earn points and achievements, and redeem rewards. The React app initializes its client state from sample data and presents dashboard, task, reward, leaderboard, achievement, and settings views; the server provides API routes, persists shared app state in Firestore, and initializes Gemini for AI features. Gmail impact-report sharing is also represented. The excerpts do not show all client-to-server calls or the complete verification flow, so those links are omitted rather than inferred.

Main entry points: [`App.tsx`](https://github.com/dsragul/green-habit-tracker/blob/main/App.tsx) (App state), [`server.ts`](https://github.com/dsragul/green-habit-tracker/blob/main/server.ts) (API server), [`GmailShareModal.tsx`](https://github.com/dsragul/green-habit-tracker/blob/main/GmailShareModal.tsx) (Gmail sharing), [`initialData.ts`](https://github.com/dsragul/green-habit-tracker/blob/main/initialData.ts) (Initial data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["App experience"]
  node_app["App state<br/>[App.tsx]"]
  node_seed["Initial data<br/>[initialData.ts]"]
  node_nav["Navigation<br/>[Navbar.tsx]"]
  node_toast["Notifications<br/>[Toast.tsx]"]
  node_settings["Account settings<br/>[SettingsPage.tsx]"]
end

subgraph group_eco["Eco engagement"]
  node_task["Task verification"]
  node_dashboard["Impact dashboard<br/>[UserDashboard.tsx]"]
  node_rewards["Reward center<br/>[RewardCenter.tsx]"]
  node_leaderboard["Leaderboard"]
  node_achievements["Achievements"]
  node_chat["AI chat<br/>[AIChatbot.tsx]"]
end

subgraph group_backend["Server services"]
  node_server["API server<br/>[server.ts]"]
  node_state[("App state store<br/>[server.ts]")]
  node_gemini{{"Gemini AI"}}
  node_firestore[("Firestore")]
end

subgraph group_sharing["Impact sharing"]
  node_gmail["Gmail sharing"]
  node_google{{"Google sign-in"}}
  node_gmailapi{{"Gmail API"}}
end

node_user(("Eco user"))

node_user -->|"uses"| node_app
node_app -->|"initializes from"| node_seed
node_app -->|"renders"| node_nav
node_app -->|"renders"| node_toast
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_task
node_app -->|"renders"| node_rewards
node_app -->|"renders"| node_leaderboard
node_app -->|"renders"| node_achievements
node_app -->|"renders"| node_settings
node_app -->|"posts state"| node_server
node_app -->|"posts chat"| node_server
node_server -->|"reads and writes"| node_state
node_server -->|"loads and seeds"| node_firestore
node_server -->|"initializes"| node_gemini
node_gmail -->|"signs in with"| node_google
node_gmail -->|"fetches profile and sends"| node_gmailapi

click node_app "https://github.com/dsragul/green-habit-tracker/blob/main/App.tsx"
click node_seed "https://github.com/dsragul/green-habit-tracker/blob/main/initialData.ts"
click node_nav "https://github.com/dsragul/green-habit-tracker/blob/main/Navbar.tsx"
click node_toast "https://github.com/dsragul/green-habit-tracker/blob/main/Toast.tsx"
click node_task "https://github.com/dsragul/green-habit-tracker/blob/main/TaskVerificationFlow.tsx"
click node_dashboard "https://github.com/dsragul/green-habit-tracker/blob/main/UserDashboard.tsx"
click node_rewards "https://github.com/dsragul/green-habit-tracker/blob/main/RewardCenter.tsx"
click node_leaderboard "https://github.com/dsragul/green-habit-tracker/blob/main/LeaderboardView.tsx"
click node_achievements "https://github.com/dsragul/green-habit-tracker/blob/main/AchievementsView.tsx"
click node_chat "https://github.com/dsragul/green-habit-tracker/blob/main/AIChatbot.tsx"
click node_settings "https://github.com/dsragul/green-habit-tracker/blob/main/SettingsPage.tsx"
click node_gmail "https://github.com/dsragul/green-habit-tracker/blob/main/GmailShareModal.tsx"
click node_server "https://github.com/dsragul/green-habit-tracker/blob/main/server.ts"
click node_state "https://github.com/dsragul/green-habit-tracker/blob/main/server.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_app,node_seed,node_nav,node_toast,node_settings,node_user toneBlue
class node_task,node_dashboard,node_rewards,node_leaderboard,node_achievements,node_chat toneAmber
class node_server,node_state,node_gemini,node_firestore toneMint
class node_gmail,node_google,node_gmailapi toneRose
```

## Components

### App experience

- [App state](https://github.com/dsragul/green-habit-tracker/blob/main/App.tsx): `App.tsx`
- [Initial data](https://github.com/dsragul/green-habit-tracker/blob/main/initialData.ts): `initialData.ts`
- [Navigation](https://github.com/dsragul/green-habit-tracker/blob/main/Navbar.tsx): `Navbar.tsx`
- [Notifications](https://github.com/dsragul/green-habit-tracker/blob/main/Toast.tsx): `Toast.tsx`
- [Account settings](https://github.com/dsragul/green-habit-tracker/blob/main/SettingsPage.tsx): `SettingsPage.tsx`

### Eco engagement

- [Task verification](https://github.com/dsragul/green-habit-tracker/blob/main/TaskVerificationFlow.tsx): `TaskVerificationFlow.tsx`
- [Impact dashboard](https://github.com/dsragul/green-habit-tracker/blob/main/UserDashboard.tsx): `UserDashboard.tsx`
- [Reward center](https://github.com/dsragul/green-habit-tracker/blob/main/RewardCenter.tsx): `RewardCenter.tsx`
- [Leaderboard](https://github.com/dsragul/green-habit-tracker/blob/main/LeaderboardView.tsx): `LeaderboardView.tsx`
- [Achievements](https://github.com/dsragul/green-habit-tracker/blob/main/AchievementsView.tsx): `AchievementsView.tsx`
- [AI chat](https://github.com/dsragul/green-habit-tracker/blob/main/AIChatbot.tsx): `AIChatbot.tsx`

### Server services

- [API server](https://github.com/dsragul/green-habit-tracker/blob/main/server.ts): `server.ts`
- [App state store](https://github.com/dsragul/green-habit-tracker/blob/main/server.ts): `server.ts`
- **Gemini AI**
- **Firestore**

### Impact sharing

- [Gmail sharing](https://github.com/dsragul/green-habit-tracker/blob/main/GmailShareModal.tsx): `GmailShareModal.tsx`
- **Google sign-in**
- **Gmail API**

### Other components

- **Eco user**

## Connections

- Eco user → App state: uses
- App state → Initial data: initializes from (evidence: `App.tsx`)
- App state → Navigation: renders (evidence: `App.tsx`)
- App state → Notifications: renders (evidence: `App.tsx`)
- App state → Impact dashboard: renders (evidence: `App.tsx`)
- App state → Task verification: renders (evidence: `App.tsx`)
- App state → Reward center: renders (evidence: `App.tsx`)
- App state → Leaderboard: renders (evidence: `App.tsx`)
- App state → Achievements: renders (evidence: `App.tsx`)
- App state → Account settings: renders (evidence: `App.tsx`)
- App state → API server: posts state (evidence: `App.tsx`)
- App state → API server: posts chat (evidence: `App.tsx`)
- API server → App state store: reads and writes (evidence: `server.ts`)
- API server → Firestore: loads and seeds (evidence: `server.ts`)
- API server → Gemini AI: initializes (evidence: `server.ts`)
- Gmail sharing → Google sign-in: signs in with (evidence: `GmailShareModal.tsx`)
- Gmail sharing → Gmail API: fetches profile and sends (evidence: `GmailShareModal.tsx`)
