# TODO — Recipe Manager

**Last Updated:** 2026-03-25  
**Current Milestone:** v1.0 — Recipe Import

---

## ✅ MVP (v0.1) Status

MVP is functionally complete (core app + docs + tests).

### Completed
- Backend API (recipes + tags)
- Frontend UI (list/detail/form/cook mode)
- Search + tag management + error handling
- Dockerfiles + docker-compose
- API docs + user guide + README setup
- ADR-001 (sql.js decision)

### Deferred / Manual Host Validation
- [ ] Manual Docker host test (`docker compose up`) on host machine with Docker installed

---

## 🎯 Active Tasks — v1.0 Recipe Import

### Phase 1: URL Import Foundation
- [x] Add backend import endpoint: `POST /api/import/url`
- [x] Implement Schema.org Recipe JSON-LD parser service
- [x] Normalize parsed recipe into internal Recipe draft format
- [x] Add import endpoint tests (valid recipe page, non-recipe page, malformed JSON-LD)

### Phase 2: Import UI
- [x] Add “Import from URL” UI page/form in frontend
- [x] Show parsed preview (title, ingredients, steps, source URL)
- [x] Allow edit-before-save flow, then save to existing create recipe API
- [x] Add frontend error states (invalid URL, parse failure, timeout)

### Phase 3: Fallback Parsing + Hardening
- [x] Add heuristic fallback parser when Schema.org missing
- [x] Add timeout/retry + user-friendly import failure messages
- [x] Add logging/telemetry for import success/failure reasons

### Phase 4: Browser Extension (after URL import stable)
- [x] Scaffold browser extension project (Manifest v3)
- [x] Add “Send to Recipe Manager” action to call import API
- [x] Add extension settings for Recipe Manager base URL

---

## 🚀 High Priority Improvements (Post-code-review)

### Phase 1: Configuration & Reliability
- [x] Add environment-based configuration (dotenv, env vars for PORT, DB_PATH, CORS_ORIGIN)
- [x] Wrap RecipeRepository.create in database transaction (BEGIN/COMMIT)
- [x] Wrap RecipeRepository.update in database transaction
- [x] Optimize duplicate detection in import (use Set for O(1) lookup)
- [x] Add health check endpoint (/api/health)
- [x] Add dirty flag to avoid unnecessary periodic database saves
- [x] Enable foreign key constraints (PRAGMA foreign_keys = ON)

### Phase 2: Security
- [x] Add API key authentication middleware (shared secret for write endpoints)
- [x] Add rate limiting to import endpoints (express-rate-limit)
- [x] Update CORS to be configurable (wildcard only in development)
- [x] Fix image URL handling: ensure relative paths converted to /images/ absolute
- [ ] (Optional) Restrict harness routes to localhost or add auth

### Phase 3: Testing
- [x] Add tests for PUT /api/recipes/:id
- [x] Add tests for DELETE /api/recipes/:id
- [x] Add tests for tag CRUD (GET/POST/PUT/DELETE)
- [x] Add tests for tag assignment/removal to recipes
- [ ] Add unit tests for CopyMeThatHtmlParser (edge cases, malformed HTML)
- [ ] Add unit tests for CopyMeThatTxtParser
- [ ] Add unit tests for CopyMeThatImportService (duplicate detection, error handling)
- [ ] Add integration tests for file upload endpoint (POST /api/import/local)

### Phase 4: Code Quality & Observability
- [ ] Extract asyncHandler middleware to reduce route boilerplate
- [ ] Add request logging (morgan)
- [ ] Replace console.log with proper logger (debug module)
- [ ] Add pagination links to recipe list response
- [ ] Add full-text search (FTS5) for title/description/ingredients/tags (defer if time)

## ✅ Completed in this session (2026-03-29)
- Implemented all Phase 1 & 2 tasks (config, auth, rate limiting, health check, transactions, dirty flag, FK constraints, image URL fix)
- Added comprehensive tests for recipes (PUT/DELETE) and tags (update/delete/assignment)
- Fixed critical bug in tag assignment routes (parameter order)
- Enabled foreign key constraints for data integrity
- Fixed TypeScript build errors:
  - monkey-patch return type for db.run
  - added `.js` extensions to all cross-module imports (node16 resolution)
  - added explicit types for callbacks in test files
- All backend tests passing (46 tests) and `npm run build` succeeds

## 📋 Backlog (Post-v1)

### v1.1
- [ ] Recipe scaling (adjust servings)
- [ ] Print styles
- [ ] Advanced search filters
- [ ] Random recipe suggestion

### v2.0 (AI Features)
- [ ] AI ingredient substitutions
- [ ] Meal planning
- [ ] Shopping list generation
- [ ] Fintrove cost tracking integration

---

## 🚧 Blocked / Needs Decision

- **CopyMeThat export path:** confirm whether Anne/Elizabeth can export directly, or we rely on URL import + browser extension.
- **Tag filtering in recipe list:** currently UI-only, backend filter by tag_id pending.

---

## Notes for Agents

- Work from top to bottom in the **Active Tasks — v1.0** section.
- Pick the **first unchecked task** only.
- One task = one commit.
- If blocked: mark task with reason and continue next unblocked task only with explicit note.

---

_This is the authoritative task queue for harness iterations._
