Vibe Coding #5 — Spanish Energy Billing Engine | Full Invoice Decomposition API

Building a FastAPI microservice that breaks down every component of a Spanish electricity bill — from OMIE spot prices and settlement adjustments to peajes, cargos, losses, and taxes — for all tariff types (2.0TD through 6.4TD).

Coming soon March 3, 2026 17:30 CET
fastapienergybillingspaintariffsomiemicroservicepython

Get weekly updates

Live coding sessions, Python libraries for energy data, and hands-on tutorials. One email per week, zero fluff.

What we’ll build

A production-ready billing engine for Spanish electricity invoices, exposed as a FastAPI service that decomposes market costs, regulated charges, losses, and taxes line by line.

Why this matters

  • Most billing tools hide electricity invoices behind opaque totals instead of showing how each component is calculated
  • Spanish tariffs change by ATR family, period, and regulatory year, so naive billing logic breaks quickly
  • Energy teams need auditable outputs for consultants, internal tools, and customer-facing apps
  • We already have the core engine working; this stream is about turning it into something deployable and reliable

What you’ll see

  1. API design: Inputs, validation, and response shape for a billing microservice
  2. Tariff coverage: Support for 2.0TD, 3.0TD, and 6.1TD-6.4TD tariff families
  3. Edge cases: DST changes, missing settlement values, and regulatory period updates
  4. Deployment: Containerizing the service and wiring it into energy.datons.ai
  5. Output polish: Structuring the breakdown so downstream apps and reports can consume it cleanly

Architecture

Inputs
CUPS · Consumption · Tariff data
Regulated charges
Billing Engine
Python · Cost decomposition
Market Data
OMIE · AJOM · AJOS · SSAA
Regulated Costs
Peajes · Cargos · Losses · Taxes
Structured bill breakdown
FastAPI
Validation · Docs · Responses
JSON responses
Consumers
Frontend · Reports · AI agents

Stack

  • Python 3.11+ · FastAPI · Pydantic · pandas · Docker · OMIE · CNMC

Who is this for

  • Energy developers building billing, quoting, or analytics products for Spain
  • Consultants and analysts who need auditable invoice decompositions
  • Data engineers turning market and settlement data into production APIs

Notes

  • The billing engine already exists; this is a hardening and deployment stream, not a blank-page build
  • The reference data covers residential, SME, and industrial ATR tariffs
  • We will explain how the main settlement columns map to real invoice components
Table of Contents
Search sections

Subscribe to our newsletter

Get weekly insights on data, automation, and AI.

© 2026 Datons. All rights reserved.