Services

Operator guides for the 14 production daemons — ports, config, APIs, deployment.

mako implements the BDEW Marktkommunikation between the four German market roles — LF (Lieferant), NB (Netzbetreiber), MSB (Messstellenbetreiber) and BKV (Bilanzkreisverantwortlicher); see Party Roles.

mako consists of 14 independently deployable services, each a self-contained Docker image built on the mako-service SDK, with TOML configuration (env: and _FILE secrets), OIDC/JWT and API-key authentication, Cedar ABAC, OpenTelemetry, /health/live · /health/ready · /metrics, and an MCP server at /mcp (Streamable HTTP) on 11 of the 14 — all except outputd, portald and agentd (the MCP host). just dev runs them all, each on its deploy/demo/<service>.toml, seeded with one Stadtwerk.


Service Map

graph TB
    ext["BDEW Counterparty<br/>(NB · LF · MSB · BKV)"]

    subgraph protocol ["Protocol & Market Data"]
        makod[":8080 makod<br/>EDIFACT runtime · 83 workflows<br/>AS4 · SlateDB · MCP"]
        marktd[":8180 marktd<br/>MaLo/MeLo/NeLo · contracts<br/>VersorgungsStatus · fan-out"]
        processd[":8580 processd<br/>Anmeldung STP, target ≥95%<br/>LF answers · §14a<br/>process projections · KPI · §7a parity<br/>Sperrauftrag queue · IFTSTA 21039"]
    end

    subgraph nb_billing ["Invoice & Grid Billing (NB)"]
        invoicd[":8280 invoicd<br/>INVOIC 8-stage plausibility<br/>auto-settle/dispute"]
        netzbilanzd[":8680 netzbilanzd<br/>NNE/KA/MMM/MSB billing<br/>SettlementResult · CalculationTrace<br/>MaBiS MSCONS 13003 · 10. Werktag"]
    end

    subgraph data ["Energy Data & Observability"]
        edmd[":8380 edmd<br/>MSCONS · iMSys direct push<br/>validation · Ersatzwerte · virtual"]
        einsd[":9180 einsd<br/>EEG/KWKG settlement<br/>10 schemes · §14 UStG Gutschrift"]
    end

    subgraph lf_billing ["Retail Billing (LF)"]
        productd[":9080 productd<br/>14 categories · §42 Stromkennzeichnung<br/>EPEX §41a · B2B Angebote"]
        billingd[":9280 billingd<br/>13 categories · XRechnung 3.0<br/>RLM demand · §54 exemption"]
        outputd[":9880 outputd<br/>Typst templates · ZUGFeRD carrier<br/>issued documents · delivery evidence"]
        accountingd[":9380 accountingd<br/>Massenkontokorrent<br/>SEPA FRST/RCUR · GLN ID · Aging · §288 BGB"]
    end

    subgraph b2c ["Contract & Customer (LF)"]
        vertragd[":9780 vertragd<br/>Kunden B2C+B2B · Rahmenverträge<br/>OIDC→MaLo · 22 MCP tools"]
        portald[":9480 portald<br/>customer portal read-model<br/>§41 self-service"]
    end

    agentd[":9580 agentd<br/>28 declarative manifests on agentplane<br/>journaled effects · strict replay<br/>human triage worklist · A2A cards<br/>OIDC · HMAC · 5 model backends"]

    ext -->|AS4 / REST| makod
    makod <-->|CloudEvents| marktd
    marktd -->|webhook fan-out| processd & invoicd & edmd & agentd
    makod -->|commands| netzbilanzd & invoicd
    netzbilanzd -->|MSCONS 13003 cmd| makod
    billingd -->|de.mako.billing.rechnung.erstellt| accountingd
    billingd -->|render · pin hash| outputd
    vertragd -->|start-supply| processd
    portald -->|aggregates| billingd & accountingd & edmd & einsd & marktd

Protocol & Market Data

ServicePortRolePurpose
makod:8080 · :4080 · :8090AllProtocol daemon — 83 workflows over 499 Prüfidentifikatoren, AS4/REST/iMS
marktd:8180AllMarket Data Hub — MaLo/MeLo/contracts, VersorgungsStatus, typed BO4E API, durable fan-out, MMMA monthly import worker
processd:8580NB + LF + MSBProcess Decision Engine — Anmeldung STP (target ≥95%), LF answers to NB-initiated GPKE processes, MSB REQOTE answers, §14a check; per-PID KPIs and § 7a Abs. 5 EnWG parity; the NB Sperrauftrag queue (IFTSTA 21039); role-gated builds

Invoice & Grid Billing

ServicePortRolePurpose
invoicd:8280LFINVOIC plausibility-check — eight stages plus the WiM 31003 send window (incl. ToU band routing via zaehlzeitregister), auto-settle/dispute, § 147 AO / GoBD receipts
netzbilanzd:8680NB/ÜNBNNE/KA/MMM/MSB/AWH billing — INVOIC 31001/31002/31005/31009/31011, REMADV lifecycle, §14a Modul 3 ToU, §42b EnWG GGV, Redispatch 2.0 Kostenblatt; MaBiS Summenzeitreihen filed with the BIKO as MSCONS 13003 on the 10. Werktag; 15-tool MCP server

Energy Data & Observability

ServicePortRolePurpose
edmd:8380AllEnergy Data Management — MSCONS, iMSys direct push, Kafka batch ingest, quality scoring and validation, virtual meters, tiered storage; 19-tool MCP server
einsd:9180NB/LFEinspeiser Registry + EEG/KWKG settlement — 10 settlement schemes; issues the §14 UStG Gutschrift (Gutschriftverfahren) per billable settlement as a BO4E Rechnung with per-rate USt breakdown; 20-tool MCP server

Retail Billing (LF)

ServicePortRolePurpose
productd:9080LFProduct & Tariff Catalog — user-defined energy products, EPEX Spot for §41a, B2B Angebote/quotations
billingd:9280LFEnergy Billing Engine — 13 categories, §41a dynamic, §42b EnWG GGV community solar, EN 16931 e-invoicing (XRechnung 3.0 CII / PEPPOL UBL); the ZUGFeRD PDF renders via outputd
outputd:9880—Customer Communications — operator Typst templates, the ZUGFeRD PDF/A-3 carrier, Mahnung and Preisanpassung, the append-only store of issued documents and their delivery evidence (portal, e-mail, print, ERP)
accountingd:9380LFCustomer Account Ledger — tamper-evident double-entry ledger (doubleentry, period seals for GoBD/§146 AO); per-MaLo Kontokorrent, FIFO clearing, Verzugszinsen §288 BGB; SEPA pain.008 and CAMT.054; dunning delivered through outputd

B2C & AI

ServicePortRolePurpose
vertragd:9780LF + MSBContract & Customer Management — Kunden (B2C+B2B), Rahmenverträge, Versorgungsverträge, Tarifwechsel with its § 41 Abs. 5 EnWG Preisänderungsanzeige, Kündigung, OIDC→MaLo auth gateway for portald
portald:9480LFCustomer Portal gateway — stateless aggregation over the LF services plus the §41 EnWG self-service writes (Tarifwechsel, Kündigung, SEPA, GDPR Art. 16) and the outputd document inbox; ownership resolved through vertragd; no MCP server
agentd:9580AllMulti-agent LLM orchestration — 28 declarative manifests on the agentplane durable runtime, every effect journaled; read-only by construction, so oversight is a triage worklist

Shared foundation — the mako-service SDK

Every daemon is built on the mako-service crate. A service's main is a single line:

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    mako_service::run::<Billingd>().await   // Billingd: Daemon impl
}

run::<D>() owns the whole lifecycle. A Daemon implementation supplies only what is service-specific — the config type, the migrations, and a build() that assembles the domain router and spawns background workers:

flowchart TD
    start(["main → run::&lt;D&gt;"]) --> check{"--check?"}
    check -->|yes| probe["GET /health/ready<br/>exit 0/1"] --> done([exit])
    check -->|no| trace["init tracing"]
    trace --> cfg["load config<br/>TOML + env + _FILE"]
    cfg --> pool["connect tuned pool<br/>DatabaseConfig::connect(url, NAME)<br/>sets application_name"]
    pool --> migrate["D::migrate<br/>sqlx::migrate! + outbox::ensure_schema"]
    migrate --> build["D::build(cfg, ctx)<br/>domain Router + spawn workers on ctx.shutdown"]
    build --> infra["mount infra routes<br/>/health · /health/live · /health/ready · /metrics"]
    infra --> serve["serve with graceful drain<br/>SIGINT / SIGTERM"]
    serve -.->|readiness| ready["/health/ready = bounded SELECT 1 + D::ready"]

What every service gets for free from the runner:

ConcernProvided by run::<D>()
TracingStructured logs and optional OTLP export (RUST_LOG, OTEL_EXPORTER_OTLP_ENDPOINT). The rmcp SDK logs at most at info level to keep tool arguments and responses private.
Config[database] + service blocks, env:/_FILE substitution, <SVC>_CONFIG path
PoolTuned sizing with a per-service application_name for pg_stat_activity
MigrationsApplied at startup before the first request
ReadinessReal /health/ready — a bounded SELECT 1 DB ping, not a static true
ShutdownSIGINT/SIGTERM graceful drain; workers observe ctx.shutdown
Health probe--check in-container HEALTHCHECK (no shell, no curl)

Event-emitting services use the SDK's transactional outbox: each CloudEvent is written to event_outbox in the same transaction as the business change, and the shared webhook module (mako_service::subscriptions) fans it out to every matching endpoint — the configured ERP URL as default, in-cluster receivers as [[subscriptions.endpoints]], integrators through the API — with retry, a dead-letter state and replay. marktd reaches the other services this way. Commands owed to another service drain through OutboxWorker::commands. Every envelope is built by CloudEvent::new and signed as Standard Webhooks (webhook-signature).

The SDK outbox wakes its workers from an AFTER INSERT trigger's NOTIFY, which Postgres holds until commit; the 30 s poll is the fallback.

makod alone keeps its own main (SlateDB event store, AS4 runtime); every other service runs on mako_service::run.


Deployment

All services are available as multi-stage Docker images built with cargo-chef:

# Single all-in-one daemon (makod only)
docker pull ghcr.io/hupe1980/mako-makod:latest

# Every service and the Desk on the released images, seeded — one port, :8000
git clone https://github.com/hupe1980/mako
cd mako
just demo

See the Getting Started guide for the full deployment walkthrough.

makod Operator Guide

makod operator guide: ports, CLI flags, the config file, persistent and volatile storage, AS4 inbound, the REST API and Kubernetes deploymen…

marktd Operator Guide

Operator guide for marktd, the market data hub: Marktpartner, Marktlokationen, price sheets and the durable CloudEvents fan-out every other …

processd Operator Guide

processd operator guide: NB Anmeldung STP, LF and MSB answers, the process read model and its KPIs, the NB Sperrauftrag queue, role-gated bu…

invoicd Operator Guide

invoicd operator guide: the LF-side INVOIC plausibility check over ten inbound billing PIDs, with § 147 AO receipts and the answer back thro…

netzbilanzd Operator Guide

netzbilanzd operator guide: NNE, Konzessionsabgabe and Mehr-/Mindermengen settled into INVOIC drafts, and MaBiS Summenzeitreihen filed with …

edmd Operator Guide

Operator guide for edmd, the energy-data daemon: MSCONS and iMSys readings, quality scoring, validation, virtual meters and § 60 MsbG Ersatz…

einsd Operator Guide

Operator guide for einsd, the EEG/KWKG feed-in settlement daemon: plant registry, §51 Negativpreisregel, §52 Pflichtzahlungen, 20 MCP tools,…

productd Operator Guide

Operator guide for productd, the LF product and tariff catalogue: Tarifpreisblätter, §41a EPEX dynamic pricing, the §41c comparison feed and…

billingd Operator Guide

Operator guide for billingd, the LF multi-product billing engine: 13 product categories, §41a dynamic tariffs, §14a modules and EN 16931 e-i…

outputd Operator Guide

Operator guide for outputd, the customer-communications daemon: operator-owned Typst templates, the ZUGFeRD PDF/A-3 carrier and per-channel …

accountingd Operator Guide

Operator guide for accountingd, the LF Massenkontokorrent: a tamper-evident double-entry ledger, SEPA and camt payment flows, Mahnwesen and …

vertragd Operator Guide

Operator guide for vertragd, contract and customer management: B2C and B2B Verträge, Rahmenverträge, Kündigungsfristen and §41 EnWG price-ch…

portald Operator Guide

Operator guide for portald, the customer-portal read-model gateway: one REST API over Lastgang, invoices, ledger and supply status, plus §41…

agentd Operator Guide

agentd operator guide: 30 specialist manifests on agentplane — typed results, durable triage, semantic trust labels and journal-backed runs.