# Project State ## Project Reference See: .planning/PROJECT.md (updated 2026-03-07) **Core value:** Generare un calendario di 13 caroselli Instagram strategicamente orchestrati, pronti per Canva Bulk Create, con un click dalla Web UI. **Current focus:** TUTTI I PIANI COMPLETATI — pronto per deploy VPS e test end-to-end ## Current Position Phase: 4 of 4 (Enrichment) — COMPLETA Plan: 2 of 2 in current phase — Completato Status: PROGETTO COMPLETO — tutte le 4 fasi implementate (backend + frontend) Last activity: 2026-03-09 — Completed 04-02-PLAN.md (Frontend Unsplash UI) Progress: [██████████] 100% (10/10 piani totali) ## Performance Metrics **Velocity:** - Total plans completed: 10 - Average duration: ~5.8 min - Total execution time: ~58 min **By Phase:** | Phase | Plans | Total | Avg/Plan | |-------|-------|-------|----------| | 01-core-generation-pipeline | 4/4 COMPLETA | 33 min | 8 min | | 02-prompt-control-output-review | 2/2 COMPLETA | 9 min | 4.5 min | | 03-organization-layer | 2/2 COMPLETA | 8 min | 4 min | | 04-enrichment | 2/2 COMPLETA | 8 min | 4 min | **Recent Trend:** - Last 5 plans: 5 min, 3 min, 3 min, 5 min, 3 min - Trend: stabile intorno a 3-5 min *Updated after each plan completion* ## Accumulated Context ### Decisions Decisions are logged in PROJECT.md Key Decisions table. Recent decisions affecting current work: - [Setup]: FastAPI root_path SOLO via Uvicorn (--root-path), mai nel costruttore FastAPI() - [Setup]: CSV encoding = utf-8-sig (BOM) sempre; CANVA_FIELDS locked come costante - [Setup]: Prompt di sistema scritti IN italiano - [Setup]: Per-item error isolation dal primo loop di generazione - [01-01]: root_path SOLO via Uvicorn --root-path nel Dockerfile CMD - [01-01]: API_BASE='/postgenerator/api' nel frontend — Pitfall #9 risolto - [01-02]: CANVA_FIELDS 33 colonne con _image_keyword (non URL) — URL Unsplash in Phase 4 - [01-02]: PromptService usa ValueError per variabili mancanti - [01-03]: LLMService._parse_retry_after() legge header HTTP per wait esatto (fallback 60s) - [01-03]: asyncio.to_thread wrappa LLM sync calls nel background task async - [01-03]: Settings.api_key merge: PUT non sovrascrive con None se non inclusa nel body - [01-03]: Pipeline singleton in generate.py per mantenere _jobs tra request, con fallback da disco - [01-04]: Palette stone/amber per design B2B non generico (non gradienti viola) - [01-04]: Download CSV sempre via POST con edits inline (non GET originale) - [01-04]: localResults separato in OutputReview per edit inline senza mutare cache TanStack Query - [verification-fix]: GenerateResponse include calendar per badge PN/Schwartz nel frontend - [02-01]: PromptService init lazy via _get_prompt_service() per sincronizzazione con lifespan directory - [02-02]: Regen notes passate via campo tono in GenerateRequest (pragmatico, no backend changes) - [02-02]: Edit detection manuale via JSON.stringify comparison (trascurabile con 13 post) - [03-01]: SwipeService lazy init identico a PromptService (DATA_PATH creato nel lifespan FastAPI) - [03-01]: IDs brevi uuid4.hex[:12] — leggibili, no rischio collisione con volumi Swipe File - [03-01]: PUT con comportamento PATCH-like per nicchia/note — None cancella il valore - [03-01]: Filtro nicchia derivato dinamicamente da items (no config separata) - [03-02]: topic_overrides come dict[int, str] — chiave = slot_index, Pydantic converte str key → int - [03-02]: Override check prima di slot.topic e prima di LLM nel _run_generation - [03-02]: mark-used fire-and-forget (mutate senza await) per non bloccare la UI - [03-02]: Picker inline con absolute positioning z-20, toggle click stesso slot chiude - [04-01]: Risoluzione Unsplash UNA SOLA VOLTA dopo batch LLM, image_url_map salvata nel job JSON - [04-01]: generate_single NON risolve Unsplash — velocita' e riuso map job originale - [04-01]: Dizionario statico IT->EN (~30 keyword B2B) — no API di traduzione - [04-01]: Fallback trasparente: keyword non risolte restano testuali, nessun errore bloccante - [04-01]: Rate limit: X-Ratelimit-Remaining < 5 => stop batch, keyword restanti non risolte - [04-02]: Link vs navigate() — usato Link da react-router-dom per coerenza col pattern codebase - [04-02]: showUnsplashKey state separato da showApiKey — toggle indipendenti per le due API key - [04-02]: Thumbnail 80x56px — anteprima visiva senza dominare la card (13 immagini in pagina) - [04-02]: Hint OutputReview volutamente discreto (stone-600) — non aggressivo, scompare silenziosamente ### Blockers/Concerns - [Phase 1]: Validare token usage reale per batch 13 post con claude-sonnet-4-5 — inter_request_delay=2.0s configurato, da validare in produzione - [Phase 1]: Baseline qualita' prompt italiani da validare dopo prima generazione reale - [Deploy]: PRIORITA' — eseguire vps-lab-deploy per testare end-to-end il sistema completo (tutte le 4 fasi complete) ## Session Continuity Last session: 2026-03-09 Stopped at: Completed 04-02-PLAN.md (Frontend Unsplash UI) — Plan 2/2 Phase 4 Resume file: None ## Next Actions 1. `vps-lab-deploy` — PRIORITA' — tutte le 4 fasi sono complete, deployare su VPS e testare end-to-end 2. Test reale della generazione bulk: configurare API key Claude + Unsplash in Settings UI, verificare thumbnail in OutputReview, verificare URL immagini nel CSV 3. Validare qualita' prompt italiani con dati reali