# emirhannavdar/ges_battery architecture

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

- Interactive diagram: https://gitdiagram.com/emirhannavdar/ges_battery
- Repository: https://github.com/emirhannavdar/ges_battery

## Overview

GES Battery is a PV-plant simulation and operations application: operators use a Next.js dashboard to authenticate, fetch weather and market inputs, run or manage simulations, and review or compare saved results. FastAPI routes requests into authentication, integrations, simulation, and persistence; Celery tasks provide background EPİAŞ and weather work. The README documents capabilities beyond the sampled excerpts, so those branches are included where paths are supported, with evidence cited to the README. Unsampled implementation details and unverified links are omitted.

Main entry points: [`auth/auth_request.py`](https://github.com/emirhannavdar/ges_battery/blob/main/auth/auth_request.py) (Authentication routes), [`simulation/simulation_manager.py`](https://github.com/emirhannavdar/ges_battery/blob/main/simulation/simulation_manager.py) (Simulation manager), [`api/api.py`](https://github.com/emirhannavdar/ges_battery/blob/main/api/api.py) (FastAPI application), [`api/endpoints/simulation_request.py`](https://github.com/emirhannavdar/ges_battery/blob/main/api/endpoints/simulation_request.py) (Simulation routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Dashboard views"]
  node_frontend_components["Dashboard components"]
  node_frontend_proxy["Backend proxy<br/>[route.ts]"]
  node_frontend_client["API client<br/>[client.ts]"]
end

subgraph group_api["API and integrations"]
  node_api_app["FastAPI application<br/>[api.py]"]
  node_epias_routes["EPİAŞ routes<br/>[epias_request.py]"]
  node_weather_routes["Weather routes"]
  node_simulation_routes["Simulation routes"]
  node_epias_service["EPİAŞ client<br/>[epias.py]"]
  node_weather_service["Weather client<br/>[visual_crossing.py]"]
end

subgraph group_auth["Identity and access"]
  node_auth_routes["Authentication routes<br/>[auth_request.py]"]
  node_auth_core["JWT authentication<br/>[auth.py]"]
  node_role_access["Role authorization<br/>[roles.py]"]
  node_geocoding["Location geocoding<br/>[geocoding.py]"]
end

subgraph group_simulation["PV simulation"]
  node_simulation_manager["Simulation manager"]
  node_inverter["Inverter model<br/>[inverter.py]"]
  node_transformer["Transformer model<br/>[transformer.py]"]
  node_ekk["EKK controller<br/>[ekk.py]"]
  node_energy_analyzer["Energy analyzer<br/>[energy_analyzer.py]"]
  node_simulation_clock["Simulation clock"]
end

subgraph group_data_jobs["Data and jobs"]
  node_pg[("PostgreSQL")]
  node_user_data[("User and location data<br/>[database.py]")]
  node_scenario_data[("Saved scenarios")]
  node_weather_data[("Weather records<br/>[weather_db.py]")]
  node_ptf_data[("PTF records<br/>[epias_ptf_db.py]")]
  node_celery["Celery app<br/>[celery_app.py]"]
  node_epias_tasks["EPİAŞ tasks<br/>[epias_tasks.py]"]
  node_weather_tasks["Weather tasks<br/>[weather_tasks.py]"]
end

node_operator(("Operator"))
node_external_epias["EPİAŞ"]
node_external_weather["Visual Crossing"]
node_redis[("Redis")]

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_frontend_components
node_frontend_components -.->|"requests"| node_frontend_client
node_frontend_client -.->|"forwards"| node_frontend_proxy
node_frontend_proxy -->|"forwards requests"| node_api_app
node_api_app -->|"registers"| node_epias_routes
node_api_app -->|"registers"| node_weather_routes
node_api_app -->|"registers"| node_simulation_routes
node_api_app -->|"registers"| node_auth_routes
node_epias_routes -->|"calls"| node_epias_service
node_epias_service -->|"requests data"| node_external_epias
node_epias_routes -->|"stores and reads"| node_ptf_data
node_weather_routes -->|"calls"| node_weather_service
node_weather_service -->|"requests weather"| node_external_weather
node_weather_routes -->|"stores and reads"| node_weather_data
node_simulation_routes -->|"runs simulation"| node_simulation_manager
node_simulation_routes -->|"reads weather"| node_weather_data
node_simulation_routes -->|"saves and loads"| node_scenario_data
node_simulation_manager -->|"steps"| node_inverter
node_simulation_manager -->|"calculates losses"| node_transformer
node_simulation_manager -->|"controls power"| node_ekk
node_simulation_manager -->|"analyzes output"| node_energy_analyzer
node_simulation_manager -->|"validates time"| node_simulation_clock
node_auth_routes -->|"authenticates"| node_auth_core
node_auth_routes -->|"reads and updates"| node_user_data
node_auth_routes -->|"resolves location"| node_geocoding
node_auth_core -->|"loads user"| node_user_data
node_role_access -->|"checks active user"| node_auth_core
node_auth_routes -->|"enforces roles"| node_role_access
node_user_data -->|"queries"| node_pg
node_scenario_data -->|"persists runs"| node_pg
node_weather_data -->|"persists records"| node_pg
node_ptf_data -->|"persists prices"| node_pg
node_epias_tasks -->|"runs as task"| node_celery
node_weather_tasks -->|"runs as task"| node_celery
node_epias_tasks -->|"fetches prices"| node_epias_service
node_epias_tasks -->|"stores prices"| node_ptf_data
node_weather_tasks -->|"fetches weather"| node_weather_service
node_weather_tasks -->|"stores weather"| node_weather_data
node_celery -->|"uses broker"| node_redis
node_epias_service -->|"caches token"| node_redis
node_auth_routes -->|"rate limits login"| node_redis

click node_dashboard "https://github.com/emirhannavdar/ges_battery/tree/main/frontend/app/(panel)"
click node_frontend_components "https://github.com/emirhannavdar/ges_battery/tree/main/frontend/components"
click node_frontend_proxy "https://github.com/emirhannavdar/ges_battery/blob/main/frontend/app/api/%5B...path%5D/route.ts"
click node_frontend_client "https://github.com/emirhannavdar/ges_battery/blob/main/frontend/lib/client.ts"
click node_api_app "https://github.com/emirhannavdar/ges_battery/blob/main/api/api.py"
click node_epias_routes "https://github.com/emirhannavdar/ges_battery/blob/main/api/endpoints/epias_request.py"
click node_weather_routes "https://github.com/emirhannavdar/ges_battery/blob/main/api/endpoints/visual_crossing_request.py"
click node_simulation_routes "https://github.com/emirhannavdar/ges_battery/blob/main/api/endpoints/simulation_request.py"
click node_epias_service "https://github.com/emirhannavdar/ges_battery/blob/main/api/services/epias.py"
click node_weather_service "https://github.com/emirhannavdar/ges_battery/blob/main/api/services/visual_crossing.py"
click node_auth_routes "https://github.com/emirhannavdar/ges_battery/blob/main/auth/auth_request.py"
click node_auth_core "https://github.com/emirhannavdar/ges_battery/blob/main/auth/auth.py"
click node_role_access "https://github.com/emirhannavdar/ges_battery/blob/main/auth/roles.py"
click node_geocoding "https://github.com/emirhannavdar/ges_battery/blob/main/auth/geocoding.py"
click node_simulation_manager "https://github.com/emirhannavdar/ges_battery/blob/main/simulation/simulation_manager.py"
click node_inverter "https://github.com/emirhannavdar/ges_battery/blob/main/simulation/inverter.py"
click node_transformer "https://github.com/emirhannavdar/ges_battery/blob/main/simulation/transformer.py"
click node_ekk "https://github.com/emirhannavdar/ges_battery/blob/main/simulation/ekk.py"
click node_energy_analyzer "https://github.com/emirhannavdar/ges_battery/blob/main/simulation/energy_analyzer.py"
click node_simulation_clock "https://github.com/emirhannavdar/ges_battery/blob/main/simulation/simulation_clock.py"
click node_user_data "https://github.com/emirhannavdar/ges_battery/blob/main/database/database.py"
click node_scenario_data "https://github.com/emirhannavdar/ges_battery/blob/main/database/simulation_repository.py"
click node_weather_data "https://github.com/emirhannavdar/ges_battery/blob/main/database/weather_db.py"
click node_ptf_data "https://github.com/emirhannavdar/ges_battery/blob/main/database/epias_ptf_db.py"
click node_celery "https://github.com/emirhannavdar/ges_battery/blob/main/tasks/celery_app.py"
click node_epias_tasks "https://github.com/emirhannavdar/ges_battery/blob/main/tasks/epias_tasks.py"
click node_weather_tasks "https://github.com/emirhannavdar/ges_battery/blob/main/tasks/weather_tasks.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_frontend_components,node_frontend_proxy,node_frontend_client toneBlue
class node_api_app,node_epias_routes,node_weather_routes,node_simulation_routes,node_epias_service,node_weather_service,node_redis toneAmber
class node_auth_routes,node_auth_core,node_role_access,node_geocoding toneMint
class node_simulation_manager,node_inverter,node_transformer,node_ekk,node_energy_analyzer,node_simulation_clock toneRose
class node_pg,node_user_data,node_scenario_data,node_weather_data,node_ptf_data,node_celery,node_epias_tasks,node_weather_tasks,node_operator,node_external_epias,node_external_weather toneIndigo
```

## Components

### Dashboard

- [Dashboard views](https://github.com/emirhannavdar/ges_battery/tree/main/frontend/app/(panel)): `frontend/app/(panel)`
- [Dashboard components](https://github.com/emirhannavdar/ges_battery/tree/main/frontend/components): `frontend/components`
- [Backend proxy](https://github.com/emirhannavdar/ges_battery/blob/main/frontend/app/api/%5B...path%5D/route.ts): `frontend/app/api/[...path]/route.ts`
- [API client](https://github.com/emirhannavdar/ges_battery/blob/main/frontend/lib/client.ts): `frontend/lib/client.ts`

### API and integrations

- [FastAPI application](https://github.com/emirhannavdar/ges_battery/blob/main/api/api.py): `api/api.py`
- [EPİAŞ routes](https://github.com/emirhannavdar/ges_battery/blob/main/api/endpoints/epias_request.py): `api/endpoints/epias_request.py`
- [Weather routes](https://github.com/emirhannavdar/ges_battery/blob/main/api/endpoints/visual_crossing_request.py): `api/endpoints/visual_crossing_request.py`
- [Simulation routes](https://github.com/emirhannavdar/ges_battery/blob/main/api/endpoints/simulation_request.py): `api/endpoints/simulation_request.py`
- [EPİAŞ client](https://github.com/emirhannavdar/ges_battery/blob/main/api/services/epias.py): `api/services/epias.py`
- [Weather client](https://github.com/emirhannavdar/ges_battery/blob/main/api/services/visual_crossing.py): `api/services/visual_crossing.py`

### Identity and access

- [Authentication routes](https://github.com/emirhannavdar/ges_battery/blob/main/auth/auth_request.py): `auth/auth_request.py`
- [JWT authentication](https://github.com/emirhannavdar/ges_battery/blob/main/auth/auth.py): `auth/auth.py`
- [Role authorization](https://github.com/emirhannavdar/ges_battery/blob/main/auth/roles.py): `auth/roles.py`
- [Location geocoding](https://github.com/emirhannavdar/ges_battery/blob/main/auth/geocoding.py): `auth/geocoding.py`

### PV simulation

- [Simulation manager](https://github.com/emirhannavdar/ges_battery/blob/main/simulation/simulation_manager.py): `simulation/simulation_manager.py`
- [Inverter model](https://github.com/emirhannavdar/ges_battery/blob/main/simulation/inverter.py): `simulation/inverter.py`
- [Transformer model](https://github.com/emirhannavdar/ges_battery/blob/main/simulation/transformer.py): `simulation/transformer.py`
- [EKK controller](https://github.com/emirhannavdar/ges_battery/blob/main/simulation/ekk.py): `simulation/ekk.py`
- [Energy analyzer](https://github.com/emirhannavdar/ges_battery/blob/main/simulation/energy_analyzer.py): `simulation/energy_analyzer.py`
- [Simulation clock](https://github.com/emirhannavdar/ges_battery/blob/main/simulation/simulation_clock.py): `simulation/simulation_clock.py`

### Data and jobs

- **PostgreSQL**
- [User and location data](https://github.com/emirhannavdar/ges_battery/blob/main/database/database.py): `database/database.py`
- [Saved scenarios](https://github.com/emirhannavdar/ges_battery/blob/main/database/simulation_repository.py): `database/simulation_repository.py`
- [Weather records](https://github.com/emirhannavdar/ges_battery/blob/main/database/weather_db.py): `database/weather_db.py`
- [PTF records](https://github.com/emirhannavdar/ges_battery/blob/main/database/epias_ptf_db.py): `database/epias_ptf_db.py`
- [Celery app](https://github.com/emirhannavdar/ges_battery/blob/main/tasks/celery_app.py): `tasks/celery_app.py`
- [EPİAŞ tasks](https://github.com/emirhannavdar/ges_battery/blob/main/tasks/epias_tasks.py): `tasks/epias_tasks.py`
- [Weather tasks](https://github.com/emirhannavdar/ges_battery/blob/main/tasks/weather_tasks.py): `tasks/weather_tasks.py`

### Other components

- **Operator**
- **EPİAŞ**
- **Visual Crossing**
- **Redis**

## Connections

- Operator → Dashboard views: uses
- Dashboard views → Dashboard components: renders
- Dashboard components → API client: requests
- API client → Backend proxy: forwards
- Backend proxy → FastAPI application: forwards requests
- FastAPI application → EPİAŞ routes: registers (evidence: `api/api.py`)
- FastAPI application → Weather routes: registers (evidence: `api/api.py`)
- FastAPI application → Simulation routes: registers (evidence: `api/api.py`)
- FastAPI application → Authentication routes: registers (evidence: `api/api.py`)
- EPİAŞ routes → EPİAŞ client: calls (evidence: `api/endpoints/epias_request.py`)
- EPİAŞ client → EPİAŞ: requests data
- EPİAŞ routes → PTF records: stores and reads (evidence: `api/endpoints/epias_request.py`)
- Weather routes → Weather client: calls (evidence: `api/endpoints/visual_crossing_request.py`)
- Weather client → Visual Crossing: requests weather
- Weather routes → Weather records: stores and reads (evidence: `api/endpoints/visual_crossing_request.py`)
- Simulation routes → Simulation manager: runs simulation (evidence: `api/endpoints/simulation_request.py`)
- Simulation routes → Weather records: reads weather
- Simulation routes → Saved scenarios: saves and loads (evidence: `api/endpoints/simulation_request.py`)
- Simulation manager → Inverter model: steps (evidence: `simulation/simulation_manager.py`)
- Simulation manager → Transformer model: calculates losses (evidence: `simulation/simulation_manager.py`)
- Simulation manager → EKK controller: controls power (evidence: `simulation/simulation_manager.py`)
- Simulation manager → Energy analyzer: analyzes output (evidence: `simulation/simulation_manager.py`)
- Simulation manager → Simulation clock: validates time (evidence: `simulation/simulation_manager.py`)
- Authentication routes → JWT authentication: authenticates (evidence: `auth/auth_request.py`)
- Authentication routes → User and location data: reads and updates (evidence: `auth/auth_request.py`)
- Authentication routes → Location geocoding: resolves location (evidence: `auth/auth_request.py`)
- JWT authentication → User and location data: loads user (evidence: `auth/auth.py`)
- Role authorization → JWT authentication: checks active user (evidence: `auth/roles.py`)
- Authentication routes → Role authorization: enforces roles (evidence: `auth/auth_request.py`)
- User and location data → PostgreSQL: queries
- Saved scenarios → PostgreSQL: persists runs
- Weather records → PostgreSQL: persists records
- PTF records → PostgreSQL: persists prices
- EPİAŞ tasks → Celery app: runs as task (evidence: `tasks/epias_tasks.py`)
- Weather tasks → Celery app: runs as task (evidence: `tasks/weather_tasks.py`)
- EPİAŞ tasks → EPİAŞ client: fetches prices (evidence: `tasks/epias_tasks.py`)
- EPİAŞ tasks → PTF records: stores prices (evidence: `tasks/epias_tasks.py`)
- Weather tasks → Weather client: fetches weather (evidence: `tasks/weather_tasks.py`)
- Weather tasks → Weather records: stores weather (evidence: `tasks/weather_tasks.py`)
- Celery app → Redis: uses broker
- EPİAŞ client → Redis: caches token (evidence: `api/services/epias.py`)
- Authentication routes → Redis: rate limits login
