# p2p-energy-trading-platform/frontend-web architecture

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

- Interactive diagram: https://gitdiagram.com/p2p-energy-trading-platform/frontend-web
- Repository: https://github.com/p2p-energy-trading-platform/frontend-web

## Overview

This is a GridX-style energy and trading web application. Users enter through marketing or account flows, authenticate, then work in a signed-in portal spanning a live energy dashboard, energy assets, trading, wallet, history, notifications, and profile. The sampled code shows dashboard orchestration of IoT queries and energy view-model transformations, plus authentication query/mutation flows and an API client used by IoT endpoints. Other feature branches are represented from the file tree and source index; their internal calls are not inferred where source was not sampled.

Main entry points: [`src/features/auth/hooks.ts`](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/auth/hooks.ts) (Auth operations), [`src/features/iot/hooks.ts`](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/iot/hooks.ts) (IoT queries), [`src/routeTree.gen.ts`](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routeTree.gen.ts) (Route registry), [`src/routes/_authenticated.tsx`](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routes/_authenticated.tsx) (Signed-in shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and identity"]
  node_auth_routes["Auth routes<br/>[route.tsx]"]
  node_auth_ui["Account forms"]
  node_auth_hooks["Auth operations<br/>[hooks.ts]"]
  node_auth_api["Auth API<br/>[api.ts]"]
  node_marketing["Marketing pages<br/>[HomeView.tsx]"]
end

subgraph group_energy["Energy monitoring"]
  node_dashboard["Energy dashboard<br/>[useDashboard.ts]"]
  node_iot_hooks["IoT queries<br/>[hooks.ts]"]
  node_iot_api["IoT endpoints<br/>[api.ts]"]
  node_energy_models["Energy view models<br/>[view-model.ts]"]
  node_energy_assets["Energy assets<br/>[useEnergyAssets.ts]"]
end

subgraph group_commerce["Trading and money"]
  node_trade["Trading terminal"]
  node_trade_data["Trading data<br/>[useTrade.ts]"]
  node_wallet["Wallet<br/>[WalletView.tsx]"]
  node_history["Order and trade history<br/>[OrderHistory.tsx]"]
end

subgraph group_account["Account services"]
  node_notifications["Notifications"]
  node_profile["Profile settings<br/>[ProfileView.tsx]"]
end

subgraph group_platform["Application platform"]
  node_router["Router<br/>[router.tsx]"]
  node_route_tree["Route registry<br/>[routeTree.gen.ts]"]
  node_portal["Signed-in shell<br/>[_authenticated.tsx]"]
  node_api_client["HTTP API client<br/>[client.ts]"]
  node_query_client["Query state<br/>[query-client.ts]"]
end

node_visitor(("Visitor"))
node_gateway{{"API gateway"}}

node_visitor -->|"opens app"| node_router
node_router -->|"registers routes"| node_route_tree
node_route_tree -->|"routes to"| node_auth_routes
node_auth_routes -->|"checks session"| node_auth_hooks
node_auth_ui -->|"submits forms"| node_auth_hooks
node_auth_hooks -->|"calls operations"| node_auth_api
node_route_tree -->|"routes to"| node_portal
node_portal -->|"loads user"| node_auth_hooks
node_portal -->|"subscribes house"| node_iot_hooks
node_dashboard -->|"queries readings"| node_iot_hooks
node_dashboard -->|"transforms readings"| node_energy_models
node_iot_hooks -->|"fetches data"| node_iot_api
node_iot_api -->|"sends requests"| node_api_client
node_energy_assets -->|"uses IoT queries"| node_iot_hooks
node_energy_assets -->|"requests series"| node_iot_api
node_trade -.->|"loads market data"| node_trade_data
node_history -->|"uses history hook"| node_history
node_api_client -.->|"requests API"| node_gateway

click node_router "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/router.tsx"
click node_route_tree "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routeTree.gen.ts"
click node_auth_routes "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routes/_auth/route.tsx"
click node_auth_ui "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/auth/CreateAccountForm.tsx"
click node_auth_hooks "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/auth/hooks.ts"
click node_auth_api "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/auth/api.ts"
click node_portal "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routes/_authenticated.tsx"
click node_dashboard "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/hooks/useDashboard.ts"
click node_iot_hooks "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/iot/hooks.ts"
click node_iot_api "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/iot/api.ts"
click node_energy_models "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/iot/view-model.ts"
click node_energy_assets "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/hooks/useEnergyAssets.ts"
click node_trade "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/trade/TradingTerminalView.tsx"
click node_trade_data "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/hooks/useTrade.ts"
click node_wallet "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/wallet/WalletView.tsx"
click node_history "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/history/OrderHistory.tsx"
click node_notifications "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/notification/NotificationView.tsx"
click node_profile "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/profile/ProfileView.tsx"
click node_marketing "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/landing/HomeView.tsx"
click node_api_client "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/lib/api-client/client.ts"
click node_query_client "https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/lib/query-client.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_auth_routes,node_auth_ui,node_auth_hooks,node_auth_api,node_marketing toneBlue
class node_dashboard,node_iot_hooks,node_iot_api,node_energy_models,node_energy_assets toneAmber
class node_trade,node_trade_data,node_wallet,node_history,node_gateway toneMint
class node_notifications,node_profile toneRose
class node_router,node_route_tree,node_portal,node_api_client,node_query_client,node_visitor toneIndigo
```

## Components

### Entry and identity

- [Auth routes](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routes/_auth/route.tsx): `src/routes/_auth/route.tsx`
- [Account forms](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/auth/CreateAccountForm.tsx): `src/components/auth/CreateAccountForm.tsx`
- [Auth operations](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/auth/hooks.ts): `src/features/auth/hooks.ts`
- [Auth API](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/auth/api.ts): `src/features/auth/api.ts`
- [Marketing pages](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/landing/HomeView.tsx): `src/components/landing/HomeView.tsx`

### Energy monitoring

- [Energy dashboard](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/hooks/useDashboard.ts): `src/hooks/useDashboard.ts`
- [IoT queries](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/iot/hooks.ts): `src/features/iot/hooks.ts`
- [IoT endpoints](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/iot/api.ts): `src/features/iot/api.ts`
- [Energy view models](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/features/iot/view-model.ts): `src/features/iot/view-model.ts`
- [Energy assets](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/hooks/useEnergyAssets.ts): `src/hooks/useEnergyAssets.ts`

### Trading and money

- [Trading terminal](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/trade/TradingTerminalView.tsx): `src/components/trade/TradingTerminalView.tsx`
- [Trading data](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/hooks/useTrade.ts): `src/hooks/useTrade.ts`
- [Wallet](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/wallet/WalletView.tsx): `src/components/wallet/WalletView.tsx`
- [Order and trade history](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/history/OrderHistory.tsx): `src/components/history/OrderHistory.tsx`

### Account services

- [Notifications](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/notification/NotificationView.tsx): `src/components/notification/NotificationView.tsx`
- [Profile settings](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/components/profile/ProfileView.tsx): `src/components/profile/ProfileView.tsx`

### Application platform

- [Router](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/router.tsx): `src/router.tsx`
- [Route registry](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routeTree.gen.ts): `src/routeTree.gen.ts`
- [Signed-in shell](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/routes/_authenticated.tsx): `src/routes/_authenticated.tsx`
- [HTTP API client](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/lib/api-client/client.ts): `src/lib/api-client/client.ts`
- [Query state](https://github.com/p2p-energy-trading-platform/frontend-web/blob/main/src/lib/query-client.ts): `src/lib/query-client.ts`

### Other components

- **Visitor**
- **API gateway**

## Connections

- Visitor → Router: opens app (evidence: `src/router.tsx`)
- Router → Route registry: registers routes (evidence: `src/router.tsx`)
- Route registry → Auth routes: routes to (evidence: `src/routeTree.gen.ts`)
- Auth routes → Auth operations: checks session (evidence: `src/routes/_auth/route.tsx`)
- Account forms → Auth operations: submits forms (evidence: `src/components/auth/CreateAccountForm.tsx`)
- Auth operations → Auth API: calls operations (evidence: `src/features/auth/hooks.ts`)
- Route registry → Signed-in shell: routes to (evidence: `src/routeTree.gen.ts`)
- Signed-in shell → Auth operations: loads user (evidence: `src/routes/_authenticated.tsx`)
- Signed-in shell → IoT queries: subscribes house (evidence: `src/routes/_authenticated.tsx`)
- Energy dashboard → IoT queries: queries readings (evidence: `src/hooks/useDashboard.ts`)
- Energy dashboard → Energy view models: transforms readings (evidence: `src/hooks/useDashboard.ts`)
- IoT queries → IoT endpoints: fetches data (evidence: `src/features/iot/hooks.ts`)
- IoT endpoints → HTTP API client: sends requests (evidence: `src/features/iot/api.ts`)
- Energy assets → IoT queries: uses IoT queries (evidence: `src/hooks/useEnergyAssets.ts`)
- Energy assets → IoT endpoints: requests series (evidence: `src/hooks/useEnergyAssets.ts`)
- Trading terminal → Trading data: loads market data
- Order and trade history → Order and trade history: uses history hook (evidence: `src/components/history/OrderHistory.tsx`)
- HTTP API client → API gateway: requests API
