# code84/ev_traffic_optim architecture

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

- Interactive diagram: https://gitdiagram.com/code84/ev_traffic_optim
- Repository: https://github.com/code84/ev_traffic_optim

## Overview

This repository is an EV-network analytics and tariff-optimization product. Its main user-to-result workflow turns ACN and Shenzhen UrbanEV data into processed time series and engineered features, trains demand and congestion models, then runs a five-agent forecast-to-insight workflow that recommends prices and tracks operational KPIs. A Streamlit dashboard presents forecasts, congestion, pricing, station analytics, and agent insights; a separate pricing simulation produces network-level comparisons. The graph follows documented or excerpted calls; some training and dashboard wiring is only documented, so uncertain links are omitted.

Main entry points: [`src/agents/orchestrator.py`](https://github.com/code84/ev_traffic_optim/blob/main/src/agents/orchestrator.py) (Agent Orchestrator), [`src/data_engineering/preprocessing_pipeline.py`](https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/preprocessing_pipeline.py) (Preprocessing), [`src/dashboard/app.py`](https://github.com/code84/ev_traffic_optim/blob/main/src/dashboard/app.py) (Streamlit Dashboard), [`src/models/trainer.py`](https://github.com/code84/ev_traffic_optim/blob/main/src/models/trainer.py) (Forecast Trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data Preparation"]
  node_acn[("ACN Sessions")]
  node_urban[("UrbanEV Inputs")]
  node_acnproc["ACN Processor<br/>[acn_processor.py]"]
  node_urbanproc["UrbanEV Processor"]
  node_preprocess["Preprocessing"]
  node_etl["Analytical ETL<br/>[etl_pipeline.py]"]
  node_features["Feature Engineering<br/>[features.py]"]
  node_featurepipe["Feature Pipeline<br/>[pipeline.py]"]
end

subgraph group_models["Modeling"]
  node_trainer["Forecast Trainer<br/>[trainer.py]"]
  node_congmodel["Congestion Model"]
end

subgraph group_agents["Agent Workflow"]
  node_forecast["Demand Forecast Agent<br/>[forecast_agent.py]"]
  node_congestion["Congestion Agent"]
  node_pricingagent["Pricing Agent<br/>[pricing_agent.py]"]
  node_monitor["Monitoring Agent"]
  node_insights["Insights Agent<br/>[insights_agent.py]"]
  node_orchestrator["Agent Orchestrator<br/>[orchestrator.py]"]
end

subgraph group_product["Pricing &amp; Interface"]
  node_engine["Pricing Engine<br/>[pricing_engine.py]"]
  node_dashboard["Streamlit Dashboard<br/>[app.py]"]
  node_loader["Dashboard Data Loader<br/>[data_loader.py]"]
  node_simulation["Pricing Simulation"]
end

subgraph group_support["Shared Analysis"]
  node_helpers["Data Helpers<br/>[helpers.py]"]
  node_metrics["Evaluation Metrics<br/>[metrics.py]"]
end

node_user(("Operator"))

node_user -.->|"starts processing"| node_preprocess
node_acn -.->|"session input"| node_preprocess
node_urban -.->|"network input"| node_preprocess
node_preprocess -->|"processes ACN"| node_acnproc
node_preprocess -->|"processes UrbanEV"| node_urbanproc
node_etl -->|"loads and transforms"| node_urbanproc
node_featurepipe -->|"engineers features"| node_features
node_features -->|"uses helpers"| node_helpers
node_trainer -.->|"trains models"| node_congmodel
node_trainer -.->|"uses engineered inputs"| node_features
node_orchestrator -->|"dispatches forecast"| node_forecast
node_orchestrator -->|"dispatches risk"| node_congestion
node_orchestrator -->|"dispatches pricing"| node_pricingagent
node_orchestrator -->|"dispatches monitoring"| node_monitor
node_orchestrator -->|"dispatches insights"| node_insights
node_pricingagent -->|"uses pricing engine"| node_engine
node_monitor -->|"feedback tunes"| node_pricingagent
node_dashboard -->|"loads dashboard data"| node_loader
node_dashboard -->|"runs agent workflow"| node_orchestrator
node_dashboard -->|"requests forecast"| node_forecast
node_user -.->|"views operations"| node_dashboard
node_simulation -->|"simulates tariffs"| node_engine
node_simulation -->|"uses helpers"| node_helpers
node_trainer -.->|"evaluates models"| node_metrics

click node_acn "https://github.com/code84/ev_traffic_optim/tree/main/UrbanEV_dataset"
click node_urban "https://github.com/code84/ev_traffic_optim/tree/main/UrbanEV_dataset"
click node_acnproc "https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/acn_processor.py"
click node_urbanproc "https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/urban_ev_processor.py"
click node_preprocess "https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/preprocessing_pipeline.py"
click node_etl "https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/etl_pipeline.py"
click node_features "https://github.com/code84/ev_traffic_optim/blob/main/src/feature_engineering/features.py"
click node_featurepipe "https://github.com/code84/ev_traffic_optim/blob/main/src/feature_engineering/pipeline.py"
click node_trainer "https://github.com/code84/ev_traffic_optim/blob/main/src/models/trainer.py"
click node_congmodel "https://github.com/code84/ev_traffic_optim/blob/main/src/models/congestion_model.py"
click node_forecast "https://github.com/code84/ev_traffic_optim/blob/main/src/agents/forecast_agent.py"
click node_congestion "https://github.com/code84/ev_traffic_optim/blob/main/src/agents/congestion_agent.py"
click node_pricingagent "https://github.com/code84/ev_traffic_optim/blob/main/src/agents/pricing_agent.py"
click node_engine "https://github.com/code84/ev_traffic_optim/blob/main/src/pricing/pricing_engine.py"
click node_monitor "https://github.com/code84/ev_traffic_optim/blob/main/src/agents/monitoring_agent.py"
click node_insights "https://github.com/code84/ev_traffic_optim/blob/main/src/agents/insights_agent.py"
click node_orchestrator "https://github.com/code84/ev_traffic_optim/blob/main/src/agents/orchestrator.py"
click node_dashboard "https://github.com/code84/ev_traffic_optim/blob/main/src/dashboard/app.py"
click node_loader "https://github.com/code84/ev_traffic_optim/blob/main/src/dashboard/data_loader.py"
click node_simulation "https://github.com/code84/ev_traffic_optim/blob/main/run_pricing_simulation.py"
click node_helpers "https://github.com/code84/ev_traffic_optim/blob/main/src/utils/helpers.py"
click node_metrics "https://github.com/code84/ev_traffic_optim/blob/main/src/utils/metrics.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_acn,node_urban,node_acnproc,node_urbanproc,node_preprocess,node_etl,node_features,node_featurepipe toneBlue
class node_trainer,node_congmodel toneAmber
class node_forecast,node_congestion,node_pricingagent,node_monitor,node_insights,node_orchestrator toneMint
class node_engine,node_dashboard,node_loader,node_simulation toneRose
class node_helpers,node_metrics,node_user toneIndigo
```

## Components

### Data Preparation

- [ACN Sessions](https://github.com/code84/ev_traffic_optim/tree/main/UrbanEV_dataset): `UrbanEV_dataset`
- [UrbanEV Inputs](https://github.com/code84/ev_traffic_optim/tree/main/UrbanEV_dataset): `UrbanEV_dataset`
- [ACN Processor](https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/acn_processor.py): `src/data_engineering/acn_processor.py`
- [UrbanEV Processor](https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/urban_ev_processor.py): `src/data_engineering/urban_ev_processor.py`
- [Preprocessing](https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/preprocessing_pipeline.py): `src/data_engineering/preprocessing_pipeline.py`
- [Analytical ETL](https://github.com/code84/ev_traffic_optim/blob/main/src/data_engineering/etl_pipeline.py): `src/data_engineering/etl_pipeline.py`
- [Feature Engineering](https://github.com/code84/ev_traffic_optim/blob/main/src/feature_engineering/features.py): `src/feature_engineering/features.py`
- [Feature Pipeline](https://github.com/code84/ev_traffic_optim/blob/main/src/feature_engineering/pipeline.py): `src/feature_engineering/pipeline.py`

### Modeling

- [Forecast Trainer](https://github.com/code84/ev_traffic_optim/blob/main/src/models/trainer.py): `src/models/trainer.py`
- [Congestion Model](https://github.com/code84/ev_traffic_optim/blob/main/src/models/congestion_model.py): `src/models/congestion_model.py`

### Agent Workflow

- [Demand Forecast Agent](https://github.com/code84/ev_traffic_optim/blob/main/src/agents/forecast_agent.py): `src/agents/forecast_agent.py`
- [Congestion Agent](https://github.com/code84/ev_traffic_optim/blob/main/src/agents/congestion_agent.py): `src/agents/congestion_agent.py`
- [Pricing Agent](https://github.com/code84/ev_traffic_optim/blob/main/src/agents/pricing_agent.py): `src/agents/pricing_agent.py`
- [Monitoring Agent](https://github.com/code84/ev_traffic_optim/blob/main/src/agents/monitoring_agent.py): `src/agents/monitoring_agent.py`
- [Insights Agent](https://github.com/code84/ev_traffic_optim/blob/main/src/agents/insights_agent.py): `src/agents/insights_agent.py`
- [Agent Orchestrator](https://github.com/code84/ev_traffic_optim/blob/main/src/agents/orchestrator.py): `src/agents/orchestrator.py`

### Pricing & Interface

- [Pricing Engine](https://github.com/code84/ev_traffic_optim/blob/main/src/pricing/pricing_engine.py): `src/pricing/pricing_engine.py`
- [Streamlit Dashboard](https://github.com/code84/ev_traffic_optim/blob/main/src/dashboard/app.py): `src/dashboard/app.py`
- [Dashboard Data Loader](https://github.com/code84/ev_traffic_optim/blob/main/src/dashboard/data_loader.py): `src/dashboard/data_loader.py`
- [Pricing Simulation](https://github.com/code84/ev_traffic_optim/blob/main/run_pricing_simulation.py): `run_pricing_simulation.py`

### Shared Analysis

- [Data Helpers](https://github.com/code84/ev_traffic_optim/blob/main/src/utils/helpers.py): `src/utils/helpers.py`
- [Evaluation Metrics](https://github.com/code84/ev_traffic_optim/blob/main/src/utils/metrics.py): `src/utils/metrics.py`

### Other components

- **Operator**

## Connections

- Operator → Preprocessing: starts processing (evidence: `README.md`)
- ACN Sessions → Preprocessing: session input (evidence: `README.md`)
- UrbanEV Inputs → Preprocessing: network input (evidence: `README.md`)
- Preprocessing → ACN Processor: processes ACN (evidence: `src/data_engineering/preprocessing_pipeline.py`)
- Preprocessing → UrbanEV Processor: processes UrbanEV (evidence: `src/data_engineering/preprocessing_pipeline.py`)
- Analytical ETL → UrbanEV Processor: loads and transforms (evidence: `src/data_engineering/etl_pipeline.py`)
- Feature Pipeline → Feature Engineering: engineers features (evidence: `src/feature_engineering/pipeline.py`)
- Feature Engineering → Data Helpers: uses helpers (evidence: `src/feature_engineering/features.py`)
- Forecast Trainer → Congestion Model: trains models (evidence: `README.md`)
- Forecast Trainer → Feature Engineering: uses engineered inputs (evidence: `README.md`)
- Agent Orchestrator → Demand Forecast Agent: dispatches forecast (evidence: `src/agents/orchestrator.py`)
- Agent Orchestrator → Congestion Agent: dispatches risk (evidence: `src/agents/orchestrator.py`)
- Agent Orchestrator → Pricing Agent: dispatches pricing (evidence: `src/agents/orchestrator.py`)
- Agent Orchestrator → Monitoring Agent: dispatches monitoring (evidence: `src/agents/orchestrator.py`)
- Agent Orchestrator → Insights Agent: dispatches insights (evidence: `src/agents/orchestrator.py`)
- Pricing Agent → Pricing Engine: uses pricing engine (evidence: `src/agents/pricing_agent.py`)
- Monitoring Agent → Pricing Agent: feedback tunes (evidence: `src/agents/orchestrator.py`)
- Streamlit Dashboard → Dashboard Data Loader: loads dashboard data (evidence: `src/dashboard/app.py`)
- Streamlit Dashboard → Agent Orchestrator: runs agent workflow (evidence: `src/dashboard/app.py`)
- Streamlit Dashboard → Demand Forecast Agent: requests forecast (evidence: `src/dashboard/app.py`)
- Operator → Streamlit Dashboard: views operations (evidence: `README.md`)
- Pricing Simulation → Pricing Engine: simulates tariffs (evidence: `run_pricing_simulation.py`)
- Pricing Simulation → Data Helpers: uses helpers (evidence: `run_pricing_simulation.py`)
- Forecast Trainer → Evaluation Metrics: evaluates models (evidence: `README.md`)
