Phase 9: Hardening & deploy — Dropbox archive, Caddy, security pass#8
Merged
Conversation
- Dropbox sync service: upload receipts post-OCR, verify content_hash, delete local file only after confirmation. Local data/receipts/ is now a staging buffer; SQLite JSON is the operational record, Dropbox the audit trail. - Hourly retry cron (sync_pending) + daily SQLite backup (backup_db) with 30-snapshot retention and dry-run purge of receipts >36 months. - Caddy reverse proxy with tls internal + prod compose profile (restart=always, healthchecks, named volumes incl. ollama-models). - APP_ENV-gated production hardening: Secure+SameSite=Strict cookies, double-submit CSRF, 5/min/IP login rate limit, Pillow verify() on uploads. Tests stay green because enforcement is prod-only. - Structured JSON logging + /api/admin/stats endpoint. - RUNBOOK.md (Ubuntu 24.04 + CUDA 12.8 + RTX 5070 Ti setup, iPhone CA trust, restore, purge, zero-trust hook), smoke_test.sh, CI workflow. - ASSUMPTIONS.md updated with what was validated vs. left untested. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Final hardening and deploy session. No new features.
content_hash, then deleted locally. Localdata/receipts/is staging only; SQLite JSON is the operational record, Dropbox is the audit trail.scripts/sync_pending.sh(hourly) retries failed uploads + logs purge dry-run;scripts/backup_db.sh(daily 02:00) snapshots SQLite → gzip → Dropbox → verify → prune to 30.caddy/Caddyfilewithtls internal;docker compose --profile prod up -dadds Caddy + healthchecks +restart: alwaysto every service.APP_ENV=productionso tests pass):HttpOnly + Secure + SameSite=Strictcookies, double-submit CSRF middleware, 5/min/IP rate limit on login, Pillowverify()on every receipt upload.GET /api/admin/stats(totals, OCR success rate, pending Dropbox sync count, DB size, last backup time).RUNBOOK.md(Ubuntu 24.04 + CUDA 12.8 + RTX 5070 Ti setup, iPhone CA trust, restore, purge, zero-trust swap),scripts/smoke_test.sh, GitHub Actions CI (pytest + vitest + compose build),ASSUMPTIONS.mdupdated with what was validated vs. left untested.Test plan
pytest -q→ 62 passed.docker compose --profile prod up -dboots healthy on the target host.ollama run qwen2.5vl:7b "hello"succeeds on the RTX 5070 Ti (verify CUDA 12.8+ / Ollama ≥ 0.6 per RUNBOOK §1.6).scripts/smoke_test.shexits 0 against the live stack.Reviewer notes
APP_ENV=production. Flipping prod on before wiring the SPA to readcsrf_tokenand echoX-CSRF-Tokenwill 403 every write. KeepAPP_ENV=developmentfor the first deploy.SECRET_KEY,DROPBOX_ACCESS_TOKEN) fail-fast at startup only whenAPP_ENV=production, so the test suite remains friction-free.OLLAMA_BASE_URL/RECEIPT_STAGING_DIRenv names are aliases —model_post_initcopies them into the existingollama_url/receipts_dirfields so no call sites needed to change.🤖 Generated with Claude Code