Build hierarchical recipe dependency graphs for Factorio: machines, throughput, and raw-resource totals from a target item and rate.
Project description
factorio-recipe-graph
A Python library that answers the question:
"If I want to produce N items per second of X, exactly how many machines, furnaces, and raw resources do I need — all the way down?"
Given a target item and desired production rate, it resolves the full ingredient tree to primitive (raw) inputs, annotating each step with machine counts, throughput rates, and transport requirements.
from factorio_recipe_graph.graph import GraphBuilder
builder = GraphBuilder.from_base_recipes()
graph = builder.build("electronic-circuit", rate=10.0)
root = graph.nodes[graph.root_node_id]
print(f"{root.label}: {root.machine_count} × {root.machine.name}")
# electronic-circuit: 7 × assembling-machine-2
Installation
git clone https://github.com/lorencarvalho/factorio-recipe-graph
cd factorio-recipe-graph
uv sync --dev
Requires Python 3.11+ and uv.
What you get
- Recursive dependency resolution down to raw resources (
iron-ore,copper-ore,crude-oil, etc.) — no hand-rolled chains needed. - Exact rate math for machine counts, ingredient demand, and belt / inserter throughput, with both ceiling (machines to build) and exact (fractional, for downstream demand) outputs.
- Memoized subgraphs so shared dependencies (e.g. copper cable feeding multiple recipes) are computed once per build.
- Lossless JSON serialization for downstream visualization tooling.
- Curated dataset covering 45+ vanilla Factorio recipes shipped under
src/factorio_recipe_graph/data/.
See the docs for the full API, worked examples, and the data-pipeline regeneration workflow.
Data pipeline
The bundled base_recipes.json is generated from raw recipes.json and
entities.json exports. To regenerate it:
uv run python scripts/build_base_recipes.py
The script is idempotent — running it multiple times produces byte-identical output. See docs/data_pipeline.md for details.
Development
uv run ruff check # lint
uv run ruff format --check # formatting
uv run ty check # types
uv run pytest # tests
CI runs all four on every push and pull request.
Limitations
- Vanilla base game only — no mods, no Space Age expansion mechanics.
- No modules, beacons, or productivity bonuses. Rate math assumes raw machine speed.
- No bot or train logistics. Transport calculations cover belts, inserters, pipes, and pumps only.
- No quality tiers.
Contributing
ruff check, ruff format --check, ty check, and pytest must all
pass before merge.
License
MIT — see LICENSE.
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 factorio_recipe_graph-0.1.0.tar.gz.
File metadata
- Download URL: factorio_recipe_graph-0.1.0.tar.gz
- Upload date:
- Size: 75.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10a26ed58e574579a3f336cc0dfb4624769c465a64eea577750cfc6b1c5ebb94
|
|
| MD5 |
e0f7138f6f17c0d6155c978dbe9127ec
|
|
| BLAKE2b-256 |
9ee8911a22caee1a7b7e11fbb8cb79778ae9f413d3aaff69ec7efbc42b0080fb
|
Provenance
The following attestation bundles were made for factorio_recipe_graph-0.1.0.tar.gz:
Publisher:
publish.yml on lorencarvalho/factorio-recipe-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
factorio_recipe_graph-0.1.0.tar.gz -
Subject digest:
10a26ed58e574579a3f336cc0dfb4624769c465a64eea577750cfc6b1c5ebb94 - Sigstore transparency entry: 1395932052
- Sigstore integration time:
-
Permalink:
lorencarvalho/factorio-recipe-graph@14ddb6399a27b07c60c29b39aca79974220736d9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/lorencarvalho
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@14ddb6399a27b07c60c29b39aca79974220736d9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file factorio_recipe_graph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: factorio_recipe_graph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa2966db968a0f634e3f2df5c765560a897b6d101d464497fedf35b43559381b
|
|
| MD5 |
9fa0c816a486d8af7f1c35f4bf3ba75b
|
|
| BLAKE2b-256 |
7b5d497127ad2be9b081ebe58b6f1099700e0e846eab5d5177874940bb046f6e
|
Provenance
The following attestation bundles were made for factorio_recipe_graph-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on lorencarvalho/factorio-recipe-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
factorio_recipe_graph-0.1.0-py3-none-any.whl -
Subject digest:
fa2966db968a0f634e3f2df5c765560a897b6d101d464497fedf35b43559381b - Sigstore transparency entry: 1395932057
- Sigstore integration time:
-
Permalink:
lorencarvalho/factorio-recipe-graph@14ddb6399a27b07c60c29b39aca79974220736d9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/lorencarvalho
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@14ddb6399a27b07c60c29b39aca79974220736d9 -
Trigger Event:
release
-
Statement type: