How hlung/swiftflow works
What this project is (type + purpose)
So your “system” is not a distributed system; it’s a library architecture with:
• Public API layer (models + GraphView)
• Layout engine (constraints for node placement)
• UIKit view composition (NodeView, Label, GraphView)
• Tests (basic package tests)
How the repository structure maps to architecture
From the file tree:
Package / build / CI
• Package.swift — Swift Package Manager manifest; define module(s), platforms, dependencies.
• .github/workflows/swift.yml — CI pipeline (build/test).
Library code
Sources/SwiftFlow/
• Models/
• Layout/drawing supporting structs: ArrowDrawingPlan.swift, EdgeOffsets.swift
• Enums: Direction, NodeShape, GraphDrawError
• Views/
• NodeView.swift, Label.swift — UIKit subviews for nodes/labels
• UIKit+Direction.swift — direction helpers, geometry utilities
Tests
• Tests/SwiftFlowTests/SwiftFlowTests.swift — unit tests (likely model/layout sanity).
This strongly suggests a Model → View rendering architecture with a small “layout engine” embedded inside GraphView/supporting model structs.
The README states:
• Users define flows via graph.addFlow([GraphElement])
• Layout is done with Auto Layout for nodes
This implies two distinct phases:
Consumer / Client App
• Example usage code calls into SwiftFlow.
SwiftFlow Public API (Models)
• Graph
• GraphElement protocol
• Node, NodeShortcut
• NodeConfig, ArrowConfig
• Enums: Direction, NodeShape
• Errors: GraphDrawError
Graph Construction / Resolution
• Flow arrays ingestion: Graph.addFlow([GraphElement])
• ID registry / reference resolution: NodeShortcut(id:) → existing Node
View Layer (UIKit)
• GraphView (container view, orchestrator)
Output
• Rendered UIView hierarchy on screen (Simulator/iPad simulator per README)
• SwiftUI Preview integration (README mentions UIViewRepresentable wrapper; not in repo, but note as external usage pattern).
Graph stores
• Flow sequences
• Node registry by id
GraphView
• builds NodeView + Label for each Node
• applies Auto Layout constraints (Layout Engine)
GraphView reads node frames → creates ArrowDrawingPlan
• “Before layout: constraints”
Architectural patterns / principles to highlight
• Declarative DSL-ish input: flows as [GraphElement]
• Two-phase rendering pipeline:
• Phase 1: Auto Layout for nodes
• Reference resolution: NodeShortcut uses id to avoid node duplication
• Separation of concerns:
• Views/paths describe *how* to render
As small tags on components:
• Swift Package Manager (Package.swift)
• UIKit (UIView, NSLayoutConstraint)
• CoreGraphics/UIBezierPath
• SwiftUI Preview (external wrapper usage, optional)
• CI (GitHub Actions)
Of the following:
• Clear labels: use the *actual type/file names* where possible (GraphView, Graph, NodeView, ArrowDrawingPlan).
• External = gray (Client App, UIKit runtime, SwiftUI wrapper)
“Don’t overthink it”: split into as many components as possible (but still coherent)
• Under Views: GraphView, NodeView, Label