# Keep BPMN process diagrams next to the code and read them in FACET Atlas

> Keep the BPMN source of a process diagram in the repository next to the code, read and walk it in FACET Atlas, and change process and code in the same pull request.

Source: https://facet-framework.com/en/guides/process-diagram-next-to-the-code/  
Last updated: 2026-11-26T23:33:14+01:00

A new support lead asks how a refund request is handled. Someone remembers a process diagram and finds it as a PNG attached to a ticket from 2022. It shows a 14-day window and a manual approval step. The code has said 30 days for a while, and the approval step was never built. The diagram's source file is on the laptop of someone who has since left.

FACET keeps a short, checkable description of each feature, called a record, next to your code, and FACET Atlas is the browser app that shows those records and the process diagrams beside them. By the end of this guide the diagram's source lives in the repository, next to the code it describes, and everyone on the team reads it in FACET Atlas without a modelling tool: the drawing, its paths from start to end, and a step-by-step walkthrough. A change to the process and the matching code change then go through the same pull request.

The commands below use a small example shop written in TypeScript, set up as in [“One answer instead of three”](https://facet-framework.com/en/guides/write-down-what-a-feature-does/). In your own project, use a BPMN diagram your team already has.

## Put the diagram's source into the repository

Atlas reads BPMN 2.0 XML, the `.bpmn` file that Camunda Modeler, bpmn.io and most other BPMN tools save. An exported PNG or PDF is a picture of the process; the `.bpmn` file is the process. Atlas looks for these files in `docs/bpmn/`:

```sh
mkdir -p docs/bpmn
```

Save your diagram there. To follow along with the example shop, save this as `docs/bpmn/refund-request.bpmn`:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
  xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
  xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
  id="Defs_Refund" name="Refund request" targetNamespace="http://demo-shop.example/bpmn">
  <bpmn:process id="Proc_Refund" name="Refund request" isExecutable="false">
    <bpmn:startEvent id="Start_Request" name="Customer asks for a refund" />
    <bpmn:exclusiveGateway id="GW_Window" name="Within 30 days of delivery?" />
    <bpmn:endEvent id="End_Refused" name="Refused with E3001" />
    <bpmn:exclusiveGateway id="GW_Payment" name="Paid with a gift card?" />
    <bpmn:serviceTask id="Task_Card" name="Refund to the original payment" />
    <bpmn:serviceTask id="Task_Credit" name="Refund as store credit" />
    <bpmn:endEvent id="End_Refunded" name="Refund issued" />
    <bpmn:sequenceFlow id="SF_1" sourceRef="Start_Request" targetRef="GW_Window" />
    <bpmn:sequenceFlow id="SF_No" name="no" sourceRef="GW_Window" targetRef="End_Refused" />
    <bpmn:sequenceFlow id="SF_Yes" name="yes" sourceRef="GW_Window" targetRef="GW_Payment" />
    <bpmn:sequenceFlow id="SF_Card" name="no" sourceRef="GW_Payment" targetRef="Task_Card" />
    <bpmn:sequenceFlow id="SF_Gift" name="yes" sourceRef="GW_Payment" targetRef="Task_Credit" />
    <bpmn:sequenceFlow id="SF_2" sourceRef="Task_Card" targetRef="End_Refunded" />
    <bpmn:sequenceFlow id="SF_3" sourceRef="Task_Credit" targetRef="End_Refunded" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="Diag_Refund" name="Refund request">
    <bpmndi:BPMNPlane id="Plane_Refund" bpmnElement="Proc_Refund">
      <bpmndi:BPMNShape id="Start_Request_di" bpmnElement="Start_Request"><dc:Bounds x="100" y="142" width="36" height="36" />
        <bpmndi:BPMNLabel><dc:Bounds x="76" y="185" width="84" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="GW_Window_di" bpmnElement="GW_Window" isMarkerVisible="true"><dc:Bounds x="200" y="135" width="50" height="50" />
        <bpmndi:BPMNLabel><dc:Bounds x="180" y="95" width="90" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="End_Refused_di" bpmnElement="End_Refused"><dc:Bounds x="207" y="282" width="36" height="36" />
        <bpmndi:BPMNLabel><dc:Bounds x="180" y="325" width="90" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="GW_Payment_di" bpmnElement="GW_Payment" isMarkerVisible="true"><dc:Bounds x="320" y="135" width="50" height="50" />
        <bpmndi:BPMNLabel><dc:Bounds x="300" y="95" width="90" height="27" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_Card_di" bpmnElement="Task_Card"><dc:Bounds x="440" y="60" width="120" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_Credit_di" bpmnElement="Task_Credit"><dc:Bounds x="440" y="200" width="120" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="End_Refunded_di" bpmnElement="End_Refunded"><dc:Bounds x="632" y="142" width="36" height="36" />
        <bpmndi:BPMNLabel><dc:Bounds x="612" y="185" width="76" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SF_1_di" bpmnElement="SF_1"><di:waypoint x="136" y="160" /><di:waypoint x="200" y="160" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SF_No_di" bpmnElement="SF_No"><di:waypoint x="225" y="185" /><di:waypoint x="225" y="282" />
        <bpmndi:BPMNLabel><dc:Bounds x="232" y="225" width="14" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SF_Yes_di" bpmnElement="SF_Yes"><di:waypoint x="250" y="160" /><di:waypoint x="320" y="160" />
        <bpmndi:BPMNLabel><dc:Bounds x="275" y="142" width="18" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SF_Card_di" bpmnElement="SF_Card"><di:waypoint x="370" y="160" /><di:waypoint x="400" y="160" /><di:waypoint x="400" y="100" /><di:waypoint x="440" y="100" />
        <bpmndi:BPMNLabel><dc:Bounds x="410" y="82" width="14" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SF_Gift_di" bpmnElement="SF_Gift"><di:waypoint x="370" y="160" /><di:waypoint x="400" y="160" /><di:waypoint x="400" y="240" /><di:waypoint x="440" y="240" />
        <bpmndi:BPMNLabel><dc:Bounds x="410" y="222" width="18" height="14" /></bpmndi:BPMNLabel></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SF_2_di" bpmnElement="SF_2"><di:waypoint x="560" y="100" /><di:waypoint x="600" y="100" /><di:waypoint x="600" y="160" /><di:waypoint x="632" y="160" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SF_3_di" bpmnElement="SF_3"><di:waypoint x="560" y="240" /><di:waypoint x="600" y="240" /><di:waypoint x="600" y="160" /><di:waypoint x="632" y="160" /></bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
```

The `BPMNDiagram` part holds the positions your modelling tool saved. Atlas draws the diagram from them, so keep that part when you export.

## Download Atlas with npx

Atlas is FACET's reader in the browser. The npm package `facet-framework` downloads and starts it. In the shop's folder, run it once:

```sh
npx facet-framework ui
```

The first run names the Atlas archive for your system, its size and the cache folder, and asks `Download and start? [y/N]`. Answer `y`. The archive is checked against the SHA-256 pinned in FACET Core and contains Atlas and the helper that reads BPMN files. Stop it with Ctrl-C; the next step starts it again, without the question.

## Open the diagram in Atlas

In the shop's folder, start Atlas again:

```sh
npx facet-framework ui
```

```console
$ npx facet-framework ui
FACET Atlas: http://127.0.0.1:7317/
Reading:     /path/to/demo-shop
Stop with Ctrl-C.
```

Open the printed address in your browser. If port 7317 is taken, Atlas picks another one and prints that. Click **Processes** in the top navigation. The overview shows one card per BPMN file and `0 of 1 files have parser findings`. Click **Refund request**.

![FACET Atlas, Processes area: the refund request diagram from refund-request.bpmn with a start event, two decisions (within 30 days of delivery, paid with a gift card), two refund tasks and two end events; above it the counts 7 elements, 7 flows, 0 lanes, 3 paths start to end, longest path 5.](https://facet-framework.com/guides/process-diagram-next-to-the-code/process-diagram-light.png)

*The diagram, drawn from the .bpmn file in the repository.*

Above the drawing, Atlas counts the elements, the flows and the paths from start to end. Three paths here: refused, refunded to the card, refunded as store credit.

## Walk each path and compare it with the code

Click **Walkthrough**, then **Next step** (the arrow at the top of the panel). At each decision, choose a branch. Choose **yes → Paid with a gift card?** and then **yes → Refund as store credit**:

![FACET Atlas walkthrough of the refund request, step 4 of 5: the path from the start through within 30 days of delivery (yes) and paid with a gift card (yes) to refund as store credit is highlighted; the panel lists the four steps taken.](https://facet-framework.com/guides/process-diagram-next-to-the-code/process-walkthrough-light.png)

*One path at a time: the panel lists every step taken.*

Walk each of the three paths and hold it against the code that implements it. In the example shop that is `src/orders/refund.ts`: a refund later than `REFUND_WINDOW_DAYS = 30` after delivery fails with `E3001`, and an order paid with a gift card gets its money back as `store_credit`. Diagram and code agree. Where they do not, decide which one is right and fix the other in the same pull request.

## Change process and code in one pull request

From now on the diagram changes the way the code does. When the refund window changes, the pull request changes `REFUND_WINDOW_DAYS`, the gateway label in `refund-request.bpmn` and, if the feature has one, its FACET record, and the reviewer sees them together. Commit the diagram:

```sh
git add docs/bpmn/refund-request.bpmn
git commit -m "Add the refund request process as BPMN"
```

Atlas reads the repository again on every page reload, so an edited `.bpmn` file shows up without a restart. If your diagrams live in another folder, set it in `.facetrc.yaml` at the repository root:

```yaml
bpmn:
  directory: process
```

> **What this does not do**
>
> Atlas draws and walks a BPMN diagram; it does not connect it to records or code. Clicking a shape shows its type and
> flows and `Linked records · 0`. Nothing checks that diagram and code agree: that comparison is the walkthrough in step
> 4, done by a person.

## If Atlas shows something else

- **`No process file` and `There is no .bpmn file under docs/bpmn.`:** the file is somewhere else or has another extension. Move it to `docs/bpmn/`, or set `bpmn.directory` in `.facetrc.yaml` as in step 5.
- **`These files could not be read`, with your file name below the cards:** the file is not complete BPMN XML. Export it again from your modelling tool as `.bpmn`, not as an image.
- **`facet: unknown command "ui" for "facet"`:** npm ran an older `facet-framework` from the project's dependencies. Update it with `npm install --save-dev facet-framework@latest`.
- **`Atlas archive SHA-256 mismatch`:** the download is incomplete or altered, and nothing was put into the cache. Run the command again to download it anew.

For more on documentation that stays next to the code instead of going stale elsewhere, read [The help article says 14 days. The code says 30.](https://facet-framework.com/en/solutions/living-documentation/)

### Sources

- [FACET Atlas on GitHub](https://github.com/facet-framework/atlas#readme)
- [FACET Atlas releases](https://github.com/facet-framework/atlas/releases)
- [BPMN 2.0 specification (OMG)](https://www.omg.org/spec/BPMN/2.0/)
