# hari-preetham-b/ecosphere architecture

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

- Interactive diagram: https://gitdiagram.com/hari-preetham-b/ecosphere
- Repository: https://github.com/hari-preetham-b/ecosphere

## Overview

EcoSphere is a role-based enterprise ESG platform. Users authenticate, configure organizational data, record environmental and social activity, manage governance work, and participate in gamification; backend APIs persist those operations and provide scoring, reports, and notifications. The README documents the major product modules, while sampled route and service code confirms selected backend responsibilities. Many page implementations and route modules were not sampled, so some product capabilities are represented at subsystem level and unverified connections are omitted.

Main entry points: [`backend/app.py`](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/app.py) (Flask API), [`backend/routes/carbon_transaction_routes.py`](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/carbon_transaction_routes.py) (Environmental tracking), [`backend/routes/scoring_routes.py`](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/scoring_routes.py) (Scoring and reports), [`backend/routes/governance_routes.py`](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/governance_routes.py) (Governance work)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["Web app<br/>[App.jsx]"]
  node_authui["Auth context<br/>[AuthContext.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_identity["Identity and setup"]
  node_master["Master data"]
  node_auth["Auth and roles<br/>[auth.py]"]
end

subgraph group_operations["ESG operations"]
  node_environment["Environmental tracking"]
  node_emission["Emission factors"]
  node_erp["ERP records<br/>[erp_routes.py]"]
  node_goals["Sustainability goals"]
  node_social["CSR participation<br/>[csr_routes.py]"]
  node_diversity["Diversity metrics"]
  node_training["Training tracking<br/>[training_routes.py]"]
  node_governance["Governance work"]
end

subgraph group_insight["Scoring and engagement"]
  node_gamification["Gamification"]
  node_scoring["Scoring and reports<br/>[scoring_routes.py]"]
  node_notifications["Notifications"]
  node_settings["ESG settings<br/>[settings_routes.py]"]
end

subgraph group_platform["Backend platform"]
  node_server["Flask API<br/>[app.py]"]
  node_database[("SQL database<br/>[database.py]")]
  node_models["Domain models<br/>[models.py]"]
end

node_employee(("User"))
node_supabase(("Supabase Auth"))
node_smtp(("Brevo SMTP"))

node_employee -->|"uses"| node_app
node_app -->|"provides auth"| node_authui
node_authui -->|"authenticates"| node_supabase
node_authui -->|"fetches profile"| node_api
node_app -->|"routes to"| node_environment
node_employee -.->|"records activity"| node_environment
node_environment -.->|"converts activity"| node_emission
node_erp -.->|"auto-calculates"| node_environment
node_employee -.->|"participates"| node_social
node_employee -.->|"acknowledges policies"| node_governance
node_social -->|"awards points"| node_gamification
node_gamification -->|"sends updates"| node_notifications
node_governance -->|"sends updates"| node_notifications
node_employee -.->|"views results"| node_scoring
node_environment -.->|"contributes data"| node_scoring
node_social -.->|"contributes data"| node_scoring
node_governance -.->|"contributes data"| node_scoring
node_scoring -.->|"reports results"| node_employee
node_employee -.->|"requests data"| node_api
node_api -.->|"calls API"| node_server
node_server -->|"registers routes"| node_master
node_server -->|"registers routes"| node_environment
node_server -->|"registers routes"| node_social
node_server -->|"registers routes"| node_governance
node_server -->|"registers routes"| node_gamification
node_server -->|"registers routes"| node_scoring
node_auth -->|"verifies token"| node_supabase
node_auth -->|"syncs profile"| node_models
node_environment -->|"persists records"| node_database
node_governance -->|"persists records"| node_database
node_gamification -->|"persists records"| node_database
node_scoring -->|"queries data"| node_database
node_notifications -->|"stores notices"| node_database
node_notifications -->|"sends email"| node_smtp
node_employee -.->|"views metrics"| node_diversity
node_employee -.->|"tracks completion"| node_training
node_employee -.->|"tracks progress"| node_goals
node_employee -.->|"configures ESG"| node_settings

click node_app "https://github.com/hari-preetham-b/ecosphere/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/hari-preetham-b/ecosphere/blob/main/frontend/src/context/AuthContext.jsx"
click node_api "https://github.com/hari-preetham-b/ecosphere/blob/main/frontend/src/lib/api.js"
click node_master "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/department_routes.py"
click node_auth "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/auth.py"
click node_environment "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/carbon_transaction_routes.py"
click node_emission "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/emission_factor_routes.py"
click node_erp "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/erp_routes.py"
click node_goals "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/sustainability_goal_routes.py"
click node_social "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/csr_routes.py"
click node_diversity "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/diversity_routes.py"
click node_training "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/training_routes.py"
click node_governance "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/governance_routes.py"
click node_gamification "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/gamification_routes.py"
click node_scoring "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/scoring_routes.py"
click node_notifications "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/services/notification_service.py"
click node_settings "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/settings_routes.py"
click node_server "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/app.py"
click node_database "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/database.py"
click node_models "https://github.com/hari-preetham-b/ecosphere/blob/main/backend/models.py"

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_authui,node_api,node_employee toneBlue
class node_master,node_auth toneAmber
class node_environment,node_emission,node_erp,node_goals,node_social,node_diversity,node_training,node_governance toneMint
class node_gamification,node_scoring,node_notifications,node_settings toneRose
class node_server,node_database,node_models,node_supabase,node_smtp toneIndigo
```

## Components

### Web experience

- [Web app](https://github.com/hari-preetham-b/ecosphere/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/hari-preetham-b/ecosphere/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/hari-preetham-b/ecosphere/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### Identity and setup

- [Master data](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/department_routes.py): `backend/routes/department_routes.py`
- [Auth and roles](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/auth.py): `backend/auth.py`

### ESG operations

- [Environmental tracking](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/carbon_transaction_routes.py): `backend/routes/carbon_transaction_routes.py`
- [Emission factors](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/emission_factor_routes.py): `backend/routes/emission_factor_routes.py`
- [ERP records](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/erp_routes.py): `backend/routes/erp_routes.py`
- [Sustainability goals](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/sustainability_goal_routes.py): `backend/routes/sustainability_goal_routes.py`
- [CSR participation](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/csr_routes.py): `backend/routes/csr_routes.py`
- [Diversity metrics](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/diversity_routes.py): `backend/routes/diversity_routes.py`
- [Training tracking](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/training_routes.py): `backend/routes/training_routes.py`
- [Governance work](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/governance_routes.py): `backend/routes/governance_routes.py`

### Scoring and engagement

- [Gamification](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/gamification_routes.py): `backend/routes/gamification_routes.py`
- [Scoring and reports](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/scoring_routes.py): `backend/routes/scoring_routes.py`
- [Notifications](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/services/notification_service.py): `backend/services/notification_service.py`
- [ESG settings](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/routes/settings_routes.py): `backend/routes/settings_routes.py`

### Backend platform

- [Flask API](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/app.py): `backend/app.py`
- [SQL database](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/database.py): `backend/database.py`
- [Domain models](https://github.com/hari-preetham-b/ecosphere/blob/main/backend/models.py): `backend/models.py`

### Other components

- **User**
- **Supabase Auth**
- **Brevo SMTP**

## Connections

- User → Web app: uses (evidence: `frontend/src/App.jsx`)
- Web app → Auth context: provides auth (evidence: `frontend/src/App.jsx`)
- Auth context → Supabase Auth: authenticates (evidence: `frontend/src/context/AuthContext.jsx`)
- Auth context → API client: fetches profile (evidence: `frontend/src/context/AuthContext.jsx`)
- Web app → Environmental tracking: routes to (evidence: `frontend/src/App.jsx`)
- User → Environmental tracking: records activity (evidence: `README.md`)
- Environmental tracking → Emission factors: converts activity (evidence: `README.md`)
- ERP records → Environmental tracking: auto-calculates (evidence: `README.md`)
- User → CSR participation: participates (evidence: `README.md`)
- User → Governance work: acknowledges policies (evidence: `README.md`)
- CSR participation → Gamification: awards points (evidence: `backend/routes/csr_routes.py`)
- Gamification → Notifications: sends updates (evidence: `backend/routes/gamification_routes.py`)
- Governance work → Notifications: sends updates (evidence: `backend/routes/governance_routes.py`)
- User → Scoring and reports: views results (evidence: `README.md`)
- Environmental tracking → Scoring and reports: contributes data (evidence: `README.md`)
- CSR participation → Scoring and reports: contributes data (evidence: `README.md`)
- Governance work → Scoring and reports: contributes data (evidence: `README.md`)
- Scoring and reports → User: reports results (evidence: `README.md`)
- User → API client: requests data
- API client → Flask API: calls API
- Flask API → Master data: registers routes (evidence: `backend/app.py`)
- Flask API → Environmental tracking: registers routes (evidence: `backend/app.py`)
- Flask API → CSR participation: registers routes (evidence: `backend/app.py`)
- Flask API → Governance work: registers routes (evidence: `backend/app.py`)
- Flask API → Gamification: registers routes (evidence: `backend/app.py`)
- Flask API → Scoring and reports: registers routes (evidence: `backend/app.py`)
- Auth and roles → Supabase Auth: verifies token (evidence: `backend/auth.py`)
- Auth and roles → Domain models: syncs profile (evidence: `backend/auth.py`)
- Environmental tracking → SQL database: persists records (evidence: `backend/routes/carbon_transaction_routes.py`)
- Governance work → SQL database: persists records (evidence: `backend/routes/governance_routes.py`)
- Gamification → SQL database: persists records (evidence: `backend/routes/gamification_routes.py`)
- Scoring and reports → SQL database: queries data (evidence: `backend/routes/scoring_routes.py`)
- Notifications → SQL database: stores notices (evidence: `backend/services/notification_service.py`)
- Notifications → Brevo SMTP: sends email (evidence: `backend/services/notification_service.py`)
- User → Diversity metrics: views metrics (evidence: `README.md`)
- User → Training tracking: tracks completion (evidence: `README.md`)
- User → Sustainability goals: tracks progress (evidence: `README.md`)
- User → ESG settings: configures ESG (evidence: `README.md`)
