# rayen-segni/enerx architecture

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

- Interactive diagram: https://gitdiagram.com/rayen-segni/enerx
- Repository: https://github.com/rayen-segni/enerx

## Overview

EnerX is a solar-project crowdfunding MVP with a dashboard for identity verification, project creation, primary investment, token resale, production submissions, and AI forecasts. The README describes the end-to-end flows and simulated-money and Hedera boundaries; sampled files confirm selected dashboard, identity, forecast, and Hedera implementations. Several route and service files were not sampled, so those subsystem links rely on README statements rather than inspected call sites.

Main entry points: [`frontend/lib/enerx/api.ts`](https://github.com/rayen-segni/enerx/blob/main/frontend/lib/enerx/api.ts) (Frontend API clients), [`backend/app/database.py`](https://github.com/rayen-segni/enerx/blob/main/backend/app/database.py) (PostgreSQL data), [`frontend/components/enerx/dashboard.tsx`](https://github.com/rayen-segni/enerx/blob/main/frontend/components/enerx/dashboard.tsx) (Dashboard state), [`backend/app/routes/production.py`](https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/production.py) (Production distributions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["User portal"]
  node_dashboard["Dashboard state<br/>[dashboard.tsx]"]
  node_investment_ui["Investment views"]
  node_owner_ui["Owner tools"]
  node_ai_ui["AI forecast view"]
  node_api_client["Frontend API clients<br/>[api.ts]"]
end

subgraph group_backend["Application backend"]
  node_auth["Identity verification<br/>[auth.py]"]
  node_projects["Project creation<br/>[project.py]"]
  node_investments["Primary investment<br/>[investments.py]"]
  node_marketplace["Token marketplace<br/>[marketplace.py]"]
  node_production["Production distributions<br/>[production.py]"]
  node_business_services["Business services"]
  node_database[("PostgreSQL data<br/>[database.py]")]
end

subgraph group_hedera["Hedera integrations"]
  node_hedera_client["Hedera client<br/>[client.py]"]
  node_did["DID registration<br/>[did_service.py]"]
  node_tokens["Token service<br/>[token_service.py]"]
  node_commitment["Project commitment<br/>[file_service.py]"]
  node_distribution_contract["Distribution contract"]
end

subgraph group_ai["Forecast and news"]
  node_forecast_api["Model API<br/>[api.py]"]
  node_forecast_model["Solar forecast<br/>[forecast.py]"]
  node_aggregation["Forecast aggregation<br/>[aggregator.py]"]
  node_news_feed["Energy news<br/>[news_feed.py]"]
end

node_person(("User"))
node_weather["Weather provider"]

node_person -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_investment_ui
node_dashboard -->|"renders"| node_owner_ui
node_dashboard -->|"renders"| node_ai_ui
node_dashboard -->|"calls"| node_api_client
node_api_client -->|"HTTP requests"| node_auth
node_api_client -->|"HTTP requests"| node_projects
node_api_client -->|"HTTP requests"| node_investments
node_api_client -->|"HTTP requests"| node_marketplace
node_api_client -->|"HTTP requests"| node_production
node_auth -->|"reads and writes"| node_database
node_auth -->|"registers DID"| node_did
node_projects -->|"creates token"| node_tokens
node_projects -->|"publishes commitment"| node_commitment
node_projects -->|"stores metadata"| node_database
node_investments -->|"transfers tokens"| node_tokens
node_investments -->|"records purchase"| node_database
node_marketplace -->|"transfers tokens"| node_tokens
node_marketplace -->|"updates balances"| node_database
node_production -->|"allocates revenue"| node_business_services
node_production -->|"reads holdings"| node_database
node_production -->|"records snapshot"| node_distribution_contract
node_production -->|"records payouts"| node_database
node_hedera_client -->|"configures client"| node_tokens
node_hedera_client -->|"provides client"| node_did
node_hedera_client -->|"provides client"| node_commitment
node_hedera_client -->|"provides client"| node_distribution_contract
node_ai_ui -->|"requests forecasts"| node_forecast_api
node_ai_ui -->|"requests news"| node_news_feed
node_forecast_api -->|"runs forecast"| node_forecast_model
node_forecast_api -->|"aggregates results"| node_aggregation
node_forecast_api -->|"loads news"| node_news_feed
node_forecast_model -->|"fetches weather"| node_weather
node_aggregation -->|"uses predictions"| node_forecast_model

click node_dashboard "https://github.com/rayen-segni/enerx/blob/main/frontend/components/enerx/dashboard.tsx"
click node_investment_ui "https://github.com/rayen-segni/enerx/tree/main/frontend/components/enerx/invest"
click node_owner_ui "https://github.com/rayen-segni/enerx/tree/main/frontend/components/enerx/owner"
click node_ai_ui "https://github.com/rayen-segni/enerx/blob/main/frontend/components/enerx/ai/ai-predictor-tab.tsx"
click node_api_client "https://github.com/rayen-segni/enerx/blob/main/frontend/lib/enerx/api.ts"
click node_auth "https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/auth.py"
click node_projects "https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/project.py"
click node_investments "https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/investments.py"
click node_marketplace "https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/marketplace.py"
click node_production "https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/production.py"
click node_business_services "https://github.com/rayen-segni/enerx/tree/main/backend/app/services"
click node_database "https://github.com/rayen-segni/enerx/blob/main/backend/app/database.py"
click node_hedera_client "https://github.com/rayen-segni/enerx/blob/main/backend/hedera/client.py"
click node_did "https://github.com/rayen-segni/enerx/blob/main/backend/hedera/did_service.py"
click node_tokens "https://github.com/rayen-segni/enerx/blob/main/backend/hedera/token_service.py"
click node_commitment "https://github.com/rayen-segni/enerx/blob/main/backend/hedera/file_service.py"
click node_distribution_contract "https://github.com/rayen-segni/enerx/blob/main/backend/hedera/contract_service.py"
click node_forecast_api "https://github.com/rayen-segni/enerx/blob/main/backend/model/api.py"
click node_forecast_model "https://github.com/rayen-segni/enerx/blob/main/backend/model/production/forecast.py"
click node_aggregation "https://github.com/rayen-segni/enerx/blob/main/backend/model/production/aggregator.py"
click node_news_feed "https://github.com/rayen-segni/enerx/blob/main/backend/model/news/news_feed.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_dashboard,node_investment_ui,node_owner_ui,node_ai_ui,node_api_client,node_person toneBlue
class node_auth,node_projects,node_investments,node_marketplace,node_production,node_business_services,node_database toneAmber
class node_hedera_client,node_did,node_tokens,node_commitment,node_distribution_contract toneMint
class node_forecast_api,node_forecast_model,node_aggregation,node_news_feed toneRose
class node_weather toneIndigo
```

## Components

### User portal

- [Dashboard state](https://github.com/rayen-segni/enerx/blob/main/frontend/components/enerx/dashboard.tsx): `frontend/components/enerx/dashboard.tsx`
- [Investment views](https://github.com/rayen-segni/enerx/tree/main/frontend/components/enerx/invest): `frontend/components/enerx/invest`
- [Owner tools](https://github.com/rayen-segni/enerx/tree/main/frontend/components/enerx/owner): `frontend/components/enerx/owner`
- [AI forecast view](https://github.com/rayen-segni/enerx/blob/main/frontend/components/enerx/ai/ai-predictor-tab.tsx): `frontend/components/enerx/ai/ai-predictor-tab.tsx`
- [Frontend API clients](https://github.com/rayen-segni/enerx/blob/main/frontend/lib/enerx/api.ts): `frontend/lib/enerx/api.ts`

### Application backend

- [Identity verification](https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Project creation](https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/project.py): `backend/app/routes/project.py`
- [Primary investment](https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/investments.py): `backend/app/routes/investments.py`
- [Token marketplace](https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/marketplace.py): `backend/app/routes/marketplace.py`
- [Production distributions](https://github.com/rayen-segni/enerx/blob/main/backend/app/routes/production.py): `backend/app/routes/production.py`
- [Business services](https://github.com/rayen-segni/enerx/tree/main/backend/app/services): `backend/app/services`
- [PostgreSQL data](https://github.com/rayen-segni/enerx/blob/main/backend/app/database.py): `backend/app/database.py`

### Hedera integrations

- [Hedera client](https://github.com/rayen-segni/enerx/blob/main/backend/hedera/client.py): `backend/hedera/client.py`
- [DID registration](https://github.com/rayen-segni/enerx/blob/main/backend/hedera/did_service.py): `backend/hedera/did_service.py`
- [Token service](https://github.com/rayen-segni/enerx/blob/main/backend/hedera/token_service.py): `backend/hedera/token_service.py`
- [Project commitment](https://github.com/rayen-segni/enerx/blob/main/backend/hedera/file_service.py): `backend/hedera/file_service.py`
- [Distribution contract](https://github.com/rayen-segni/enerx/blob/main/backend/hedera/contract_service.py): `backend/hedera/contract_service.py`

### Forecast and news

- [Model API](https://github.com/rayen-segni/enerx/blob/main/backend/model/api.py): `backend/model/api.py`
- [Solar forecast](https://github.com/rayen-segni/enerx/blob/main/backend/model/production/forecast.py): `backend/model/production/forecast.py`
- [Forecast aggregation](https://github.com/rayen-segni/enerx/blob/main/backend/model/production/aggregator.py): `backend/model/production/aggregator.py`
- [Energy news](https://github.com/rayen-segni/enerx/blob/main/backend/model/news/news_feed.py): `backend/model/news/news_feed.py`

### Other components

- **User**
- **Weather provider**

## Connections

- User → Dashboard state: uses (evidence: `README.md`)
- Dashboard state → Investment views: renders (evidence: `frontend/components/enerx/dashboard.tsx`)
- Dashboard state → Owner tools: renders (evidence: `frontend/components/enerx/dashboard.tsx`)
- Dashboard state → AI forecast view: renders (evidence: `frontend/components/enerx/dashboard.tsx`)
- Dashboard state → Frontend API clients: calls (evidence: `frontend/components/enerx/dashboard.tsx`)
- Frontend API clients → Identity verification: HTTP requests (evidence: `README.md`)
- Frontend API clients → Project creation: HTTP requests (evidence: `README.md`)
- Frontend API clients → Primary investment: HTTP requests (evidence: `README.md`)
- Frontend API clients → Token marketplace: HTTP requests (evidence: `README.md`)
- Frontend API clients → Production distributions: HTTP requests (evidence: `README.md`)
- Identity verification → PostgreSQL data: reads and writes (evidence: `backend/app/routes/auth.py`)
- Identity verification → DID registration: registers DID (evidence: `backend/app/routes/auth.py`)
- Project creation → Token service: creates token (evidence: `README.md`)
- Project creation → Project commitment: publishes commitment (evidence: `README.md`)
- Project creation → PostgreSQL data: stores metadata (evidence: `README.md`)
- Primary investment → Token service: transfers tokens (evidence: `README.md`)
- Primary investment → PostgreSQL data: records purchase (evidence: `README.md`)
- Token marketplace → Token service: transfers tokens (evidence: `README.md`)
- Token marketplace → PostgreSQL data: updates balances (evidence: `README.md`)
- Production distributions → Business services: allocates revenue (evidence: `backend/app/services/production_service.py`)
- Production distributions → PostgreSQL data: reads holdings (evidence: `README.md`)
- Production distributions → Distribution contract: records snapshot (evidence: `README.md`)
- Production distributions → PostgreSQL data: records payouts (evidence: `README.md`)
- Hedera client → Token service: configures client (evidence: `backend/hedera/token_service.py`)
- Hedera client → DID registration: provides client (evidence: `backend/hedera/did_service.py`)
- Hedera client → Project commitment: provides client (evidence: `backend/hedera/file_service.py`)
- Hedera client → Distribution contract: provides client (evidence: `backend/hedera/contract_service.py`)
- AI forecast view → Model API: requests forecasts (evidence: `README.md`)
- AI forecast view → Energy news: requests news (evidence: `README.md`)
- Model API → Solar forecast: runs forecast (evidence: `backend/model/api.py`)
- Model API → Forecast aggregation: aggregates results (evidence: `backend/model/api.py`)
- Model API → Energy news: loads news (evidence: `backend/model/api.py`)
- Solar forecast → Weather provider: fetches weather (evidence: `backend/model/production/forecast.py`)
- Forecast aggregation → Solar forecast: uses predictions (evidence: `backend/model/production/aggregator.py`)
