---
title: "Draw the data flows and their trust · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/threat-modelling/data-flow-diagram
id: APS-93
level: Recommended
updated: 2026-10-27
build: a2a6bdfed830
tokens: 897
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Draw the data flows and their trust boundaries

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Threat modelling](https://agentwranglers.se/playbook/application-security/threat-modelling.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-93
- Level: Recommended
- Chapter: [Threat modelling](https://agentwranglers.se/playbook/application-security/threat-modelling.md)
- Rule: Keep a data-flow diagram for each app in the repository. It shows every process, data store, outside party and flow, and a line wherever trust changes.
- Check: A CI job fails a pull request that adds an outbound host, a queue or a data store but leaves the diagram file unchanged. Every flow in the diagram that crosses a boundary has a number and a named kind of data.
- How: A trust boundary is any place where data passes between parties that trust each other differently. Examples are the browser and the server, the app and a payment provider, or a public API and an internal queue. Draw the diagram as text, such as Mermaid or a threat modelling tool's file, so it changes in the same pull request as the code. Give each flow a number and name the data it carries, such as card tokens or session cookies. Every flow that crosses a boundary is where input is checked, as [Find threats at every boundary with STRIDE and LINDDUN](https://agentwranglers.se/playbook/application-security/threat-modelling/stride-and-linddun.md) describes. The threat model in [Plan attacks before building](https://agentwranglers.se/playbook/application-security/threat-modelling/threat-model.md) starts from this diagram.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Mermaid example

```mermaid
flowchart LR
  subgraph Internet
    B[Browser]
  end
  subgraph App["App servers (boundary 1)"]
    W[Web app] --> Q[(Order queue)]
  end
  subgraph Provider["Payment provider (boundary 2)"]
    P[Hosted checkout]
  end
  B -- "1: session cookie, order form" --> W
  W -- "2: order ID, amount" --> P
  P -- "3: signed webhook" --> W
```

## Sources

- [OWASP Threat Modeling Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Threat_Modeling_Cheat_Sheet.html)

## Related rules

- APS-1 [Plan attacks before building](https://agentwranglers.se/playbook/application-security/threat-modelling/threat-model.md) in Application security
- APS-94 [Find threats at every boundary with STRIDE and LINDDUN](https://agentwranglers.se/playbook/application-security/threat-modelling/stride-and-linddun.md) in Application security

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/application-security/threat-modelling/data-flow-diagram">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Plan attacks before building](https://agentwranglers.se/playbook/application-security/threat-modelling/threat-model.md)
- Next: [Find threats at every boundary with STRIDE and LINDDUN](https://agentwranglers.se/playbook/application-security/threat-modelling/stride-and-linddun.md)
- [Threat modelling](https://agentwranglers.se/playbook/application-security/threat-modelling.md)
