# deekshhh37/smart-energy-chain architecture

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

- Interactive diagram: https://gitdiagram.com/deekshhh37/smart-energy-chain
- Repository: https://github.com/deekshhh37/smart-energy-chain

## Overview

Energy Wise is a React energy-monitoring dashboard: users sign in, view consumption and smart alerts, explore analytics, and review bills or export reports. The dashboard’s main data path loads a CSV and transforms it into display-ready usage statistics; authentication uses Supabase. README documents chatbot advice and analytics capabilities, but sampled source does not establish all backend connections, so those links are omitted. The analytics pages, edge functions, and several visual components were not sampled in full.

Main entry points: [`src/App.tsx`](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/App.tsx) (Routes and app shell), [`src/pages/Dashboard.tsx`](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Dashboard.tsx) (Dashboard page), [`src/pages/Billing.tsx`](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Billing.tsx) (Billing page), [`src/contexts/AuthContext.tsx`](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/contexts/AuthContext.tsx) (Authentication state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and access"]
  node_app["Routes and app shell<br/>[App.tsx]"]
  node_login["Sign in<br/>[Login.tsx]"]
  node_guard["Protected routes<br/>[ProtectedRoute.tsx]"]
  node_auth["Authentication state<br/>[AuthContext.tsx]"]
  node_layout["Dashboard navigation"]
end

subgraph group_energy["Energy insights"]
  node_dashboard["Dashboard page<br/>[Dashboard.tsx]"]
  node_csv["CSV data processing"]
  node_mockdata["Sample energy and bill data<br/>[mockData.ts]"]
  node_alerts["Smart energy alerts<br/>[AIAlerts.tsx]"]
  node_linechart["Usage line chart"]
  node_barchart["Usage bar chart<br/>[EnergyBarChart.tsx]"]
  node_piechart["Energy mix chart<br/>[EnergyPieChart.tsx]"]
  node_stats["Energy stat cards<br/>[StatCard.tsx]"]
  node_analytics["Analytics page<br/>[Analytics.tsx]"]
end

subgraph group_billing["Billing and reports"]
  node_billing["Billing page<br/>[Billing.tsx]"]
  node_exportui["Report export controls<br/>[ReportExport.tsx]"]
  node_export["Report generation<br/>[reportExport.ts]"]
end

subgraph group_services["Assistant and services"]
  node_supabase["Supabase client<br/>[client.ts]"]
  node_chatui["Energy chat assistant<br/>[EnergyChatbot.tsx]"]
  node_chatfn["Chat edge function<br/>[index.ts]"]
  node_chatserver["Local chat server"]
  node_analyticsfn["Analytics edge function<br/>[index.ts]"]
  node_alertfn["Energy alerts function<br/>[index.ts]"]
end

node_user(("Dashboard user"))
node_external[("Supabase service")]

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_login
node_app -->|"protects routes"| node_guard
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_billing
node_app -->|"renders"| node_chatui
node_app -->|"provides auth"| node_auth
node_guard -->|"checks access"| node_auth
node_auth -->|"uses auth"| node_supabase
node_supabase -.->|"connects to"| node_external
node_dashboard -->|"renders within"| node_layout
node_dashboard -->|"loads data"| node_csv
node_dashboard -->|"renders"| node_alerts
node_dashboard -->|"renders"| node_linechart
node_dashboard -->|"renders"| node_piechart
node_dashboard -->|"renders"| node_stats
node_dashboard -->|"renders"| node_exportui
node_alerts -->|"loads data"| node_csv
node_billing -->|"renders within"| node_layout
node_billing -->|"reads bills"| node_mockdata
node_billing -->|"renders"| node_exportui
node_billing -->|"uses reports"| node_export
node_chatui -.->|"connects to"| node_chatserver

click node_app "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/App.tsx"
click node_login "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Login.tsx"
click node_guard "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/auth/ProtectedRoute.tsx"
click node_auth "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/contexts/AuthContext.tsx"
click node_supabase "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/integrations/supabase/client.ts"
click node_dashboard "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Dashboard.tsx"
click node_layout "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/layout/DashboardLayout.tsx"
click node_csv "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/lib/csvDataProcessor.ts"
click node_mockdata "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/lib/mockData.ts"
click node_alerts "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/AIAlerts.tsx"
click node_linechart "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/EnergyLineChart.tsx"
click node_barchart "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/EnergyBarChart.tsx"
click node_piechart "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/EnergyPieChart.tsx"
click node_stats "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/StatCard.tsx"
click node_analytics "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Analytics.tsx"
click node_billing "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Billing.tsx"
click node_exportui "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/ReportExport.tsx"
click node_export "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/lib/reportExport.ts"
click node_chatui "https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/chat/EnergyChatbot.tsx"
click node_chatfn "https://github.com/deekshhh37/smart-energy-chain/blob/main/supabase/functions/chat/index.ts"
click node_chatserver "https://github.com/deekshhh37/smart-energy-chain/blob/main/mock-chat-server.js"
click node_analyticsfn "https://github.com/deekshhh37/smart-energy-chain/blob/main/supabase/functions/analytics/index.ts"
click node_alertfn "https://github.com/deekshhh37/smart-energy-chain/blob/main/supabase/functions/energy-alerts/index.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_login,node_guard,node_auth,node_layout,node_user toneBlue
class node_dashboard,node_csv,node_mockdata,node_alerts,node_linechart,node_barchart,node_piechart,node_stats,node_analytics,node_external toneAmber
class node_billing,node_exportui,node_export toneMint
class node_supabase,node_chatui,node_chatfn,node_chatserver,node_analyticsfn,node_alertfn toneRose
```

## Components

### Application and access

- [Routes and app shell](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/App.tsx): `src/App.tsx`
- [Sign in](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Login.tsx): `src/pages/Login.tsx`
- [Protected routes](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/auth/ProtectedRoute.tsx): `src/components/auth/ProtectedRoute.tsx`
- [Authentication state](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Dashboard navigation](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/layout/DashboardLayout.tsx): `src/components/layout/DashboardLayout.tsx`

### Energy insights

- [Dashboard page](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [CSV data processing](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/lib/csvDataProcessor.ts): `src/lib/csvDataProcessor.ts`
- [Sample energy and bill data](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/lib/mockData.ts): `src/lib/mockData.ts`
- [Smart energy alerts](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/AIAlerts.tsx): `src/components/dashboard/AIAlerts.tsx`
- [Usage line chart](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/EnergyLineChart.tsx): `src/components/dashboard/EnergyLineChart.tsx`
- [Usage bar chart](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/EnergyBarChart.tsx): `src/components/dashboard/EnergyBarChart.tsx`
- [Energy mix chart](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/EnergyPieChart.tsx): `src/components/dashboard/EnergyPieChart.tsx`
- [Energy stat cards](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/StatCard.tsx): `src/components/dashboard/StatCard.tsx`
- [Analytics page](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Analytics.tsx): `src/pages/Analytics.tsx`

### Billing and reports

- [Billing page](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/pages/Billing.tsx): `src/pages/Billing.tsx`
- [Report export controls](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/dashboard/ReportExport.tsx): `src/components/dashboard/ReportExport.tsx`
- [Report generation](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/lib/reportExport.ts): `src/lib/reportExport.ts`

### Assistant and services

- [Supabase client](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Energy chat assistant](https://github.com/deekshhh37/smart-energy-chain/blob/main/src/components/chat/EnergyChatbot.tsx): `src/components/chat/EnergyChatbot.tsx`
- [Chat edge function](https://github.com/deekshhh37/smart-energy-chain/blob/main/supabase/functions/chat/index.ts): `supabase/functions/chat/index.ts`
- [Local chat server](https://github.com/deekshhh37/smart-energy-chain/blob/main/mock-chat-server.js): `mock-chat-server.js`
- [Analytics edge function](https://github.com/deekshhh37/smart-energy-chain/blob/main/supabase/functions/analytics/index.ts): `supabase/functions/analytics/index.ts`
- [Energy alerts function](https://github.com/deekshhh37/smart-energy-chain/blob/main/supabase/functions/energy-alerts/index.ts): `supabase/functions/energy-alerts/index.ts`

### Other components

- **Dashboard user**
- **Supabase service**

## Connections

- Dashboard user → Routes and app shell: opens (evidence: `src/App.tsx`)
- Routes and app shell → Sign in: routes to (evidence: `src/App.tsx`)
- Routes and app shell → Protected routes: protects routes (evidence: `src/App.tsx`)
- Routes and app shell → Dashboard page: routes to (evidence: `src/App.tsx`)
- Routes and app shell → Analytics page: routes to (evidence: `src/App.tsx`)
- Routes and app shell → Billing page: routes to (evidence: `src/App.tsx`)
- Routes and app shell → Energy chat assistant: renders (evidence: `src/App.tsx`)
- Routes and app shell → Authentication state: provides auth (evidence: `src/App.tsx`)
- Protected routes → Authentication state: checks access (evidence: `src/components/auth/ProtectedRoute.tsx`)
- Authentication state → Supabase client: uses auth (evidence: `src/contexts/AuthContext.tsx`)
- Supabase client → Supabase service: connects to (evidence: `src/integrations/supabase/client.ts`)
- Dashboard page → Dashboard navigation: renders within (evidence: `src/pages/Dashboard.tsx`)
- Dashboard page → CSV data processing: loads data (evidence: `src/pages/Dashboard.tsx`)
- Dashboard page → Smart energy alerts: renders (evidence: `src/pages/Dashboard.tsx`)
- Dashboard page → Usage line chart: renders (evidence: `src/pages/Dashboard.tsx`)
- Dashboard page → Energy mix chart: renders (evidence: `src/pages/Dashboard.tsx`)
- Dashboard page → Energy stat cards: renders (evidence: `src/pages/Dashboard.tsx`)
- Dashboard page → Report export controls: renders (evidence: `src/pages/Dashboard.tsx`)
- Smart energy alerts → CSV data processing: loads data (evidence: `src/components/dashboard/AIAlerts.tsx`)
- Billing page → Dashboard navigation: renders within (evidence: `src/pages/Billing.tsx`)
- Billing page → Sample energy and bill data: reads bills (evidence: `src/pages/Billing.tsx`)
- Billing page → Report export controls: renders (evidence: `src/pages/Billing.tsx`)
- Billing page → Report generation: uses reports (evidence: `src/pages/Billing.tsx`)
- Energy chat assistant → Local chat server: connects to (evidence: `README.md`)
