# Prompt Sprint 2 - Source Management ## 🎯 Sprint 2: Source Management **Iniziato**: 2026-04-06 **Stato**: 🟡 In Progress **Assegnato**: @sprint-lead --- ## 📋 Obiettivo Implementare la gestione delle fonti (sources) per i notebook, permettendo agli utenti di aggiungere URL, PDF, YouTube, Google Drive e avviare ricerche web. --- ## 🏗️ Architettura ### Pattern da seguire (stesso di Sprint 1) ``` API Layer (FastAPI Routes) ↓ Service Layer (SourceService) ↓ External Layer (notebooklm-py client) ``` ### Endpoints da implementare 1. **POST /api/v1/notebooks/{id}/sources** - Aggiungere fonte 2. **GET /api/v1/notebooks/{id}/sources** - Listare fonti 3. **DELETE /api/v1/notebooks/{id}/sources/{source_id}** - Rimuovere fonte 4. **GET /api/v1/notebooks/{id}/sources/{source_id}/fulltext** - Ottenere testo 5. **POST /api/v1/notebooks/{id}/sources/research** - Ricerca web --- ## 📊 Task Breakdown Sprint 2 ### Fase 1: Specifiche - [ ] SPEC-004: Analisi requisiti Source Management - [ ] SPEC-005: Definire modelli dati fonti ### Fase 2: API Design - [ ] API-003: Modelli Pydantic (SourceCreate, Source, ecc.) - [ ] API-004: Documentazione endpoints ### Fase 3: Implementazione - [ ] DEV-007: SourceService - [ ] DEV-008: POST /sources - [ ] DEV-009: GET /sources - [ ] DEV-010: DELETE /sources/{id} - [ ] DEV-011: POST /sources/research ### Fase 4: Testing - [ ] TEST-004: Unit tests SourceService - [ ] TEST-005: Integration tests --- ## 🔧 Implementazione ### Tipi di Fonti Supportate ```python class SourceType(str, Enum): URL = "url" FILE = "file" # PDF, DOC, etc. YOUTUBE = "youtube" DRIVE = "drive" ``` ### SourceService Methods ```python class SourceService: async def create(notebook_id: UUID, data: dict) -> Source async def list(notebook_id: UUID) -> list[Source] async def get(notebook_id: UUID, source_id: str) -> Source async def delete(notebook_id: UUID, source_id: str) -> None async def get_fulltext(notebook_id: UUID, source_id: str) -> str async def research(notebook_id: UUID, query: str, mode: str) -> ResearchResult ``` --- ## 📝 Note Importanti 1. **Riusare pattern Sprint 1**: Stessa struttura NotebookService 2. **Gestione upload file**: Supportare multipart/form-data per PDF 3. **Ricerca web**: Integrare con notebooklm-py research 4. **Error handling**: Fonte già esistente, formato non supportato --- ## 🚀 Prossimi Passi 1. @sprint-lead: Attivare @api-designer per API-003 2. @api-designer: Definire modelli Pydantic 3. @tdd-developer: Iniziare implementazione SourceService --- **Dipende da**: Sprint 1 (Notebook CRUD) ✅ **Blocca**: Sprint 3 (Chat) 🔴