Generate beautiful ASCII and PNG flowcharts from simple text descriptions
Project description
RetroFlow
___________________________________________________________
| |
| _____ _ ______ _ |
| | __ \ | | | ____| | |
| | |__) |___| |_ _ __ ___ | |__ | | _____ __ |
| | _ // _ \ __| '__/ _ \| __| | |/ _ \ \ /\ / / |
| | | \ \ __/ |_| | | (_) | | | | (_) \ V V / |
| |_| \_\___|\__|_| \___/|_| |_|\___/ \_/\_/ |
| |
| [ Beautiful ASCII Flowcharts ] |
|___________________________________________________________|
|| ||
A Python library for generating beautiful ASCII and PNG flowcharts from simple text descriptions.
Overview
This is a project to help engineers, researchers, project managers, and others create beautiful, retro-looking ASCII flow diagrams. ASCII diagrams are pretty, and harken back to the mid-20th century technical documentation. They also have real advantages:
- They work wonderfully in the age of agentic AI, which can easily read and parse these small representations.
- ASCII diagrams can live inline with: PRs, Markdown files, Slack threads, etc.
- ASCII diagrams optimize for thinking speed, not presentation quality. It encourages iteration and deletion instead of premature refinement.
- Minimalist diagrams reduce visual noise (although they do still look retro and pretty)
- They're tool agnostic and can be rendered anywhere
┌─────────┐
│ START │░
└─────────┘░
░░░░░░░░░░░
│
▼
┌─────────┐
│ PROCESS │░
└─────────┘░
░░░░░░░░░░░
│
▼
┌─────────┐
│DECISION │░
└─────────┘░
░░░░░░░░░░░
│
▼
┌─────────┐
│ END │░
└─────────┘░
░░░░░░░░░░░
Installation
pip install retroflow
Or with uv:
uv add retroflow
Quick Start
from retroflow import FlowchartGenerator
# Create a generator
generator = FlowchartGenerator()
# Define your flowchart using simple arrow syntax
flowchart = generator.generate("""
Start -> Process
Process -> Decision
Decision -> End
""")
print(flowchart)
Features
- Simple syntax: Define flowcharts using intuitive
A -> Barrow notation - ASCII output: Generate text-based flowcharts for terminals and documentation
- Intelligent layout: Automatic node positioning using NetworkX with barycenter heuristic
- Cycle detection: Handles cyclic graphs gracefully with back-edge routing
- Customizable: Adjust text width, box sizes, spacing, and shadows
- Unicode box-drawing: Beautiful boxes with optional shadow effects
Usage
Basic Generation
from retroflow import FlowchartGenerator
generator = FlowchartGenerator()
# Simple linear flow
result = generator.generate("""
A -> B
B -> C
C -> D
""")
print(result)
Branching Flows
# Branching and merging
result = generator.generate("""
Start -> Validate
Validate -> Process
Validate -> Error
Process -> End
Error -> End
""")
print(result)
Cyclic Flows
# Loops and cycles are supported
result = generator.generate("""
Init -> Check
Check -> Process
Process -> Check
Check -> Done
""")
print(result)
Export to Text File
generator = FlowchartGenerator()
generator.save_txt("""
A -> B
B -> C
""", "flowchart.txt")
Configuration
FlowchartGenerator Options
generator = FlowchartGenerator(
max_text_width=22, # Max width for text inside boxes before wrapping (default: 22)
min_box_width=10, # Minimum box width (default: 10)
horizontal_spacing=12, # Space between boxes horizontally (default: 12)
vertical_spacing=6, # Space between boxes vertically (default: 6)
shadow=True # Whether to draw box shadows (default: True)
)
Input Format
The input format uses a simple arrow syntax:
# Comments start with #
NodeA -> NodeB
NodeB -> NodeC
# Node names can contain spaces
User Login -> Validate Credentials
Validate Credentials -> Access Granted
Rules
- Each line defines one connection:
Source -> Target - Node names are trimmed of whitespace
- Empty lines are ignored
- Lines starting with
#are comments - Node names can contain spaces
API Reference
FlowchartGenerator
The main class for generating flowcharts.
Methods
| Method | Description |
|---|---|
generate(input_text) |
Generate ASCII flowchart string |
save_txt(input_text, filename) |
Save flowchart to a text file |
Convenience Functions
from retroflow import parse_flowchart
# Parse without rendering
connections = parse_flowchart("A -> B\nB -> C")
# Returns: [('A', 'B'), ('B', 'C')]
Lower-Level API
For advanced use cases, you can access the individual components:
from retroflow import (
Parser,
SugiyamaLayout, # Alias for NetworkXLayout
Canvas,
BoxRenderer,
)
# Parse input
parser = Parser()
connections = parser.parse("A -> B\nB -> C")
# Compute layout
layout_engine = SugiyamaLayout()
layout_result = layout_engine.layout(connections)
# Access layout information
for node_name, node_layout in layout_result.nodes.items():
print(f"{node_name}: layer={node_layout.layer}, position={node_layout.position}")
Development
Setup
git clone https://github.com/ronikobrosly/retroflow.git
cd retroflow
uv sync --dev
Run Tests
uv run pytest
Run Linting
uvx ruff check .
uvx ruff format --check .
License
MIT License - see LICENSE for details.
Contributing
Contributions are 100% welcome! Please feel free to submit a PR.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file retroflow-0.3.0.tar.gz.
File metadata
- Download URL: retroflow-0.3.0.tar.gz
- Upload date:
- Size: 83.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6d5cdb7fcdfb958eaebd3b56f296621e1131c573fd96e29f34df50d27c86726
|
|
| MD5 |
78a4fa19e8a37d7f66856f2991a5318f
|
|
| BLAKE2b-256 |
1e2a49e88a230f2a3ab26b2752f68ba2392f6d5bf521e2085e54cf00d6e5aa62
|
File details
Details for the file retroflow-0.3.0-py3-none-any.whl.
File metadata
- Download URL: retroflow-0.3.0-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcfa8f97542706351131a59cc444f4f765d8cbe58551dc1a332774a9099f2a44
|
|
| MD5 |
ebe0e5560f6292bd1335f4f12813bc27
|
|
| BLAKE2b-256 |
165375141229fde9344da2fdae6c6ace49a98bd1c1ae29dda74c4750620ae65c
|