Example Repository
In this walkthrough, we will spin up a simulated Payment Service stack that includes: - Python application code - Terraform infrastructure definitions - Kubernetes manifests
You will see how jnkn stitches these disparate files together into a single dependency graph.
1. Setup the Demo
You don't need to clone anything. Jnkn includes a built-in demo generator.
Create a temporary directory and initialize the demo:
mkdir try-jnkn
cd try-jnkn
# This downloads the example structure and configures Jnkn
jnkn init --demo
````
You should see:
```text
π Created demo project at: .../try-jnkn/jnkn-demo
β¨ Initialized successfully!
Navigate into the generated project:
2. The Architecture
Before we scan, let's look at the "trap" waiting in this codebase.
-
The Code (
src/app.py): The Python app crashes if it can't connect to the database. It expects an environment variable namedPAYMENT_DB_HOST. -
The Infrastructure (
terraform/main.tf): Terraform provisions an RDS instance and outputs its address aspayment_db_host. -
The Glue (
k8s/deployment.yaml): Kubernetes injects the secret into the container.
The Problem: There are no explicit imports connecting Terraform to Python. If you rename the Terraform output, terraform plan will pass, but the Python app will crash in production.
3. Run the Scan
Let's see if Jnkn can find these hidden connections.
Output:
π Scanning .../try-jnkn/jnkn-demo
Parsers loaded: python, terraform, kubernetes
Files found: 3
β
Scan complete
Nodes: 7
Edges: 7
Saved: .jnkn/lineage.json
Jnkn has parsed the files, tokenized the variable names (e.g., PAYMENT_DB_HOST β [payment, db, host]), and stitched them together based on matching patterns.
4. Analyze Blast Radius
Now, imagine you are the Infrastructure Engineer. You want to refactor the Terraform code.
Question: "What happens if I change the payment_db_host output?"
Run a blast radius check:
You will see exactly what breaks downstream:
π₯ Blast Radius Analysis
ββββββββββββββββββββββββ
Source: infra:output.payment_db_host
βΈοΈ Kubernetes (1)
β’ k8s:default/deployment/payment-service
π Python Code (1)
β’ src/app.py (Confidence: High)
Result: You instantly see that changing Terraform impacts both the Kubernetes deployment configuration and the Python application code.
5. Visualize the Graph
For a high-level view of your architecture, generate an interactive HTML graph.
Open my-stack.html in your browser:
- Zoom in to see the nodes.
- Click on
infra:aws_db_instance.payment_db. - Follow the arrows to see how data flows from Infrastructure β Config β Code.
This visual proof is excellent for explaining architectural dependencies to new team members or during architectural reviews.
6. Cleanup
When you are done, simply remove the directory:
Next Steps
Now that you've seen it work in a perfect environment, try it on your real code.