Case study

SolarCast: forecasting solar income, shipped with GitOps

A Prophet model that forecasts a home solar system’s monthly generation and payout, delivered to Kubernetes through a pipeline where Git is the only way to deploy.

  • Apr 2026 – Oct 2026
  • Personal project · ML and DevOps
Screenshot of SolarCast
error (MAPE) on 9 unseen months
8.0%error (MAPE) on 9 unseen months
error of the same-month-last-year baseline
9.5%error of the same-month-last-year baseline
automated tests gating every pull request
39automated tests gating every pull request
manual kubectl steps to deploy
0manual kubectl steps to deploy
01

The problem

A rooftop solar system in Sri Lanka is paid for the energy it exports to the grid, at LKR 37 a unit, about a month after each meter reading. The household wanted to know what next month’s generation and payout would be, with an honest range rather than a single guess.

The data made that harder than it sounds. There are only 29 clean monthly records, from April 2024. The utility sometimes skips a meter visit, so one reading covers two months. One month is incomplete because the inverter lost its Wi-Fi. And the readings are private, so they could not go into Git, a container image or a public demo.

I also used the project to practise the delivery side properly: a forecasting model is only useful if it can be tested, shipped and rolled back as safely as any other service.

02

Architecture

Two containers, a React dashboard served by nginx and a FastAPI backend that trains and serves the model, run in two Kubernetes environments built from the same manifests. Nothing in the cluster is changed by hand: Argo CD keeps it matching the repository.

Source and CI

  • GitHub repository

    App code and Kubernetes manifests in one place

  • GitHub Actions

    ruff, pytest, image builds, Trivy, smoke test

Registry

  • Docker Hub

    Backend and frontend images, amd64 and arm64, tagged with the commit SHA

Kubernetes cluster

  • Argo CD

    Watches deploy/overlays and syncs, prunes and self-heals

solarcast-dev

  • frontend

    nginx, 1 pod

  • backend

    FastAPI and Prophet

  • Synthetic data

    Secret and model volume

solarcast-prod

  • frontend

    nginx, 2 pods

  • backend

    FastAPI and Prophet

  • Real readings

    Secret and model volume

CI never talks to the cluster. After publishing images it commits the new tag to the dev overlay, and Argo CD notices the commit. The inverter CSVs are mounted from a Kubernetes Secret created from a local folder, so they never enter Git or an image.

03

From pull request to running pod

Every change takes the same path, and each stage can stop it.

  1. 1

    Pull request

    Lint with ruff, 39 pytest tests on synthetic data, a frontend build, both images built, and a Trivy scan that fails on any fixable high or critical vulnerability. Then the real containers start and a smoke test trains, predicts and reads history through nginx.

  2. 2

    Merge to main

    Multi-architecture images are published to Docker Hub, tagged with the commit SHA. An image is built once and only its tag moves between environments.

  3. 3

    Record the release in Git

    A CI job writes the new SHA into deploy/overlays/dev and commits it. If another merge lands first, it rebases and retries rather than overwriting it.

  4. 4

    Argo CD rolls out dev

    Automated sync applies the commit. Objects removed from Git are pruned, and changes made directly in the cluster are reverted.

  5. 5

    Promote or roll back

    Prod changes only when a pull request edits the tag in deploy/overlays/prod. Rolling back is reverting that commit, so the Git history is the record of what ran where.

04

Decisions and trade-offs

01

Prophet with a deliberately small seasonal model

With 20 training months, Prophet’s default yearly seasonality (Fourier order 10) overfit badly: it forecast 274 kWh for a January whose actual was 512. Order 3 with flat growth and no changepoints captures the dry-season cycle without fitting noise.

Trade-offMost calendar months have only one or two samples, so the seasonal shape is still rough.

02

Ratios for export and payout instead of a second model

Only generation is forecast. Export, creditable export and cash are derived from it using per-month ratios from the training data, which is simpler to check and explain than another black box.

Trade-offGrid import is averaged, not predicted, so a big change in household use (an EV, say) would throw the payout off.

03

Confidence intervals I compute myself

With flat growth and MAP fitting, Prophet’s own interval collapses to zero width. The 90% range comes from each month’s observed spread (1.645σ), widened for export by the ratio’s spread.

Trade-offMonths with a single training sample fall back to a fixed ±10%.

04

CI records releases in Git and never touches the cluster

Git is the single source of truth for what runs. Every deployment is a commit someone can read, review and revert, and the cluster needs no CI credentials.

Trade-offEach merge adds a bot commit to main, and concurrent merges need a rebase-and-retry loop.

05

Recreate rollouts for the backend

Trained models live on a persistent volume that only one pod can attach, and two pods must never write to it at once.

Trade-offThe API is briefly unavailable during each backend rollout.

06

Private data stays out of everything shared

CI, the dev environment and the public demo all run on a synthetic dataset. The demo on GitHub Pages runs the real pipeline at build time and ships only the JSON answers.

Trade-offSetting up a cluster includes a manual step to load the real readings into prod.

05

Results

  • On the 9 most recent months, which the model never saw, it is off by about 8.0% (MAE about 47 kWh a month), against about 9.5% for simply repeating the same month last year. These figures are for data up to September 2026 and move as each month is added.

  • A merge reaches the dev cluster with no manual step, and prod moves only by a reviewed pull request. A manual change in the cluster does not last: Argo CD puts back what Git says.

  • Both pods run as non-root with every Linux capability dropped and no Kubernetes API token, the backend on a read-only root filesystem, and every CI action is pinned to a commit SHA.

  • The public demo rebuilds on every change and on the 1st of each month, so its history always runs to last month without any private reading reaching it.

06

What I'd do next

The model only narrowly beats the baseline, and the platform has known gaps. These are next, in this order:

  1. 01

    Observability: Prometheus, Grafana dashboards and alerts for latency, errors and forecast error. The API already exposes request metrics, but nothing collects them yet.

  2. 02

    Move training out of the API into a cluster job that publishes to an MLflow registry, and remove the unauthenticated POST /train endpoint.

  3. 03

    Switch to daily inverter data with weather features, kept in MinIO, so the model can beat the baseline by a clear margin.

  4. 04

    Add an Ingress instead of port-forwarding, and manage the Argo CD applications themselves with the app-of-apps pattern.

  5. 05

    Scheduled retraining behind a promotion gate, with canary releases through Argo Rollouts so a worse model rolls itself back.

Built with

  • Python
  • Prophet
  • pandas
  • FastAPI
  • React
  • Recharts
  • Docker
  • nginx
  • Kubernetes
  • Kustomize
  • Argo CD
  • GitHub Actions
  • Trivy
  • Docker Hub
  • pytest
  • ruff

© 2026 Kalhara Tennakoon. All Rights Reserved.