2.1 KiB
2.1 KiB
ADR — Local catalogue, không cloud sync
Trạng thái: chấp nhận · 2026-09-28 · nhánh recipes-web
Bối cảnh
Studio PWA (docker/frontend) đọc thư mục trên máy người dùng qua File System Access API.
Bản nháp thiết kế lightroom_web_app.md giả định endpoint /v1/sync/edits và auth
Authorization: Bearer localStorage['pro_user_token']. Backend thật (Fastify + SQLite) chỉ biết
ảnh upload qua /api/photos (cap 12/tài khoản) và recipe qua /api/recipes; auth bằng cookie
SESSION_COOKIE HttpOnly. Không có photoId phía server để gắn edit vào — endpoint đó không
thể tồn tại. Tính năng được yêu cầu là quản lý local, nên phần sync là YAGNI.
Quyết định
- Freeze scope: catalog và edit chỉ nằm trên máy người dùng. Không thêm bảng, không endpoint sync.
- IndexedDB
recipescam-library(version 1), ba store — theo đúngsrc/engine/library.ts:folders— keyPathnamephotos— keyPathid=${folder}/${name}, indexfolder,takenedits— keyPathphotoId,{ recipe, updatedAt }
- API cùng origin qua nginx proxy
/api/→fetch(..., { credentials: 'same-origin' })(src/api.ts). Không'include', không Bearer. - Nhận diện ảnh: trước mắt chỉ
folder/name. Khi cần sync thật: partial hash (first + last 64 KiB + size), và chỉ hash những frame thực sự có edit. Lưu ýscanFoldervốn đã đọc trọn bytes mỗi RAW chorawThumbnail, nên "hash đắt vì phải đọc 30–50 MB" không phải lập luận đúng; cái làmfilename+size+mtimemất map recipe là rename và copy từ card (mtime đổi, bytes y hệt).
Hệ quả
- Không có gì để "cắt Cloud Sync": trong repo chưa từng có code sync.
- Nếu sau này cần: thêm
library_edits (user_id, key, recipe, updated_at)+GET/POST /api/library/edits(upsert theo batch, LWW theoupdated_at), client flush khionline, xác thực bằng cookie session, key = partial hash. Ước ~60–80 dòng.