Skip to main content

Commandline tool to generate data flow diagrams from text

Project description

DFD — Data Flow Diagrams as Code

CI PyPI version License: GPL v3 Python 3.11+

Describe system architectures as text, get diagrams as SVG, PNG, PDF, and more. Version-controlled, diffable, no GUI needed.

DFD generates Data Flow Diagrams from a simple text-based DSL, rendered via Graphviz. It supports the SA/SD and SA/RT methodologies (Structured Analysis / Structured Design, with real-time extensions) as described by Edward Yourdon.

Complete example

The diagram above is generated from this input:

process   Acquire   Acquire data
process   Compute
control   Control
entity    Device
store     Config    Configuration
channel   API

*         ::>  Control    clock
Control   <::  *          enable
Control   <::  *          disable
Control   ::>? Acquire    sampling

Device    ->>  Acquire    continuous raw data
Acquire   -->  Compute    raw records
Config    <->  Compute    parameters
Compute   -->  API        records

Features

Feature Description
SA/RT support Signals, control processes, and channels for real-time and embedded systems
Context diagrams Generate a top-level SA/SD context diagram (style context)
Frames and grouping Visually group related items
Filters Render focused subsets of a large master diagram (neighborhood, only/without)
Dependency checking Verify that all referenced includes and items are consistent
Includes and reuse Split large diagrams across files, share common item definitions via include
Markdown embedding Embed diagrams directly in Markdown files and generate all images in one pass (--markdown mode)
Layout control Horizontal or vertical orientation, placement constraints between items, relaxed constraints on connections
Styling Background color, graph title suppression, inline Graphviz attributes, reusable attribute aliases
Multiple output formats SVG, PNG, PDF, JPG, EPS, and any other format supported by your Graphviz installation (run dot -Thelp for the full list), plus raw DOT source

Quick start

pip install data-flow-diagram

Create a file hello.dfd:

entity    User
process   App
store     DB

User --> App    request
App  --> DB     query
DB   --> App    result
App  --> User   response

Generate the diagram:

data-flow-diagram hello.dfd -o hello.svg --no-graph-title

You should obtain:

Quick start result

Or pipe directly from stdin:

echo 'entity User
process App
User --> App  request' | data-flow-diagram -o quick.svg --no-graph-title

Stdin pipe result

Installing

For users

Requires Python 3.11+ and Graphviz.

Linux (Debian/Ubuntu):

sudo apt install graphviz
pip install data-flow-diagram

macOS (Homebrew):

brew install graphviz python3
pip install data-flow-diagram

If you get a ModuleNotFoundError: No module named 'reportlab.graphics._renderPM' error at runtime, reinstall reportlab:

pip install --upgrade --force-reinstall reportlab

For developers

Requires GNU Make (pre-installed on most Linux distributions; on macOS, install the Xcode Command Line Tools if not already present: xcode-select --install).

git clone https://github.com/pbauermeister/dfd.git
cd dfd
make all    # creates venv, installs deps, formats, lints, tests, builds docs

make all auto-detects your OS and installs the required system packages (Debian apt or macOS brew). Run make help for all available targets.

Documentation

Full syntax reference, examples, and advanced features:

Usage

data-flow-diagram -h says:

usage: data-flow-diagram [-h] [--output-file OUTPUT_FILE] [--markdown]
                         [--format FORMAT]
                         [--background-color BACKGROUND_COLOR]
                         [--no-graph-title] [--no-check-dependencies]
                         [--debug] [--version]
                         [INPUT_FILE]

Command-line DFD diagram generator. Converts a textual description into a
graphic file.

positional arguments:
  INPUT_FILE            DFD input file; if omitted, stdin is used

options:
  -h, --help            show this help message and exit
  --output-file OUTPUT_FILE, -o OUTPUT_FILE
                        output file name; pass '-' to use stdout; if omitted,
                        use INPUT_FILE base name with '.svg' extension, or
                        stdout
  --markdown, -m        consider snippets between opening marker: ```data-
                        flow-diagram OUTFILE, and closing marker: ``` allowing
                        to generate all diagrams contained in an INPUT_FILE
                        that is a markdown file
  --format FORMAT, -f FORMAT
                        output format: gif, jpg, tiff, bmp, pnm, eps, pdf, svg
                        (any supported by Graphviz), or dot (raw Graphviz DOT
                        text); default is svg
  --background-color BACKGROUND_COLOR, -b BACKGROUND_COLOR
                        background color name (including 'none' for
                        transparent) in web color notation; see
                        https://developer.mozilla.org/en-
                        US/docs/Web/CSS/color_value for a list of valid names;
                        default is white
  --no-graph-title      suppress graph title
  --no-check-dependencies
                        suppress dependencies checking
  --debug               emit debug messages
  --version, -V         print the version and exit

See https://github.com/pbauermeister/dfd for information, syntax and examples.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data_flow_diagram-1.16.7.post2.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

data_flow_diagram-1.16.7.post2-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file data_flow_diagram-1.16.7.post2.tar.gz.

File metadata

  • Download URL: data_flow_diagram-1.16.7.post2.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for data_flow_diagram-1.16.7.post2.tar.gz
Algorithm Hash digest
SHA256 352a80780a3b8f0ad421a027cae67f1d6ab0b9be0efe140e4f080cf1727aea2a
MD5 7dae870add81020cbec230349d7beb9e
BLAKE2b-256 c9d641cca5a830a5af547421a83037494942fe439113a41a118ab965e612e933

See more details on using hashes here.

File details

Details for the file data_flow_diagram-1.16.7.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for data_flow_diagram-1.16.7.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ce068a2cf9e1a50738defdcd3e215a933e1d6783fbd2800607b7a4b580f52a9
MD5 8ed43fa378b520453c7191a2a0da9277
BLAKE2b-256 32c302d8ead48def769b4f5f11441ecfc19f86e704840fc766a43e436f4f4f58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page