# codeasarjun/ecogrid-demand-ops architecture

> Architecture diagram of the GitHub repository codeasarjun/ecogrid-demand-ops, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codeasarjun/ecogrid-demand-ops
- Repository: https://github.com/codeasarjun/ecogrid-demand-ops

## Overview

EcoGrid-Demand-Ops is a demand-forecasting MLOps application. Its documented workflow runs drift monitoring before retraining: Prefect halts when drift is detected, otherwise it trains a Random Forest, records metrics in MLflow, and saves weights for the FastAPI inference service. The graph also shows configuration and the prediction interface. The monitor source currently builds synthetic baseline and live data rather than reading the repository CSVs; implementation details beyond the sampled files are not inferred.

Main entry points: [`src/app_server.py`](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/app_server.py) (FastAPI service), [`src/pipeline_train.py`](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/pipeline_train.py) (Grid model training), [`src/orchestrator.py`](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/orchestrator.py) (Prefect workflow), [`src/pipeline_monitor.py`](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/pipeline_monitor.py) (Drift assessment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Orchestration"]
  node_orchestrator["Prefect workflow<br/>[orchestrator.py]"]
end

subgraph group_monitoring["Drift Monitoring"]
  node_monitor["Drift assessment"]
end

subgraph group_training["Model Training"]
  node_training["Grid model training<br/>[pipeline_train.py]"]
  node_config["Runtime settings<br/>[config.py]"]
  node_mlflow[("MLflow ledger")]
  node_model_artifact["Serialized model"]
end

subgraph group_serving["Inference Serving"]
  node_api["FastAPI service<br/>[app_server.py]"]
  node_telemetry_payload["Validated payload<br/>[app_server.py]"]
  node_forecast["Load forecast<br/>[app_server.py]"]
end

node_operator(("Pipeline operator"))
node_sensor_source(("Sensor telemetry"))
node_api_user(("Inference caller"))

node_operator -->|"starts flow"| node_orchestrator
node_orchestrator -->|"runs check"| node_monitor
node_monitor -->|"reads settings"| node_config
node_sensor_source -.->|"provides telemetry"| node_monitor
node_monitor -->|"returns drift result"| node_orchestrator
node_orchestrator -->|"runs if clear"| node_training
node_training -->|"reads settings"| node_config
node_training -->|"logs run"| node_mlflow
node_training -->|"saves weights"| node_model_artifact
node_api_user -->|"submits query"| node_api
node_api -->|"reads settings"| node_config
node_api -->|"loads weights"| node_model_artifact
node_api -->|"validates input"| node_telemetry_payload
node_api -->|"returns prediction"| node_forecast

click node_orchestrator "https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/orchestrator.py"
click node_monitor "https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/pipeline_monitor.py"
click node_training "https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/pipeline_train.py"
click node_config "https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/config.py"
click node_api "https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/app_server.py"
click node_telemetry_payload "https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/app_server.py"
click node_forecast "https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/app_server.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_orchestrator toneBlue
class node_monitor toneAmber
class node_training,node_config,node_mlflow,node_model_artifact toneMint
class node_api,node_telemetry_payload,node_forecast toneRose
class node_operator,node_sensor_source,node_api_user toneIndigo
```

## Components

### Orchestration

- [Prefect workflow](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/orchestrator.py): `src/orchestrator.py`

### Drift Monitoring

- [Drift assessment](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/pipeline_monitor.py): `src/pipeline_monitor.py`

### Model Training

- [Grid model training](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/pipeline_train.py): `src/pipeline_train.py`
- [Runtime settings](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/config.py): `src/config.py`
- **MLflow ledger**
- **Serialized model**

### Inference Serving

- [FastAPI service](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/app_server.py): `src/app_server.py`
- [Validated payload](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/app_server.py): `src/app_server.py`
- [Load forecast](https://github.com/codeasarjun/ecogrid-demand-ops/blob/master/src/app_server.py): `src/app_server.py`

### Other components

- **Pipeline operator**
- **Sensor telemetry**
- **Inference caller**

## Connections

- Pipeline operator → Prefect workflow: starts flow (evidence: `README.md`)
- Prefect workflow → Drift assessment: runs check (evidence: `src/orchestrator.py`)
- Drift assessment → Runtime settings: reads settings (evidence: `src/pipeline_monitor.py`)
- Sensor telemetry → Drift assessment: provides telemetry (evidence: `README.md`)
- Drift assessment → Prefect workflow: returns drift result (evidence: `src/orchestrator.py`)
- Prefect workflow → Grid model training: runs if clear (evidence: `src/orchestrator.py`)
- Grid model training → Runtime settings: reads settings (evidence: `src/pipeline_train.py`)
- Grid model training → MLflow ledger: logs run (evidence: `src/pipeline_train.py`)
- Grid model training → Serialized model: saves weights (evidence: `src/pipeline_train.py`)
- Inference caller → FastAPI service: submits query (evidence: `README.md`)
- FastAPI service → Runtime settings: reads settings (evidence: `src/app_server.py`)
- FastAPI service → Serialized model: loads weights (evidence: `src/app_server.py`)
- FastAPI service → Validated payload: validates input (evidence: `src/app_server.py`)
- FastAPI service → Load forecast: returns prediction (evidence: `src/app_server.py`)
