# narapat/aeternum-ally architecture

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

- Interactive diagram: https://gitdiagram.com/narapat/aeternum-ally
- Repository: https://github.com/narapat/aeternum-ally
- Video tour (about a minute): https://gitdiagram.com/narapat/aeternum-ally/video

## Overview

Aeternum Ally is a multi-tenant sustainability management and ESRS/CSRD reporting platform. The main workflow starts with company setup and business-model context, proceeds through SWOT and double materiality assessment, then turns findings into prioritized actions, KPI tracking, carbon management, and a sustainability statement. The graph also includes the documented AI-assistance and evidence capabilities. Source excerpts show some client/data-service behavior, but not all screen-to-function wiring, so uncertain links are omitted.

Main entry points: [`App.tsx`](https://github.com/narapat/aeternum-ally/blob/main/App.tsx) (Tenant application), [`services/dbService.ts`](https://github.com/narapat/aeternum-ally/blob/main/services/dbService.ts) (Data service), [`lib/supabaseClient.ts`](https://github.com/narapat/aeternum-ally/blob/main/lib/supabaseClient.ts) (Supabase), [`services/evidenceService.ts`](https://github.com/narapat/aeternum-ally/blob/main/services/evidenceService.ts) (Evidence attachments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Assessment workflow"]
  node_profile["Company profile"]
  node_canvas["Business model canvas"]
  node_swot["SWOT analysis"]
  node_assessment["Materiality assessment<br/>[AssessmentForm.tsx]"]
  node_insights["DMA insight hub<br/>[DMAInsightHub.tsx]"]
  node_matrix["Materiality matrix"]
end

subgraph group_action["Action and reporting"]
  node_tasks["Task management<br/>[TaskManagement.tsx]"]
  node_performance["KPI dashboard"]
  node_carbon["Carbon management<br/>[CarbonWizard.tsx]"]
  node_carbon_dashboard["Carbon dashboard"]
  node_statement["Sustainability statement"]
  node_evidence["Evidence attachments<br/>[evidenceService.ts]"]
end

subgraph group_platform["Application platform"]
  node_app["Tenant application<br/>[App.tsx]"]
  node_auth["Authentication<br/>[useAuth.ts]"]
  node_organization["Organization setup<br/>[useOrganization.ts]"]
  node_org_data["Organization data hook<br/>[useOrgData.ts]"]
end

subgraph group_services["Backend services"]
  node_db_service["Data service<br/>[dbService.ts]"]
  node_emissions["Emission services"]
  node_api["AI request API<br/>[api.ts]"]
  node_assessment_job["Assessment generation"]
  node_dma_job["DMA analysis<br/>[dma-background.ts]"]
  node_report_job["Report generation"]
  node_context["Company context<br/>[companyContext.js]"]
  node_supabase[("Supabase<br/>[supabaseClient.ts]")]
end

subgraph group_admin["Platform administration"]
  node_admin_app["Admin portal<br/>[AdminApp.tsx]"]
  node_admin_api["Admin functions<br/>[admin.ts]"]
end

node_user(("SME user"))
node_gemini["Google Gemini"]

node_user -->|"uses"| node_app
node_app -->|"authenticates"| node_auth
node_app -->|"loads org"| node_organization
node_app -->|"opens"| node_profile
node_app -->|"opens"| node_canvas
node_app -->|"opens"| node_swot
node_app -->|"opens"| node_assessment
node_app -->|"opens"| node_insights
node_app -->|"shows"| node_matrix
node_app -->|"opens"| node_tasks
node_app -->|"opens"| node_performance
node_app -->|"opens"| node_carbon
node_app -->|"opens"| node_carbon_dashboard
node_app -->|"opens"| node_statement
node_organization -->|"fetches membership"| node_db_service
node_org_data -->|"loads and saves"| node_db_service
node_db_service -->|"reads and writes"| node_supabase
node_emissions -->|"reads and writes"| node_supabase
node_evidence -->|"stores links"| node_supabase
node_evidence -.->|"uploads via"| node_user
node_user -->|"attaches"| node_evidence
node_assessment -->|"requests drafting"| node_assessment_job
node_insights -->|"requests analysis"| node_dma_job
node_statement -->|"requests generation"| node_report_job
node_assessment_job -->|"builds grounding"| node_context
node_dma_job -->|"builds grounding"| node_context
node_report_job -->|"builds grounding"| node_context
node_context -->|"reads profile data"| node_supabase
node_assessment_job -->|"generates with"| node_gemini
node_dma_job -->|"analyzes with"| node_gemini
node_report_job -->|"generates with"| node_gemini
node_app -->|"requests AI"| node_api
node_api -->|"calls"| node_gemini
node_admin_app -->|"manages platform"| node_admin_api
node_admin_api -->|"reads and writes"| node_supabase
node_carbon -->|"manages emissions"| node_emissions
node_carbon_dashboard -->|"summarizes emissions"| node_emissions
node_assessment -->|"links evidence"| node_evidence
node_tasks -->|"loads and saves"| node_db_service
node_performance -->|"loads and saves"| node_db_service

click node_app "https://github.com/narapat/aeternum-ally/blob/main/App.tsx"
click node_auth "https://github.com/narapat/aeternum-ally/blob/main/hooks/useAuth.ts"
click node_organization "https://github.com/narapat/aeternum-ally/blob/main/hooks/useOrganization.ts"
click node_profile "https://github.com/narapat/aeternum-ally/blob/main/components/CompanyProfileForm.tsx"
click node_canvas "https://github.com/narapat/aeternum-ally/blob/main/components/BusinessModelCanvas.tsx"
click node_swot "https://github.com/narapat/aeternum-ally/blob/main/components/SwotAnalysisWizard.tsx"
click node_assessment "https://github.com/narapat/aeternum-ally/blob/main/components/AssessmentForm.tsx"
click node_insights "https://github.com/narapat/aeternum-ally/blob/main/components/DMAInsightHub.tsx"
click node_matrix "https://github.com/narapat/aeternum-ally/blob/main/components/MaterialityMatrix.tsx"
click node_tasks "https://github.com/narapat/aeternum-ally/blob/main/components/TaskManagement.tsx"
click node_performance "https://github.com/narapat/aeternum-ally/blob/main/components/PerformanceDashboard.tsx"
click node_carbon "https://github.com/narapat/aeternum-ally/blob/main/components/CarbonWizard.tsx"
click node_carbon_dashboard "https://github.com/narapat/aeternum-ally/blob/main/components/CarbonDashboard.tsx"
click node_statement "https://github.com/narapat/aeternum-ally/blob/main/components/SustainabilityStatement.tsx"
click node_evidence "https://github.com/narapat/aeternum-ally/blob/main/services/evidenceService.ts"
click node_org_data "https://github.com/narapat/aeternum-ally/blob/main/hooks/useOrgData.ts"
click node_db_service "https://github.com/narapat/aeternum-ally/blob/main/services/dbService.ts"
click node_emissions "https://github.com/narapat/aeternum-ally/blob/main/services/emissionFactorService.ts"
click node_api "https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/api.ts"
click node_assessment_job "https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/assessment-background.ts"
click node_dma_job "https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/dma-background.ts"
click node_report_job "https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/report-background.ts"
click node_context "https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/_shared/companyContext.js"
click node_supabase "https://github.com/narapat/aeternum-ally/blob/main/lib/supabaseClient.ts"
click node_admin_app "https://github.com/narapat/aeternum-ally/blob/main/AdminApp.tsx"
click node_admin_api "https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/admin.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_profile,node_canvas,node_swot,node_assessment,node_insights,node_matrix,node_user toneBlue
class node_tasks,node_performance,node_carbon,node_carbon_dashboard,node_statement,node_evidence toneAmber
class node_app,node_auth,node_organization,node_org_data toneMint
class node_db_service,node_emissions,node_api,node_assessment_job,node_dma_job,node_report_job,node_context,node_supabase toneRose
class node_admin_app,node_admin_api,node_gemini toneIndigo
```

## Components

### Assessment workflow

- [Company profile](https://github.com/narapat/aeternum-ally/blob/main/components/CompanyProfileForm.tsx): `components/CompanyProfileForm.tsx`
- [Business model canvas](https://github.com/narapat/aeternum-ally/blob/main/components/BusinessModelCanvas.tsx): `components/BusinessModelCanvas.tsx`
- [SWOT analysis](https://github.com/narapat/aeternum-ally/blob/main/components/SwotAnalysisWizard.tsx): `components/SwotAnalysisWizard.tsx`
- [Materiality assessment](https://github.com/narapat/aeternum-ally/blob/main/components/AssessmentForm.tsx): `components/AssessmentForm.tsx`
- [DMA insight hub](https://github.com/narapat/aeternum-ally/blob/main/components/DMAInsightHub.tsx): `components/DMAInsightHub.tsx`
- [Materiality matrix](https://github.com/narapat/aeternum-ally/blob/main/components/MaterialityMatrix.tsx): `components/MaterialityMatrix.tsx`

### Action and reporting

- [Task management](https://github.com/narapat/aeternum-ally/blob/main/components/TaskManagement.tsx): `components/TaskManagement.tsx`
- [KPI dashboard](https://github.com/narapat/aeternum-ally/blob/main/components/PerformanceDashboard.tsx): `components/PerformanceDashboard.tsx`
- [Carbon management](https://github.com/narapat/aeternum-ally/blob/main/components/CarbonWizard.tsx): `components/CarbonWizard.tsx`
- [Carbon dashboard](https://github.com/narapat/aeternum-ally/blob/main/components/CarbonDashboard.tsx): `components/CarbonDashboard.tsx`
- [Sustainability statement](https://github.com/narapat/aeternum-ally/blob/main/components/SustainabilityStatement.tsx): `components/SustainabilityStatement.tsx`
- [Evidence attachments](https://github.com/narapat/aeternum-ally/blob/main/services/evidenceService.ts): `services/evidenceService.ts`

### Application platform

- [Tenant application](https://github.com/narapat/aeternum-ally/blob/main/App.tsx): `App.tsx`
- [Authentication](https://github.com/narapat/aeternum-ally/blob/main/hooks/useAuth.ts): `hooks/useAuth.ts`
- [Organization setup](https://github.com/narapat/aeternum-ally/blob/main/hooks/useOrganization.ts): `hooks/useOrganization.ts`
- [Organization data hook](https://github.com/narapat/aeternum-ally/blob/main/hooks/useOrgData.ts): `hooks/useOrgData.ts`

### Backend services

- [Data service](https://github.com/narapat/aeternum-ally/blob/main/services/dbService.ts): `services/dbService.ts`
- [Emission services](https://github.com/narapat/aeternum-ally/blob/main/services/emissionFactorService.ts): `services/emissionFactorService.ts`
- [AI request API](https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/api.ts): `netlify/functions/api.ts`
- [Assessment generation](https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/assessment-background.ts): `netlify/functions/assessment-background.ts`
- [DMA analysis](https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/dma-background.ts): `netlify/functions/dma-background.ts`
- [Report generation](https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/report-background.ts): `netlify/functions/report-background.ts`
- [Company context](https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/_shared/companyContext.js): `netlify/functions/_shared/companyContext.js`
- [Supabase](https://github.com/narapat/aeternum-ally/blob/main/lib/supabaseClient.ts): `lib/supabaseClient.ts`

### Platform administration

- [Admin portal](https://github.com/narapat/aeternum-ally/blob/main/AdminApp.tsx): `AdminApp.tsx`
- [Admin functions](https://github.com/narapat/aeternum-ally/blob/main/netlify/functions/admin.ts): `netlify/functions/admin.ts`

### Other components

- **SME user**
- **Google Gemini**

## Connections

- SME user → Tenant application: uses
- Tenant application → Authentication: authenticates
- Tenant application → Organization setup: loads org
- Tenant application → Company profile: opens
- Tenant application → Business model canvas: opens
- Tenant application → SWOT analysis: opens
- Tenant application → Materiality assessment: opens
- Tenant application → DMA insight hub: opens
- Tenant application → Materiality matrix: shows
- Tenant application → Task management: opens
- Tenant application → KPI dashboard: opens
- Tenant application → Carbon management: opens
- Tenant application → Carbon dashboard: opens
- Tenant application → Sustainability statement: opens
- Organization setup → Data service: fetches membership
- Organization data hook → Data service: loads and saves
- Data service → Supabase: reads and writes
- Emission services → Supabase: reads and writes
- Evidence attachments → Supabase: stores links
- Evidence attachments → SME user: uploads via
- SME user → Evidence attachments: attaches
- Materiality assessment → Assessment generation: requests drafting
- DMA insight hub → DMA analysis: requests analysis
- Sustainability statement → Report generation: requests generation
- Assessment generation → Company context: builds grounding
- DMA analysis → Company context: builds grounding
- Report generation → Company context: builds grounding
- Company context → Supabase: reads profile data
- Assessment generation → Google Gemini: generates with
- DMA analysis → Google Gemini: analyzes with
- Report generation → Google Gemini: generates with
- Tenant application → AI request API: requests AI
- AI request API → Google Gemini: calls
- Admin portal → Admin functions: manages platform
- Admin functions → Supabase: reads and writes
- Carbon management → Emission services: manages emissions
- Carbon dashboard → Emission services: summarizes emissions
- Materiality assessment → Evidence attachments: links evidence
- Task management → Data service: loads and saves
- KPI dashboard → Data service: loads and saves
