Expand description
ERP integration traits and reference implementations.
§Role
mako-engine is a protocol processor — it handles EDIFACT parsing, BDEW
process rules, AS4 delivery, and regulatory deadlines. All contract data,
billing logic, and master data live in the operator’s ERP.
This module defines the stable integration contract between mako-engine
and external ERP or backend systems. The payload contract is BO4E, not
raw EDIFACT. ERP adapters never see EDIFACT segment codes or format-version
identifiers — those are absorbed inside mako-engine.
§Outbound: mako → ERP
Implement ErpAdapter and register it at startup. Every domain event
that requires ERP action is delivered as an ErpEvent. The production
WebhookErpAdapter (in makod) serialises events as
CloudEvents 1.0 structured-mode JSON and POSTs
them to the configured ERP endpoint.
POST <erp_webhook_url>
Content-Type: application/cloudevents+json
X-Idempotency-Key: <event.idempotency_key>
X-Mako-Signature: <hmac-sha256-hex> ← only when secret is configured
{
"specversion": "1.0",
"id": "<idempotency_key>",
"source": "urn:mako:tenant:<tenant_id>",
"type": "de.mako.aperak.accepted",
"time": "2026-10-01T10:15:00+02:00",
"subject": "<process_id>",
"dataschema": "https://.../Marktlokation.json",
"datacontenttype": "application/json",
"makoconvid": "<conversation_id>",
"makocausationid": "<causation_id>",
"makopid": 55001,
"data": { "_typ": "MARKTLOKATION", ... }
}See ErpEventType::cloud_event_type for the full type → CE type mapping.
The BO4E payload is always in the data field; the payload_schema URL
maps to the CloudEvents dataschema attribute.
§Inbound: ERP → mako (event-driven)
For ERP systems with a message bus, implement ErpCommandSource to feed
BO4E business objects into the engine without a synchronous REST round-trip.
struct MyKafkaSource { consumer: KafkaConsumer }
impl ErpCommandSource for MyKafkaSource {
async fn next(&self) -> Result<Option<InboundErpCommand>, ErpAdapterError> {
let msg = self.consumer.poll(Duration::from_millis(100)).await;
Ok(msg.map(|m| InboundErpCommand {
idempotency_key: m.offset().to_string(),
tenant_id: TenantId::new(),
payload_schema: "…/Marktlokation.json".into(),
payload: serde_json::from_slice(m.payload()).unwrap(),
}))
}
async fn ack(&self, id: &str) -> Result<(), ErpAdapterError> {
self.consumer.commit_offset(id.parse().unwrap()).await
.map_err(ErpAdapterError::transport)
}
async fn nack(&self, _id: &str, _reason: &str) -> Result<(), ErpAdapterError> {
Ok(()) // Kafka auto-redelivers on next poll
}
}§Reference implementations
| Type | Feature | Use case |
|---|---|---|
[NoopErpAdapter] | testing | Unit tests, CI |
LogErpAdapter | — | Structured log output; starting point for new integrations |
[NoopErpCommandSource] | testing | No-op inbound source for tests |
For the production WebhookErpAdapter and POST /api/v1/commands endpoint,
see makod/src/erp_adapter.rs.
Structs§
- ErpEvent
- A structured process event delivered from
mako-engineto the ERP. - Inbound
ErpCommand - A BO4E business object received from the ERP, intended to trigger a mako process.
- LogErp
Adapter - An
ErpAdapterthat logs every event atinfolevel without delivering it.
Enums§
- ErpAdapter
Error - Errors produced by
ErpAdapterandErpCommandSourceimplementations. - ErpEvent
Type - Semantic classification of an outbound ERP process event.
Constants§
- BO4E_
SCHEMA_ ENERGIEMENGE - BO4E JSON Schema URL for
Energiemenge. - BO4E_
SCHEMA_ GESCHAEFTSPARTNER - BO4E JSON Schema URL for
Geschaeftspartner. - BO4E_
SCHEMA_ MARKTLOKATION - BO4E JSON Schema URL for
Marktlokation. - BO4E_
SCHEMA_ MESSLOKATION - BO4E JSON Schema URL for
Messlokation. - BO4E_
SCHEMA_ RECHNUNG - BO4E JSON Schema URL for
Rechnung. - BO4E_
SCHEMA_ VERTRAG - BO4E JSON Schema URL for
Vertrag. - BO4E_
SCHEMA_ ZAEHLER - BO4E JSON Schema URL for
Zaehler. - BO4E_
V202501_ BASE - BO4E schema URL base for v202501.0.0.
Traits§
- ErpAdapter
- Outbound notification sink —
mako-enginecalls this when a process event should be reported to the ERP. - ErpCommand
Source - Inbound command source —
mako-enginepolls this for new BO4E objects from the ERP.