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

# Module 1 Exercise: Design and Build Your First End-to-End Flow

> Design a Biochar Delivery event type in a spreadsheet or FigJam, then build it in Mangrove: one event type, one model, one calculated output.

<Panel>
  <Card title="Accounting Academy" className="accounting-academy-card">
    <div className="accounting-academy-content">
      <Steps className="my-0">
        <Step title="MODULE 1: Fundamentals" icon="bookmark" iconType="solid" stepNumber={1} titleSize="p">
          * [1.1: Core Concepts & the Data Lifecycle](/accounting-academy/module-1/1-1-core-concepts-data-lifecycle)
          * [1.2: Translating Methodologies to Mangrove](/accounting-academy/module-1/1-2-translating-methodologies-to-mangrove)
          * [1.3: Events and Datapoints](/accounting-academy/module-1/1-3-events-and-datapoints)
          * [Exercise: Design and Build](/accounting-academy/module-1/1-exercise-design-and-build)
        </Step>

        <Step title="MODULE 2: Calculations" icon="bookmark" iconType="solid" stepNumber={2} titleSize="p">
          * [2.1: Calculation Architecture](/accounting-academy/module-2/2-1-calculation-architecture)
          * [2.2: Expanding Your Data Model](/accounting-academy/module-2/2-2-expanding-your-data-model)
          * [Exercise: Multi-Step Calculations](/accounting-academy/module-2/2-exercise-multi-step-calculations)
        </Step>

        <Step title="MODULE 3: Batch Partitioning & LCA" icon="bookmark" iconType="solid" stepNumber={3} titleSize="p">
          * [3.1: What Is a Batch?](/accounting-academy/module-3/3-1-what-is-a-batch)
          * [3.2: Batch Partitioning Strategies](/accounting-academy/module-3/3-2-batch-partitioning)
          * [3.3: Life Cycle Assessment & Emissions](/accounting-academy/module-3/3-3-lca-and-emissions)
          * [3.4: Allocating Emissions to Batches](/accounting-academy/module-3/3-4-allocating-emissions-to-batches)
          * [Exercise: Batch Partitioning & LCA](/accounting-academy/module-3/3-exercise-batch-partitioning-and-lca)
        </Step>

        <Step title="MODULE 4: Mass Balance with Ledgers" icon="bookmark" iconType="solid" stepNumber={4} titleSize="p">
          * [4.1: Introduction to Mass Balance](/accounting-academy/module-4/4-1-intro-to-mass-balance)
          * [4.2: Designing the Ledger Structure](/accounting-academy/module-4/4-2-designing-the-ledger-structure)
          * [4.3: Multiple Batch Types for Different Stages](/accounting-academy/module-4/4-3-multiple-batch-types)
          * [Exercise: Design & Build Mass Balance](/accounting-academy/module-4/4-exercise-design-and-build-mass-balance)
        </Step>

        <Step title="MODULE 5: Integration Testing" icon="bookmark" iconType="solid" stepNumber={5} titleSize="p">
          * [5.1: The Complete Model Assembly](/accounting-academy/module-5/5-1-the-complete-model-assembly)
          * [5.2: Testing Patterns](/accounting-academy/module-5/5-2-testing-patterns)
          * [5.3: Common Integration Pitfalls](/accounting-academy/module-5/5-3-common-integration-pitfalls)
          * [Exercise: Integration Testing](/accounting-academy/module-5/5-exercise-integration-testing)
        </Step>

        <Step title="MODULE 6: Advanced Patterns & Production" icon="bookmark" iconType="solid" stepNumber={6} titleSize="p">
          * [6.1: Model Design Best Practices](/accounting-academy/module-6/6-1-model-design-best-practices)
          * [6.2: Advanced Techniques](/accounting-academy/module-6/6-2-advanced-techniques)
          * [6.3: Production Readiness](/accounting-academy/module-6/6-3-production-readiness)
          * [Exercise: Production Deployment](/accounting-academy/module-6/6-exercise-production-deployment)
        </Step>
      </Steps>
    </div>
  </Card>
</Panel>

<Check>
  **What you'll build in this exercise:**

  * Design a Biochar Delivery event type with 3-5 datapoints
  * Build the event type and a simple model in Mangrove
  * Generate a batch and verify the calculated output
</Check>

This exercise has two parts: a **Design** phase (30 min) and a **Build in Mangrove** phase (1 hr). By the end you will have a working end-to-end flow:

```mermaid theme={null}
flowchart LR
    E["Event<br/>Biochar Delivery"] --> M["Model<br/>carbon = mass x C% x 3.67"]
    M --> B["Batch<br/>29.36 tCO2e"]

    style E fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#000
    style M fill:#66bb6a,stroke:#388e3c,stroke-width:2px,color:#000
    style B fill:#ef5350,stroke:#c62828,stroke-width:2px,color:#000
```

**Prerequisites:** Complete [Lesson 1.1](/accounting-academy/module-1/1-1-core-concepts-data-lifecycle), [Lesson 1.2](/accounting-academy/module-1/1-2-translating-methodologies-to-mangrove), and [Lesson 1.3](/accounting-academy/module-1/1-3-events-and-datapoints). Ensure you have duplicated the Mangrove Biochar starter project and named it "Mangrove Biochar – \[Your Name] Training." You can <a href="/production-accounting/getting-started" target="_blank" rel="noopener noreferrer">create or duplicate a project</a>

in the Projects section.

***

## Part 1: Design (30 min)

Before touching the app, design your first event type and dataflow in a spreadsheet or FigJam.

### 1. Identify one key activity

Pick **one key activity** in the Mangrove Biochar process to model first. We suggest **"Biochar Delivery"** — the moment biochar is delivered to a field for application. Each delivery is a natural unit of production and a good candidate for an event.

### 2. List the datapoints

For the activity you chose, list the datapoints the event must capture:

<CardGroup cols={3}>
  <Card icon="ruler" title="Measurements">
    * Biochar mass (tonnes)
    * Carbon content (%)
    * Delivery date
  </Card>

  <Card icon="tag" title="Identifiers">
    * Delivery ticket ID
    * Tracking ID (optional)
  </Card>

  <Card icon="file-check" title="Evidence">
    * Delivery ticket
    * Weighbridge slip
    * Application record
  </Card>
</CardGroup>

You can store the Delivery ticket ID as a datapoint or as the event's <a href="/data-collection/add-data" target="_blank" rel="noopener noreferrer">Tracking ID</a>

(optional field).

### 3. Sketch the flow: Event → Model → Output

<Steps>
  <Step title="Event">
    One Biochar Delivery with values for each datapoint (e.g., mass = 10 t, carbon content = 80%).
  </Step>

  <Step title="Model">
    A calculation that reads those datapoints and produces one output. Formula:

    `carbon_delivered = mass × (carbon_content / 100) × 3.67`

    (3.67 is the CO2-to-carbon mass ratio.)
  </Step>

  <Step title="Output">
    The model produces **carbon delivered in tCO2e** — e.g., 10 × 0.80 × 3.67 = **29.36 tCO2e**.
  </Step>
</Steps>

***

## Part 2: Build in Mangrove (1 hr)

Using your duplicated Mangrove Biochar project, implement the design. The starter project already has the ledger and batch type set up, so you only need to create the event type, build the model, and generate batches.

### Step 1: Create one event type with 3-5 datapoints

1. Open your project and go to **Data Inputs > Input Settings**.
2. Add a new event type (e.g., name: "Biochar Delivery", slug: `biochar-delivery`).
3. Add 3-5 datapoint types:

| Datapoint             | Value Type    |
| --------------------- | ------------- |
| Delivery date         | date/datetime |
| Biochar mass (tonnes) | number        |
| Carbon content (%)    | number        |
| Delivery ticket ID    | text          |

Define each with a clear slug so they can be referenced in the model. See <a href="/production-accounting/data-inputs" target="_blank" rel="noopener noreferrer">configuring event types</a>

and [Lesson 1.3: Events and Datapoints](/accounting-academy/module-1/1-3-events-and-datapoints).

### Step 2: Create a simple model

1. Open the **Models** section and the **Model Editor** (click **Edit/Test** next to the model). See <a href="/production-accounting/models" target="_blank" rel="noopener noreferrer">building accounting models</a>

   .
2. Build a minimal tree:
   * **Input nodes** — reference the slugs for biochar mass and carbon content
   * **Constant node** — value 3.67 (CO2-to-carbon mass ratio)
   * **Output node** — `operator: product`, `data_point_type: carbon-delivered-tco2e`

<Note>
  If carbon content is stored as a percentage (0-100), include a division by 100 in the formula or an intermediate node.
</Note>

3. **Validate** the model in the Console and save. Ensure the output datapoint slug matches what the batch type expects.

### Step 3: Generate batches

The starter project already has the ledger and batch type configured. You only need to run the dataflow.

1. Go to **Production Accounting** and use <a href="/production-accounting/generate-batches" target="_blank" rel="noopener noreferrer">Generate Batches</a>

   .
2. Choose an accounting period that includes your test event's date.
3. Validate that required datapoints are present, then **Submit**.

### Step 4: Test end-to-end

<Steps>
  <Step title="Create a sample event">
    Go to **Data Inputs** and <a href="/data-collection/add-data" target="_blank" rel="noopener noreferrer">add an event directly</a>

    . Select **Biochar Delivery**, set the date range, and fill in your datapoints (e.g., mass = 10 t, carbon content = 80%). Optionally add a Tracking ID and <a href="/data-collection/add-data" target="_blank" rel="noopener noreferrer">evidence</a>

    .
  </Step>

  <Step title="Generate batches">
    Trigger batch generation for a period including your test event. Resolve any validation messages. If validations show missing data, try adjusting the datetime range or using the **show time** option per <a href="/production-accounting/generate-batches" target="_blank" rel="noopener noreferrer">Generate batches</a>

    .
  </Step>

  <Step title="Verify the output">
    Check that the batch shows the expected result:

    `10 × 0.80 × 3.67 ≈ 29.36 tCO2e`
  </Step>
</Steps>

<Warning>
  If results don't match, double-check: event type slugs vs. model `data_point_type` slugs, units (% vs. fraction), and that the model output slug matches what the batch type expects.
</Warning>

***

## Success criteria

You have completed the Module 1 exercise when:

* **One event type** exists (e.g., Biochar Delivery) with 3-5 datapoints in **Data Inputs > Input Settings**
* **One simple model** reads your event's datapoints and computes **carbon delivered** (e.g. `mass × carbon_content × 3.67`)
* **Batches generated** — you ran **Generate Batches** and a batch was created for your test event
* **End-to-end test** — the batch shows the expected calculated output (e.g. \~29.36 tCO2e for 10 t at 80% carbon content)

***

## What's next

Module 2 (Calculations) is coming soon — you'll expand this with more event types and multi-step calculations. In the meantime, you can jump ahead to [Module 4: Mass Balance with Ledgers](/accounting-academy/module-4/4-1-intro-to-mass-balance) to learn about ledger structures and mass balance accounting.
