Implement Flow Funding V2: Continuous flow dynamics with progressive outflow
This commit adds a complete v2 implementation of the flow funding mechanism
with continuous flow dynamics, progressive outflow zones, and real-time
interactive visualization.
## V2 Implementation (New - Today's Work)
### Core Engine (/lib/flow-v2/)
- types.ts: Flow-oriented type system with FlowNode, FlowNetwork, FlowZone
- engine-v2.ts: Steady-state equilibrium solver with progressive outflow
- Progressive zones: deficit (keep all), building (progressive share), capacity (redirect excess)
- Iterative convergence algorithm
- Dual time scale: per-second implementation, per-month UI
- scenarios-v2.ts: 5 preset networks demonstrating various topologies
### Interactive UI (/app/flow-v2/)
- Real-time external inflow sliders (0-$2000/mo per node)
- Dynamic edge width visualization based on flow rate (logarithmic scaling)
- Animated flow particles showing money movement (60 FPS)
- Zone-based node coloring: red (deficit), amber (building), green (capacity)
- Network overflow node (pure sink for unallocatable overflow)
- Comprehensive metrics: per-node and network-level statistics
- Play/pause animation controls
- Click-to-select node highlighting
### Key Features
- Progressive outflow formula implementing the water metaphor:
* Deficit: outflow = 0
* Building: outflow = inflow × ((inflow - min) / (max - min))
* Capacity: outflow = inflow - max
- Steady-state convergence typically in 10-50 iterations
- Fully isolated implementation - no impact on existing routes
## V1 Implementation (Previous Session)
### Core Engine (/lib/flow-funding/)
- Discrete distribution algorithm with phases:
* Initial distribution (prioritize minimums, fill capacity)
* Overflow calculation and redistribution
* Iterative convergence
- Network validation
- 5 preset scenarios
### UI Components
- /app/flowfunding/: Interactive v1 demo with animations
- /app/tbff/: Alternative visualization
- Timeline with time-travel
- Targeted funding mode (click-to-fund)
- Flow particle animations
## Routes
- /flow-v2: V2 continuous flow dynamics demo (NEW)
- /flowfunding: V1 discrete distribution demo
- /tbff: Alternative v1 visualization
All implementations are self-contained and don't affect other parts of the system.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>