Both came from the src/ restructure and only show up at runtime, so
the test suite had not caught them.
- src/backend/config.py: env_file was "../../.env", which pydantic-
settings resolves against the *cwd*, not the file. Running uvicorn
or alembic from the project root therefore looked for
../../.env one level above the repo and silently fell back to the
default DB_PASSWORD ("change_me_in_production"), hiding the real
password. Now resolved as Path(__file__).resolve().parents[2] /
".env" so the lookup is always against the project root regardless
of cwd.
- src/backend/models/orm/__init__.py: Station and
StationRecipeAssignment were never imported here, so anything that
triggers Base.metadata.create_all without first importing the
setup router (which has its own Station import) ended up with no
stations / station_recipe_assignments tables. Verified locally:
/api/setup/seed used to fail with "Table tiemeasureflow.stations
doesn't exist" before this fix.
- .gitignore: ignore src/frontend/flask_app/package.json and
package-lock.json (local npm-install artifacts; the Dockerfile
installs tailwindcss directly).
Smoke verified end-to-end: uvicorn + gunicorn + MySQL, login + admin
stations + select_recipe + admin users all 200 OK.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Brings the entry-point README in line with the V2.0.0 restructure:
- Replace all server/ + client/ paths with src/backend/ +
src/frontend/flask_app/.
- Replace pip install -r requirements.txt with the uv workflow
(uv sync --extra server --extra client --extra dev).
- Manual setup section uses uv run uvicorn / uv run flask /
uv run alembic / uv run pybabel, all driven from the project root.
- Document the V2.0.0 additions: STATION_CODE per-tablet, /admin/
stations GUI, gunicorn 5x4 + uvicorn 4 worker scaling, X-Forwarded
-For-aware rate limiting (RATE_LIMIT_GENERAL default 300).
- Add tooling section (uv, pyproject.toml, uv.lock, .python-version,
pytest stack).
- Documentation section now points at the new docs/ index plus the
STATO_PROGETTO + ROADMAP architecture pair as the canonical "what
is done / what is next" references.
- Variabili d'Ambiente: add STATION_CODE, RATE_LIMIT_LOGIN,
RATE_LIMIT_GENERAL.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cleanup
- Remove src/backend/Dockerfile.legacy and
src/frontend/flask_app/Dockerfile.legacy (history is in git, build
uses the new uv-based root Dockerfile / Dockerfile.frontend).
- Remove src/frontend/flask_app/verify_i18n.py (had hardcoded paths
pointing at the old client/ tree).
Group docs/
- New docs/README.md indexes everything in one place.
- New docs/architecture/STATO_PROGETTO.md: snapshot of what works in
V2.0.0 (inherited V1.0.7 features, rev04 Phase 1 stations,
worker scaling, src/ restructure, test status, stack, decisions).
- New docs/architecture/ROADMAP.md: what's next — Phases 2-7 of the
rev04 migration with status, open client decisions (D-0.1 through
D-0.10), tech debt and time estimates for M1 / M2.
- Move PIANO_IMPLEMENTAZIONE.md (90KB V1.0.0 plan) to
docs/archive/2026-02-06-piano-implementazione-v1.md (historical).
- Move Schema sviluppo SW TieFlow_rev04-2026.docx to docs/specs/
with ISO date filename so the customer spec is now tracked.
- Move src/frontend/flask_app/I18N_SETUP.md to docs/I18N_SETUP.md
and rewrite paths to the new src/frontend/flask_app/ tree.
.dockerignore: simplified now that legacy Dockerfiles are gone;
docs/ stays excluded from the build context.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Aligns the repo with the python-project-spec-design.md template chosen
for V2.0.0. Big move, no logic changes. The 3 pre-existing test
failures (test_recipes::test_update_recipe, test_recipes::
test_recipe_versioning, test_tasks::test_reorder_tasks, plus the
client test_save_measurement_proxy) survive unchanged.
Layout changes
- server/ -> src/backend/
- server/middleware/ -> src/backend/api/middleware/
- server/routers/ -> src/backend/api/routers/
- server/models/ -> src/backend/models/orm/
- server/schemas/ -> src/backend/models/api/
- server/uploads/ -> uploads/ (project root, mounted volume)
- server/tests/ -> src/backend/tests/
- client/ -> src/frontend/flask_app/ (Flask kept; React
deroga is documented in CLAUDE.md, justified by tablet UX, USB
caliper/barcode workflow and Fabric.js integration)
Tooling
- pyproject.toml: monorepo with [project] core deps and
optional-dependencies server / client / dev. Replaces both
server/requirements.txt and client/requirements.txt.
- uv.lock + .python-version (3.11) committed for reproducible builds.
- Dockerfile (root, backend) and Dockerfile.frontend rewritten to use
uv sync --frozen --no-dev --extra server|client; legacy Dockerfiles
preserved as Dockerfile.legacy for reference but excluded from build
context via .dockerignore.
- docker-compose.dev.yml + docker-compose.yml: build context now ".",
dockerfile pointing to the root files.
Code adjustments forced by the move
- Every "from config|database|models|schemas|services|routers|middleware
import ..." rewritten to its src.backend.* equivalent (50+ files
including indented inline imports inside test bodies).
- src/backend/migrations/env.py: insert project root into sys.path so
alembic can resolve src.backend.* imports regardless of cwd.
- src/backend/config.py: env_file ../../.env (was ../.env), upload_path
resolves project root via parents[2].
- src/backend/tests/conftest.py + tests: import ... from src.backend.*
instead of bare names; old per-directory pytest.ini files removed in
favor of root pyproject.toml [tool.pytest.ini_options].
- .gitignore: uploads/ at root, src/frontend/flask_app/static/css/
tailwind.css path; .dockerignore tightened.
- CLAUDE.md: rewrote sections "Layout del repository", "Comandi di
Sviluppo", "Database & Migrations", "Test", "i18n", and all path
references throughout the architecture sections.
Verified
- uv lock resolves 77 packages; uv sync --extra server --extra client
--extra dev installs cleanly.
- uv run pytest: 171 passed, 4 pre-existing failures.
- uv run alembic -c src/backend/migrations/alembic.ini check loads
config and metadata (errors only on the absent local MySQL).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The default 2-worker gunicorn could only serve 2 concurrent tablet requests,
queueing the rest, and the rate limiter saw every tablet as the same Nginx
container IP, so 20 users would have collectively burned through the
100 req/min general bucket.
- gunicorn: 5 workers x 4 gthread, --forwarded-allow-ips=*, access log
- uvicorn: 4 workers, --proxy-headers, --forwarded-allow-ips=*
- RateLimitMiddleware: resolve real client IP from
X-Forwarded-For -> X-Real-IP -> request.client.host
- Bump rate_limit_general 100 -> 300 req/min/IP (per tablet now)
- Flask: ProxyFix(x_for=1, x_proto=1, x_host=1) so request.remote_addr
is the tablet IP, not the Nginx IP
- APIClient: forward X-Forwarded-For + X-Real-IP to FastAPI for both
JSON and multipart/files calls; safe no-op outside request context
- 12 new tests (7 server + 5 client) covering header precedence,
forwarding behavior and ProxyFix install
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a complete browser-based interface for managing stations,
closing the last deliverable of rev04 Phase 1.
- New /admin/stations page with stations table, create/edit modal,
delete confirmation and dedicated recipe-assignment modal
- Proxy endpoints under /admin/api/stations/* covering CRUD and
recipe assign/unassign so all admin operations stay behind the
Flask CSRF + admin_required guard
- Navbar entry "Stazioni" (desktop + mobile), visible to admins only
- 10 new tests covering page render, every proxy and the non-admin
redirect
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace generic /api/recipes call with api_client.get_station_recipes(STATION_CODE).
Return 503 station_not_configured.html when STATION_CODE env var is unset.
Add station indicator to recipe selection page header.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reads STATION_CODE from the environment and exposes it as Config.STATION_CODE
(None when unset or empty). Adds the variable to .env.example with a
per-station deployment note, and covers both read and missing-key paths with
new pytest tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add _seed_default_station() helper to /api/setup/seed endpoint that
creates the ST-DEFAULT station and assigns all active recipes to it,
preserving existing behaviour after migration 002 runs on live DBs.
Helper is idempotent and is called on both the normal seed path and
the early-return path (when demo data already exists).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rinomina _RecipeSummary -> RecipeSummary: il leading underscore
segnalava "privato" ma la classe e usata come response_model pubblico
ed esposta nell'OpenAPI schema.
- Aggiunge commento esplicativo sopra /by-code/{code}/recipes sul perche
l'ordine di dichiarazione conta (protezione gia data dal tipo int di
station_id, ma esplicito per prevenire regressioni durante refactor).
- Detail message del 404 by-code uniformato a "Station not found"
(senza distinguere not-found vs inactive, evita leak di esistenza).
- Aggiunge 3 test mancanti sul router:
* test_admin_can_list_stations (copertura happy path + active_only)
* test_assign_recipe_not_found_returns_404
* test_duplicate_assignment_returns_409
Feedback da code-reviewer su Task 5. Full suite: 11/11 passed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implements the /api/stations FastAPI router (admin-only CRUD, recipe
assignment endpoints) and the public /by-code/{code}/recipes operator
endpoint. Registers the router in main.py and adds 8 integration tests.
- Station.code: usa UniqueConstraint("code", name="uq_stations_code")
esplicito in __table_args__ invece di unique=True sulla colonna,
per allineamento con la migration 002 ed evitare drift Alembic.
- Aggiunge test test_duplicate_assignment_is_rejected per coprire
il vincolo uq_station_recipe (regola business centrale del modello).
- Sposta import IntegrityError a module-level per consistenza.
Feedback da code-reviewer su Task 2.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TDD: test written first, confirmed failing with ModuleNotFoundError,
then model implemented; all 3 new tests pass. conftest updated to
import new models so Base.metadata.create_all picks up the tables.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- server_default='1' anziche sa.true() per compatibilita con SQLite
(usato come DB in-memory nei test)
- Rimuove Index ix_stations_code ridondante con UniqueConstraint
uq_stations_code (InnoDB crea gia un indice per i vincoli UNIQUE)
Feedback da code-reviewer su Task 1.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Le migrations Alembic sono essenziali per il deploy riproducibile:
rimuove la regola in .gitignore che le escludeva e aggiunge al
tracking la migration 001 (image_path) gia esistente ma mai committata.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Aggiunge il master plan di migrazione V1.0.7 -> V1.1.0 (rev04-2026)
con le sette fasi organizzate in milestone M1 (demo cliente) e M2
(produzione), piu il piano TDD dettagliato della Fase 1 (Stazioni e
identita per-tablet) con 17 task eseguibili.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Correct the middleware stack order (was documented backwards due to
Starlette's add_middleware wrapping behavior), document fabric-debug.js
local copy, and note full 50-900 shade palettes for Tailwind colors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restructure README to be more concise: add feature overview section,
architecture diagram with security note, tabular stack listing,
streamlined quick start, and env vars reference table. Move VPS
deployment details to docs/DEPLOYMENT.md to avoid duplication.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change Plotly modebar to hover-only mode to avoid overlapping chart content
- Remove redundant Plotly titles (container headers already provide them)
- Add Content-Type check and inline error display for report downloads
- Fix setup login validation and seed idempotency for existing data
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Seed now generates 180 realistic measurements (30 per subtask) with
Gaussian distribution for SPC testing. Setup page gains full user CRUD
with list, create/edit, password change, and activate/deactivate.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Edit button now opens the same "Nuova Misurazione" form pre-filled with
existing data, showing "Modifica Misurazione" title and "Aggiorna Misurazione"
button. Also adds marker_number to SubtaskUpdate schema so edits persist.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace drop-zone with action buttons (Sostituisci/Rimuovi) when image
exists, matching the task editor pattern. Add upload overlay with
spinner on the image during file upload.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Recipe image_path is now used as preview thumbnail only. Removed
auto-creation of "Technical Drawing" task from recipe upload, and
removed recipe image strip from task_execute view. Each task displays
its own file_path independently.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Production compose with Traefik labels for auto-SSL via Let's Encrypt.
Requires external traefik-net (root_default) network.
Dev compose (docker-compose.dev.yml) remains unchanged with Nginx.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactor measurement execution page from 2-column to 3-column layout:
- Left: vertical marker sidebar with status indicators
- Center: image area with subtask image switching (per-subtask detail
images override task annotation viewer) + optional recipe image strip
- Right: compact info panel with tolerances, feedback, and numpad
Also: compact header bar, use window.__data pattern for tojson escaping,
fetch recipe image_path in measure blueprint.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New admin blueprint with CRUD proxy endpoints for users
- Admin user management template with search, create, edit, toggle active
- Navbar: add admin link for is_admin users (desktop + mobile)
- Register admin blueprint in app factory
- Add IT/EN translations for all admin UI strings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Recipe model: add image_path field for recipe-level image
- RecipeSubtask model: add image_path for per-subtask detail images
- Schemas: add image_path to create/update/response for recipe and subtask
- Task router: pass image_path when creating tasks and subtasks
- Recipe service: copy image_path in versioning and update-in-place
- Users router: add PUT /{user_id}/password endpoint (admin only)
- User schema: add UserPasswordChange model
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Align documentation with current codebase state: add admin blueprint to
client architecture, document dev (Nginx) vs prod (Traefik) compose files,
fix blueprint count in test section.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Auto-advance to next task after completing all subtask measurements
- 1s pause between measurements to show pass/fail/warning result
- Colored marker strip (green/red/amber) based on measurement status
- Replace duplicate measurements instead of appending (fixes progress bar)
- Add Task column and Date/Time column to measurement summary table
- Enrich summary with task_info for each measurement
- Update-in-place for recipe versions without measurements (no copy-on-write)
- Dark theme improvements and navbar cleanup
- Server config: ignore extra env vars
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Canvas now sizes to match the scaled image dimensions (zero empty space)
instead of using a fixed aspect ratio, fixing coordinate mismatch between
editor and viewer
- Annotations load only after background image is ready via _pendingAnnotations
pattern, preventing placement at wrong coordinates
- Arrow endpoints (arrowX1/Y1/X2/Y2) update on object:modified using
transform delta, so moved arrows serialize at correct position
- Coordinate scaling on load: coordScale = currentImageScale / savedImageScale
handles annotations saved at different screen widths
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In setMode('select'), explicitly set hasControls, hasBorders, and evented
on all objects. In drawing modes, disable selectable/evented to prevent
accidental interaction. Fixes controls only appearing on multi-select drag.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add recipe_id property to RecipeTask model (via version relationship)
- Add recipe_id to TaskResponse schema
- Eager-load version in _get_task_or_404 query
- Use task.recipe_id instead of task.version_id in task_execute template URLs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove hasControls:false and lockScaling from markers so resize/rotate handles appear
- Add setActiveObject() after creating arrows and rectangles for immediate control visibility
- Restore angle, scaleX, scaleY when loading saved annotations (all object types)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Complete English translation catalog (44 entries fixed/added)
- Fix Fabric.js Group cache invalidation (active.dirty = true) so color,
thickness and line-dash changes are visible on selected markers/arrows
- Fix Italian .po placeholder mismatch (%(detail)s -> %(error)s)
- Bump annotation-editor.js cache buster to v8
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Browser was serving stale cached version without editor format
support (objects array). Bumped ?v=4 on all three templates:
recipe_preview, task_execute, task_editor.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
annotationViewer.drawAnnotations() now handles the editor format
(objects array with marker/arrow/area) in addition to the legacy
format (markers array). This fixes missing overlay in recipe preview
and task execution views.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add per-task file upload with image preview in task editor
- Add dedicated annotation editor page (task_drawing.html) with Fabric.js
- Add color picker, stroke width, and line dash controls to annotation toolbar
- Apply property changes to selected objects in real-time
- Disable style controls until a drawing tool or object is selected
- Remove zoom/pan from annotation toolbar (simplified UX)
- Auto-switch to select mode after placing annotation elements
- Show annotation overlay on task image previews (read-only canvas)
- Add file proxy route in measure blueprint for task file access
- Add file_path/file_type fields to TaskCreate/TaskUpdate Pydantic schemas
- Replace Tailwind CDN with compiled CSS (tailwind.config.js with full shades)
- Fix Alpine.js x-init crash: extract annotations JSON to <script> tags
(recipe_preview.html, task_execute.html) to avoid HTML attribute breakage
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add file proxy route in maker blueprint (X-API-Key auth for browser requests)
- Persist file_path/annotations_json to DB via RecipeCreate/RecipeUpdate schemas
- Fix canvas sizing using grandparent container instead of Fabric.js wrapper div
- Defer canvas init with requestAnimationFrame for x-show timing
- Add PDF.js support in annotation-editor and annotation-viewer
- Fix annotations_json double-serialization (parse string to object before send)
- Handle FastAPI 422 validation error arrays in api_client and JS error display
- Update template URLs to use /maker/api/files/ proxy path
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix version badge showing [object Object] or Python dict dump in
select_recipe, task_list, and task_complete templates by accessing
current_version.version_number instead of the whole object
- Fix recipe_editor.html Internal Server Error caused by Jinja2 block
scoping: {% set %} variables from block content were invisible in
block extra_js, replaced with direct recipe.* references
- Fix task_editor.html SyntaxError from Italian apostrophe in
nell'eliminazione breaking JS string literals, switched to |tojson
- Add i18n {{ _() }} wrappers to all hardcoded navbar strings (desktop
and mobile menus) so language toggle works correctly
- Add app title text "TieMeasureFlow" next to logo in navbar
- Add missing GET /api/tasks/{task_id} endpoint on server that caused
405 Method Not Allowed when starting measurements
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>