Skip to content

feat: enerOS Site Intelligence MVP v0.1#13

Merged
AUREX-ML merged 2 commits into
mainfrom
copilot/eneros-site-intelligence-mvp-v0-1
Jul 3, 2026
Merged

feat: enerOS Site Intelligence MVP v0.1#13
AUREX-ML merged 2 commits into
mainfrom
copilot/eneros-site-intelligence-mvp-v0-1

Conversation

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Implements the full enerOS Site Intelligence MVP — a live operational picture of one simulated energy site, from raw telemetry through analytics to an operator dashboard.

Backend (apps/api/)

  • FastAPI REST API: assets, telemetry ingestion/history, alerts, recommendations
  • SQLAlchemy ORM — SQLite by default, PostgreSQL in Docker; schema auto-created on startup with 5 seeded demo assets (grid, solar, battery, generator, load)
  • Analytics engine (analytics.py) — deterministic rules evaluated on every ingested record:
    • 6 alert types: CRITICAL_BATTERY, LOW_BATTERY, HIGH_GRID_IMPORT, GENERATOR_RUNNING, SOLAR_UNDERPERFORM, HIGH_LOAD
    • 4 recommendation types: CHARGE_BATTERY, REDUCE_GRID_IMPORT, SCHEDULE_LOADS, GENERATOR_TEST

Simulator (services/simulator/simulate.py)

Three modes via CLI:

python -m services.simulator.simulate history   # back-fills 25 h to the API
python -m services.simulator.simulate live      # posts a record every 30 s
python -m services.simulator.simulate file      # writes JSON to data/

Physics model: 50 kW solar curve, 10 kW battery, 15 kW generator, base + peak load profile.

Dashboard (apps/dashboard/)

React 18 / Vite / TypeScript SPA — polls /api/v1/* every 5 s. Four panels: live telemetry metrics, per-asset status, active alerts (resolvable), recommendations (dismissable). Vite dev proxy forwards /api to localhost:8000.

Tests (apps/api/tests/)

40 pytest tests — full coverage of every API endpoint and every alert/recommendation rule using an in-memory SQLite StaticPool with dependency override.

One-command start

cp .env.example .env   # set DB_PASSWORD
docker compose up      # db → api → simulator (history then live) → dashboard

Dashboard: http://localhost:5173 · API docs: http://localhost:8000/docs

Copilot AI linked an issue Jul 3, 2026 that may be closed by this pull request
10 tasks
@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Security Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot AI changed the title [WIP] Release enerOS Site Intelligence MVP v0.1 feat: enerOS Site Intelligence MVP v0.1 Jul 3, 2026
Copilot AI requested a review from AUREX-ML July 3, 2026 09:12
@AUREX-ML
AUREX-ML marked this pull request as ready for review July 3, 2026 11:28
Copilot AI review requested due to automatic review settings July 3, 2026 11:28
@AUREX-ML
AUREX-ML merged commit c617763 into main Jul 3, 2026
2 of 3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements the enerOS Site Intelligence MVP v0.1 end-to-end: a simulator generates site telemetry, a FastAPI backend ingests/persists it and derives alerts/recommendations, and a React/Vite dashboard visualizes the live operational picture (plus Docker Compose for one-command startup).

Changes:

  • Expanded simulator into file/history/live modes with API posting support and containerization.
  • Added FastAPI + SQLAlchemy backend with analytics rules, seeded demo assets, and pytest coverage for endpoints/rules.
  • Added a React/Vite/TypeScript dashboard (plus Nginx container) and local dev proxying.

Reviewed changes

Copilot reviewed 34 out of 36 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
services/simulator/simulate.py Adds simulator modes, record generation, and API posting logic.
services/simulator/requirements.txt Introduces Python dependencies for the simulator container build.
services/simulator/README.md Documents simulator modes and environment variables.
services/simulator/Dockerfile Containerizes the simulator for Docker Compose.
README.md Updates repo-level docs for the MVP, quick starts, and scenarios.
docker-compose.yml Adds full-stack dev composition (db/api/simulator/dashboard).
data/sample-telemetry.json Updates sample telemetry payloads to match the newer schema/content.
apps/dashboard/vite.config.ts Adds Vite dev server config including /api proxy.
apps/dashboard/tsconfig.json Adds TypeScript compiler configuration for the dashboard.
apps/dashboard/src/types.ts Defines dashboard domain types (assets/telemetry/alerts/recommendations).
apps/dashboard/src/main.tsx Adds dashboard React entrypoint.
apps/dashboard/src/index.css Adds global styling tokens and base styles.
apps/dashboard/src/components/TelemetryPanel.tsx Live telemetry KPI panel UI.
apps/dashboard/src/components/RecommendationsPanel.tsx Recommendations list UI with dismiss action.
apps/dashboard/src/components/AssetsPanel.tsx Asset status list UI based on latest telemetry.
apps/dashboard/src/components/AlertsPanel.tsx Alerts list UI with resolve action.
apps/dashboard/src/App.tsx Main dashboard app: polling, state management, actions.
apps/dashboard/src/App.css Dashboard layout and component styling.
apps/dashboard/README.md Documents dashboard features and dev/build usage.
apps/dashboard/package.json Adds dashboard npm metadata and deps (React/Vite/TS).
apps/dashboard/nginx.conf Nginx config for SPA hosting + /api proxy in Docker.
apps/dashboard/index.html Dashboard HTML entry for Vite build.
apps/dashboard/Dockerfile Multi-stage Docker build for dashboard (build + Nginx).
apps/api/tests/test_api.py Endpoint integration tests for API routes.
apps/api/tests/test_analytics.py Unit tests for analytics alert/recommendation rules.
apps/api/tests/conftest.py Test DB setup (StaticPool) and FastAPI dependency overrides.
apps/api/tests/init.py Marks API tests package.
apps/api/requirements.txt Pins API runtime + test dependencies.
apps/api/README.md Documents API endpoints and how to run/test locally.
apps/api/models.py Adds ORM models and Pydantic schemas.
apps/api/main.py Adds FastAPI app, routes, DB init/seeding, and analytics integration.
apps/api/Dockerfile Containerizes API service for Docker Compose.
apps/api/database.py Adds SQLAlchemy engine/session setup and schema init.
apps/api/analytics.py Implements analytics rules producing alerts/recommendations.
apps/api/init.py Marks API package.
.env.example Adds example env configuration for Docker Compose.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1 @@
requests==2.32.3
)
battery_soc = 60.0
while True:
ts = datetime.now(tz=timezone.utc).replace(second=0, microsecond=0)
Comment on lines +211 to +213
args = parser.parse_args()
mode = args.mode or "file"

Comment on lines +85 to +90
battery_delta = net + generator_kw
battery_change = max(-10.0, min(10.0, battery_delta))
battery_soc = round(max(0.0, min(100.0, battery_soc + battery_change)), 1)
battery_kw = round(battery_change, 2)

grid_kw = round(net + generator_kw - battery_change, 2)
Comment thread apps/api/analytics.py
Comment on lines +52 to +56
record_ts = record.get("timestamp", ts)
if isinstance(record_ts, str):
record_ts = datetime.fromisoformat(record_ts.replace("Z", "+00:00"))
hour = record_ts.hour if hasattr(record_ts, "hour") else ts.hour

Comment thread apps/api/main.py
Comment on lines +52 to +57
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
)
Comment on lines +76 to +79
def test_get_latest_telemetry(client):
r = client.get("/api/v1/telemetry/latest")
assert r.status_code == 200
assert "solar_kw" in r.json()
Comment thread apps/api/models.py
from typing import Optional

from pydantic import BaseModel
from sqlalchemy import DateTime, Float, Integer, String, Text
Comment thread apps/api/models.py
alert_type: Mapped[str] = mapped_column(String(64), nullable=False)
severity: Mapped[str] = mapped_column(String(16), nullable=False) # info | warning | critical
message: Mapped[str] = mapped_column(Text, nullable=False)
resolved: Mapped[bool] = mapped_column(Integer, default=0) # SQLite bool compat
Comment thread apps/api/models.py
priority: Mapped[str] = mapped_column(String(16), nullable=False) # low | medium | high
message: Mapped[str] = mapped_column(Text, nullable=False)
action: Mapped[str] = mapped_column(Text, nullable=False)
dismissed: Mapped[bool] = mapped_column(Integer, default=0)
Copilot AI mentioned this pull request Jul 3, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enerOS Site Intelligence MVP v0.1

3 participants