# varunikashrees/carbonbuddy_by_techtrio architecture

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

- Interactive diagram: https://gitdiagram.com/varunikashrees/carbonbuddy_by_techtrio
- Repository: https://github.com/varunikashrees/carbonbuddy_by_techtrio

## Overview

CarbonBuddy is a personal carbon-footprint tracker that turns spending records into emissions estimates and visual insights. Users sign in, add or upload transactions, review dashboard trends, and manage goals, offsets, settings, and committed action plans. The principal flow is routed by the home page and relies on shared user state backed by browser storage and Supabase. Smart-insight capabilities are represented, but the sampled excerpts do not establish their exact API wiring.

Main entry points: [`src/lib/UserContext.tsx`](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/UserContext.tsx) (User context), [`src/components/AppShell.tsx`](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/AppShell.tsx) (App navigation), [`src/app/page.tsx`](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/app/page.tsx) (Home router), [`src/components/Offset.tsx`](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Offset.tsx) (Goals and offsets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_home["Home router<br/>[page.tsx]"]
  node_login["Sign-in<br/>[Login.tsx]"]
  node_shell["App navigation<br/>[AppShell.tsx]"]
  node_transactions["Transactions<br/>[Transactions.tsx]"]
  node_settings["Preferences<br/>[Settings.tsx]"]
end

subgraph group_impact["Carbon insights"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_offset["Goals and offsets<br/>[Offset.tsx]"]
  node_plans["Action plans"]
  node_insights_api["Insights endpoint<br/>[route.ts]"]
end

subgraph group_state["User state and storage"]
  node_user_state["User context<br/>[UserContext.tsx]"]
  node_storage[("Emissions and local storage<br/>[storage.ts]")]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_types["Domain data types<br/>[types.ts]"]
end

subgraph group_shared["Shared interface"]
  node_providers["Context providers<br/>[Providers.tsx]"]
  node_ui["UI primitives<br/>[button.tsx]"]
end

node_user(("Person"))
node_supabase[("Supabase")]

node_user -->|"opens"| node_home
node_home -->|"reads state"| node_user_state
node_home -->|"routes unauthenticated"| node_login
node_home -->|"renders authenticated"| node_shell
node_shell -->|"renders"| node_dashboard
node_shell -->|"renders"| node_transactions
node_shell -->|"renders"| node_offset
node_shell -->|"renders"| node_settings
node_login -->|"uses auth state"| node_user_state
node_transactions -->|"updates records"| node_user_state
node_transactions -->|"calculates emissions"| node_storage
node_dashboard -->|"reads user data"| node_user_state
node_offset -->|"updates goals"| node_user_state
node_offset -->|"renders plans"| node_plans
node_settings -->|"updates preferences"| node_user_state
node_user_state -->|"loads and saves"| node_storage
node_user_state -->|"uses client"| node_supabase_client
node_supabase_client -.->|"connects"| node_supabase
node_user_state -->|"uses schemas"| node_types
node_storage -->|"uses schemas"| node_types
node_providers -->|"provides context"| node_user_state
node_dashboard -.->|"may request insights"| node_insights_api
node_offset -.->|"may request insights"| node_insights_api
node_shell -->|"uses controls"| node_ui

click node_home "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/app/page.tsx"
click node_login "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Login.tsx"
click node_shell "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/AppShell.tsx"
click node_transactions "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Transactions.tsx"
click node_settings "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Settings.tsx"
click node_dashboard "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Dashboard.tsx"
click node_offset "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Offset.tsx"
click node_plans "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/CommittedActionPlans.tsx"
click node_insights_api "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/app/api/insights/route.ts"
click node_user_state "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/UserContext.tsx"
click node_storage "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/storage.ts"
click node_supabase_client "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/supabase.ts"
click node_types "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/types.ts"
click node_providers "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Providers.tsx"
click node_ui "https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/ui/button.tsx"

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_login,node_shell,node_transactions,node_settings toneBlue
class node_dashboard,node_offset,node_plans,node_insights_api,node_supabase toneAmber
class node_user_state,node_storage,node_supabase_client,node_types toneMint
class node_providers,node_ui toneRose
class node_user toneIndigo
```

## Components

### User experience

- [Home router](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Sign-in](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Login.tsx): `src/components/Login.tsx`
- [App navigation](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/AppShell.tsx): `src/components/AppShell.tsx`
- [Transactions](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Transactions.tsx): `src/components/Transactions.tsx`
- [Preferences](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Settings.tsx): `src/components/Settings.tsx`

### Carbon insights

- [Dashboard](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Dashboard.tsx): `src/components/Dashboard.tsx`
- [Goals and offsets](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Offset.tsx): `src/components/Offset.tsx`
- [Action plans](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/CommittedActionPlans.tsx): `src/components/CommittedActionPlans.tsx`
- [Insights endpoint](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/app/api/insights/route.ts): `src/app/api/insights/route.ts`

### User state and storage

- [User context](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/UserContext.tsx): `src/lib/UserContext.tsx`
- [Emissions and local storage](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- [Supabase client](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Domain data types](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/lib/types.ts): `src/lib/types.ts`

### Shared interface

- [Context providers](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/Providers.tsx): `src/components/Providers.tsx`
- [UI primitives](https://github.com/varunikashrees/carbonbuddy_by_techtrio/blob/main/src/components/ui/button.tsx): `src/components/ui/button.tsx`

### Other components

- **Person**
- **Supabase**

## Connections

- Person → Home router: opens (evidence: `src/app/page.tsx`)
- Home router → User context: reads state (evidence: `src/app/page.tsx`)
- Home router → Sign-in: routes unauthenticated (evidence: `src/app/page.tsx`)
- Home router → App navigation: renders authenticated (evidence: `src/app/page.tsx`)
- App navigation → Dashboard: renders (evidence: `src/app/page.tsx`)
- App navigation → Transactions: renders (evidence: `src/app/page.tsx`)
- App navigation → Goals and offsets: renders (evidence: `src/app/page.tsx`)
- App navigation → Preferences: renders (evidence: `src/app/page.tsx`)
- Sign-in → User context: uses auth state (evidence: `src/components/Login.tsx`)
- Transactions → User context: updates records (evidence: `src/components/Transactions.tsx`)
- Transactions → Emissions and local storage: calculates emissions (evidence: `src/components/Transactions.tsx`)
- Dashboard → User context: reads user data (evidence: `src/components/Dashboard.tsx`)
- Goals and offsets → User context: updates goals (evidence: `src/components/Offset.tsx`)
- Goals and offsets → Action plans: renders plans (evidence: `src/components/Offset.tsx`)
- Preferences → User context: updates preferences (evidence: `src/components/Settings.tsx`)
- User context → Emissions and local storage: loads and saves (evidence: `src/lib/UserContext.tsx`)
- User context → Supabase client: uses client (evidence: `src/lib/UserContext.tsx`)
- Supabase client → Supabase: connects
- User context → Domain data types: uses schemas (evidence: `src/lib/UserContext.tsx`)
- Emissions and local storage → Domain data types: uses schemas (evidence: `src/lib/storage.ts`)
- Context providers → User context: provides context (evidence: `src/components/Providers.tsx`)
- Dashboard → Insights endpoint: may request insights
- Goals and offsets → Insights endpoint: may request insights
- App navigation → UI primitives: uses controls (evidence: `src/components/AppShell.tsx`)
