# Docker Compose to Mermaid diagram

Convert docker-compose.yml into Mermaid flowchart text showing services, dependencies, ports, volumes, and networks.

## Run it

- **CLI:** `gizza tool compose-to-diagram "services:
  web:
    image: nginx
    depends_on:
      - api"`
- **Web:** https://gizza.ai/tools/compose-to-diagram/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/compose-to-diagram/tool.json

## Inputs

- `compose` — Compose YAML _(field)_
- `direction` — Direction _(field)_
- `networks` — Networks _(field)_
- `ports` — Show ports _(field)_
- `volumes` — Show volumes _(field)_
- `labels` — Service labels _(field)_
- `profile` — Profile filter _(field)_
- `styled` — Emit Mermaid styles _(field)_
- `title` — Diagram title _(field)_
- `output` — Output _(field)_

## Output

- Diagram output (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `compose` — Compose YAML
- `direction` — Direction
- `networks` — Networks
- `ports` — Show ports
- `volumes` — Show volumes
- `labels` — Service labels
- `profile` — Profile filter
- `styled` — Emit Mermaid styles
- `title` — Diagram title
- `output` — Output

Example: `https://gizza.ai/tools/compose-to-diagram/?compose=services%3A%0A%20%20web%3A%0A%20%20%20%20image%3A%20nginx%0A%20%20%20%20depends_on%3A%0A%20%20%20%20%20%20-%20api&direction=TD&networks=subgraph&ports=true&volumes=true&labels=image&profile=debug&styled=true&title=Checkout%20stack&output=mermaid`

---

## About this tool

Convert a `docker-compose.yml` or `compose.yaml` file into Mermaid flowchart text.
The parser reads the parts that describe architecture — services, `image` or
`build`, `depends_on`, `links`, `network_mode: service:...`, ports, volumes,
networks, profiles, restart policy, and replica counts — and ignores runtime
details such as commands and environment values.

Use raw Mermaid output for Mermaid Live, GitHub Markdown, Notion, and IDE preview
plugins. Use Markdown output when you want a ready-to-paste fenced code block.
Use Summary output for a text audit of services, dependencies, duplicate host
ports, unused declarations, and circular dependency chains.

Worked example:

1. Paste a Compose file with `web`, `api`, and `db` services.
2. Set direction to `LR` for a left-to-right architecture view.
3. Leave networks as subgraphs and keep ports/volumes enabled.
4. Copy the Mermaid flowchart into your README or diagram previewer.

Limits and edge cases: this tool accepts YAML up to 2 MB and up to 500 services.
It does not run Docker, pull images, read `.env`, resolve includes, or inspect
external compose files referenced by `extends.file`; those references are reported
as warnings in the summary.

## FAQ

<details>
<summary>Does this execute my Compose file?</summary>

No. The tool only parses YAML text and renders a diagram. It does not contact
Docker, fetch images, interpolate `.env`, or run any service commands.

</details>

<details>
<summary>Which dependency forms are shown?</summary>

Both `depends_on: [db]` and the long map form with `condition:` are supported.
The tool also draws `links`, `network_mode: service:name`, and same-file
`extends` relationships so hidden service coupling is visible.

</details>

<details>
<summary>How should I show shared networks?</summary>

Use `subgraph` for the common case where each service mostly belongs to one
network. Use `node` when services join many networks and you want every network
drawn as a separate node. Use `off` for a dependency-only diagram.

</details>

<details>
<summary>Can I use the output directly in a README?</summary>

Yes. Choose `markdown` output for a ready-to-paste fenced `mermaid` block, or
choose raw `mermaid` output if your documentation system already provides the
fence.

</details>

## Related tools

- [Mermaid from data](https://gizza.ai/tools/mermaid-from-data/): Turn structured node and edge rows into Mermaid flowchart, classDiagram or erDiagram source with labels, shapes and relationship styles.
- [Import & Dependency Graph Extractor](https://gizza.ai/tools/import-graph-extractor/): Paste JS, Python, Rust, or Go source and get an import graph with file edges, external deps, dependents, orphans, leaves, and cycles.
- [Apply a Unified Diff to a File](https://gizza.ai/tools/apply-patch/): Paste a file and a unified diff to get the patched text in your browser, with reverse apply, fuzz matching, and per-hunk conflict reports.
- [Autocomplete Trie](https://gizza.ai/tools/autocomplete-trie/): Build a prefix trie from a pasted wordlist and get ranked autocomplete suggestions for any typed prefix. Weights, typo tolerance, trie stats, JSON. Runs locally.
- [Code Chunker](https://gizza.ai/tools/code-chunker/): Split Python, Rust, JavaScript, TypeScript, Go, Java, C/C++, C#, PHP, or Swift into line-ranged chunks that keep functions and classes intact.
