The actual request was simple (store exports in R2 like source files,
pending a retention-duration decision), but investigating where
exports were written surfaced something worse: /api/process built and
saved a full workbook to disk on EVERY extraction, and nothing in the
frontend ever called /api/download/<filename> to retrieve it (confirmed
by grep - no reference anywhere). Every extraction was silently
orphaning an .xlsx file for no reason; 91 had already accumulated
locally from this session's own testing alone.
Removed the dead work entirely: /api/process no longer builds or saves
a workbook at all. /api/download/<filename>, file_repository.
save_workbook/resolve_output_path, and OUTPUT_FOLDER (env var, volume,
directory) are all gone - confirmed nothing else referenced any of
them before removing. outputs/ deleted, including its 91 accumulated
files.
/api/export (the only path actually used - Download Excel/All) now
builds the workbook into an in-memory BytesIO and streams it straight
from there - never touches disk, not even temporarily. The frontend
persists it long-term instead: documentsService.saveExportFile uploads
the same Blob the browser download already used to a new exportFile
field (pb_migrations/3_add_export_file.js), stored in R2 same as
sourceFile. Overwrites the previous export rather than keeping a
history - no retention policy has been decided yet, and keeping every
version would just relocate the same unbounded-growth problem from the
VPS to R2 instead of fixing it. Best-effort from ResultCard.vue - a
save failure is reported but never blocks the browser download itself.
Verified for real: /api/process's response no longer has `filename`
(title still does); /api/export still streams a valid, correctly-typed
.xlsx; /app/outputs no longer exists in the rebuilt container; the old
/api/download URL now falls through to the ordinary SPA catch-all, not
a leftover route. documentsService.saveExportFile run against the REAL
bytes /api/export produced, fetched back through the R2-backed URL,
confirmed byte-for-byte - and confirmed a second export overwrites
rather than creating a second record. measure.py unaffected; npm run
build passes.
New third service alongside app/docling - a deliberate, revisited
decision from the documented "no DB" architecture, not an oversight.
pocketbase/Dockerfile - official minimal pattern (no official image
exists), pinned binary, migrations+hooks copied in and run on startup.
pb_migrations/1_create_collections.js - schema as code: users (auth,
self-registration open), projects (owner-scoped), documents (owner-
AND project-scoped - project is REQUIRED, not optional, since a
planned future per-project category-mapping feature needs every
document scoped from day one), with a sourceFile field for the
original PDF/image (stored in R2 once configured).
pb_hooks/ensure_default_project.pb.js - auto-creates each new user's
"General" project (isDefault:true) the moment their account exists -
covers password and Google signup uniformly, guarantees the required
documents.project relation always has somewhere to point.
configure-secrets.sh - the only place R2/Google secrets are handled,
reading from a gitignored .env and PATCHing PocketBase's own REST API.
Never in a migration (those are committed to git).
Frontend: pocketbaseRepository.js (the one SDK instance),
authService.js (login/signup/Google/logout), authStore.js (Pinia,
synced to the SDK's own authStore), LoginView.vue, and App.vue's new
auth gate - talks to PocketBase directly, not proxied through Flask.
Verified via real REST API calls against the running container (not
just read): migrations create the expected collections/rules; a fresh
signup gets exactly one auto-created "General" project; a second
user's token can't see the first user's data; a document created with
no project correctly fails validation (confirming the frontend must
resolve one itself); authService's actual functions exercised via a
live Node script against the real container (signup, hook-created
project visible, logout, re-login). npm run build passes. measure.py
unaffected (no backend code touched).
Not yet verified - needs real R2/Google credentials this session
doesn't have: configure-secrets.sh itself, and the Google OAuth popup
flow (needs a real browser + real Google Cloud OAuth client, both
outside this repo's control - documented as setup prerequisites in
README.md).
This is Stage B.1 of 3 (schema + auth gate). B.2 (document persistence
moves from localStorage to PocketBase) and B.3 (the project sidebar
UI) are not started yet.
Bettersight Statement Extractor as of Phase 1 build: bank-agnostic pdfplumber
extraction, Docling cross-check, the 6+1 checks, Excel export, and the
minimal web UI - all built and working.
Adds the measurement harness (measure.py) from the plan's step 10: runs
every fixtures/*.pdf with a matching *_ground_truth.xlsx against the real
pipeline, diffs date/description/amount/balance per transaction, and logs
a dated JSON result under results/. Also adds hand-verified ground truth
for the HSBC Sep statement and a new RBC fixture (RBC-CAD-Aug26.pdf, sourced
from docs/) with its own hand-verified ground truth - RBC extraction now has
regression coverage it previously lacked.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>