vital_solver
Pure-Dart nutritional solver for the VITAL FlutterFlow app β extracted from 4 monolithic FlutterFlow custom code entities (applyQualityRulesBeforeSolver, macroOptimizerPQDynamicMaxAction, solveSingleMealWithTargets, buildRecipeCreationPreSolveReport) into a portable, testable library.
Status
π§ Work in progress β currently in Phase 1 (bootstrap). See the migration plan at ~/.claude/plans/ok-maintenant-explique-moi-serene-firefly.md.
| Phase | Status |
|---|---|
| 0 β Snapshot regression harness | β done (9 fixtures) |
| 1 β Package skeleton | β done |
| 2 β Helpers + portable types | β done (115 tests) |
3 β Migration applyQualityRulesBeforeSolver |
β done (203 tests, byte-equivalent legacy) |
4 β Migration macroOptimizerPQDynamicMaxAction |
β done (212 tests, byte-equivalent legacy) |
| 5 β Pipeline + report | β done (232 tests, solvePipeline + buildPreSolveReport) |
| 6 β Shims FlutterFlow | β artifacts ready (3-stage DSL + migration guide + shim refs); deploy gated on Phase 7 |
| 7 β Package publishable | β done (v0.7.0, LICENSE, example, dry-run clean); hosting decision pending (see PUBLISHING.md) |
| 8 β Suppression legacy | covered by Phase 6 Stage C cleanup |
Goals
- Unblock SDK push β splitting 370KB of custom code into portable Dart so each FlutterFlow entity drops below the 64KB server limit.
- Enable automated tests β pure Dart logic is testable via
dart test, unlike monolithic custom code closures. - Eliminate duplication β ~13% of legacy code is duplicated helpers; centralized here.
- Decouple from FlutterFlow / Firestore β no
DocumentReference, noFieldValue, no FF-specific types in the package surface.
Architecture
lib/
βββ vital_solver.dart β public API exports
βββ src/
βββ types/ β portable types (no Firestore)
βββ helpers/ β toD, asMap, norm, macros (per100g)
βββ quality/ β apply_quality_rules + sub-modules
βββ optimizer/ β coordinate descent + rescue passes
βββ pipeline/ β orchestrators
βββ reporting/ β pre-solve report (warnings, blocking, suggestions)
test/
βββ snapshots/ β real Firestore cases (Phase 0)
βββ legacy/ β frozen copies of FF functions (regression baseline)
βββ snapshot_regression_test.dart β compares package output vs legacy
βββ sweet_batch_v22b_test.dart β V22b cascade scenarios
βββ helpers_test.dart
βββ quality_test.dart
βββ optimizer_test.dart
βββ pipeline_test.dart
Usage (target API, Phase 5+)
import 'package:vital_solver/vital_solver.dart';
final output = solveSingleMeal(
ingredients: [/* IngredientInput list from your data layer */],
targets: SolverTargets(p: 52, c: 35, l: 17, fiMin: 8),
context: RecipeContext.standard(),
);
if (output.constraintsOk) {
// output.gramsById, output.totals, output.diagnostics
} else {
// Inspect output.errors and output.diagnostics for guidance
}
Development
dart pub get
dart analyze
dart test
License
Private β internal use only for VITAL.
Libraries
- vital_solver
- vital_solver β Pure-Dart nutritional solver for the VITAL FlutterFlow app.