> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heychocolate.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EPD & MKI

> Ingest, parse, and visualize Environmental Product Declarations and Milieukostenindicatoren.

The EPD & MKI module handles the ingestion, parsing, and visualization of Environmental Product Declarations (EPDs) and their associated MKI (Milieukostenindicator) scores.

## What are EPD and MKI?

* **EPD** (Environmental Product Declaration): A standardized document that quantifies the environmental impact of a product across its lifecycle, following ISO 14025 and EN 15804.
* **MKI** (Milieukostenindicator): A Dutch environmental cost indicator that translates environmental impacts into a single monetary value (EUR), widely used in construction and infrastructure.

## Ingesting an EPD

Upload an EPD document (PDF or XML) for automatic parsing:

```graphql theme={null}
mutation {
  ingestEpd(input: {
    productId: "prod_abc123"
    source: URL
    sourceUrl: "https://example.com/epd/product-abc.xml"
    format: EN15804_XML
  }) {
    id
    status
    productId
    parsedData {
      declarationNumber
      validFrom
      validTo
      functionalUnit
      impactCategories {
        name
        code
        value
        unit
        phase
      }
      mkiScore
    }
  }
}
```

## Supported input formats

| Format        | Description                      |
| ------------- | -------------------------------- |
| `EN15804_XML` | EN 15804 compliant XML format    |
| `ILCD_XML`    | ILCD/EPD format                  |
| `PDF`         | PDF document (OCR-parsed)        |
| `MANUAL`      | Manual data entry via API fields |

## Querying EPD data

```graphql theme={null}
query {
  epd(productId: "prod_abc123") {
    declarationNumber
    programOperator
    validFrom
    validTo
    functionalUnit
    impactCategories {
      name
      code
      value
      unit
      phase
    }
    mkiScore
    mkiBreakdown {
      category
      value
      percentage
    }
  }
}
```

## MKI calculation

Calculate MKI scores with custom parameters, similar to [Insert Marktplaats](https://marktplaats.insert.nl):

```graphql theme={null}
mutation {
  calculateMki(input: {
    productId: "prod_abc123"
    quantity: 1
    functionalUnit: "m2"
    lifespan: 75
    maintenanceScenario: STANDARD
  }) {
    mkiScore
    unit
    perFunctionalUnit
    breakdown {
      phase
      value
      percentage
    }
    phases {
      A1_A3 { value description }
      A4 { value description }
      A5 { value description }
      B1_B7 { value description }
      C1_C4 { value description }
      D { value description }
    }
  }
}
```

**Response:**

```json theme={null}
{
  "data": {
    "calculateMki": {
      "mkiScore": 0.87,
      "unit": "EUR/m2",
      "perFunctionalUnit": 0.87,
      "breakdown": [
        { "phase": "Production (A1-A3)", "value": 0.45, "percentage": 51.7 },
        { "phase": "Transport (A4)", "value": 0.08, "percentage": 9.2 },
        { "phase": "Construction (A5)", "value": 0.05, "percentage": 5.7 },
        { "phase": "Use (B1-B7)", "value": 0.15, "percentage": 17.2 },
        { "phase": "End of life (C1-C4)", "value": 0.18, "percentage": 20.7 },
        { "phase": "Benefits (D)", "value": -0.04, "percentage": -4.6 }
      ]
    }
  }
}
```

## EPD lifecycle phases

| Phase        | Code  | Description                                         |
| ------------ | ----- | --------------------------------------------------- |
| Production   | A1-A3 | Raw material supply, transport, manufacturing       |
| Transport    | A4    | Transport to construction site                      |
| Construction | A5    | Installation process                                |
| Use          | B1-B7 | Use, maintenance, repair, replacement               |
| End of life  | C1-C4 | Demolition, transport, waste processing, disposal   |
| Benefits     | D     | Recycling and reuse benefits beyond system boundary |

## Webhook events

* `epd.ingested` — EPD document successfully parsed
* `epd.validation_failed` — EPD parsing encountered errors
* `mki.calculated` — MKI score computed for a product
