Refactor transport calculation into shared domain

This commit is contained in:
2026-09-24 13:11:18 +02:00
parent fa3000b325
commit defbf20202
10 changed files with 582 additions and 132 deletions
+8 -8
View File
@@ -21,6 +21,7 @@ Backend:
- `/api/user` returns the authenticated user.
- `/api/calculations/roll` executes a `CalculationRequest` through the deterministic core.
- `/api/calculations/roll/modify` applies controlled changes to `CalculationState` and recalculates.
- `/api/calculations/transport` executes the shared transport-capacity service.
- `/api/reports/roll-calculation.pdf` recalculates a request and renders its authoritative result.
- `/api/conversations` creates a process-local conversational session.
- `/api/conversations/<id>/messages` runs constrained NLU followed by the existing deterministic calculation functions.
@@ -40,7 +41,8 @@ Frontend:
Domain service:
- `roll_calculation.py` owns `CalculationRequest`, `CalculationState`, `ArticleRepository`, `calculate_roll()`, and `modify_calculation()`.
- `roll_calculation.py` owns `CalculationRequest`, `CalculationState`, `ArticleRepository`, `get_article()`, `calculate_roll()`, and `modify_calculation()`.
- `transport_calculation.py` owns `analyze_transport()` and the canonical active transport presets. The template calls the protected transport API and retains only UI rendering and SVG drawing.
- Direct diameter ranges, optional weight, and direct-flow forklift warnings originate there.
- Request parsing rejects calculated diameter, weight, warning, and calculation fields.
- Natural-language clients may describe or modify a calculation request, but engineering results are generated exclusively by the deterministic Roll Calculator core.
@@ -246,14 +248,12 @@ That file includes localized messages and additional equipment requirements. Bef
## Load Optimizer
The Load Optimizer is implemented inline in `templates/roll_calculator.html`.
`transport_calculation.py` is authoritative for transport presets and capacity
analysis through `analyze_transport()`. The active template calls the protected
transport endpoint and only collects inputs, renders returned values, and draws
the SVG front view.
Classes:
- `LoadOptimizer`
- `LoadOptimizerUI`
It uses calculated roll data from the Direct Calculation tab:
It uses displayed roll data from the Direct Calculation tab:
- Roll diameter.
- Core diameter.