From 2f62417c9f47630c14fb67191b337d92ca205dc7 Mon Sep 17 00:00:00 2001 From: NguyenND Date: Fri, 5 Jun 2026 13:57:36 -0400 Subject: [PATCH] 06/05 Optimize app: Add Plaid web hook, healthcheck --- .env.example | 1 + CLAUDE.md | 162 +++++++++++++++++++++++++-------- app/__init__.py | 2 + app/config.py | 5 +- app/routes/health.py | 87 ++++++++++++++++++ app/routes/plaid.py | 96 ++++++++++++++++++- app/services/plaid_service.py | 105 ++++++++++++++++++++- app/templates/plaid/index.html | 33 +++++++ requirements.txt | 2 + 9 files changed, 449 insertions(+), 44 deletions(-) create mode 100644 app/routes/health.py diff --git a/.env.example b/.env.example index f61a894..caf9ce3 100644 --- a/.env.example +++ b/.env.example @@ -13,3 +13,4 @@ FLASK_APP=wsgi:app PLAID_CLIENT_ID=your-plaid-client-id PLAID_SECRET=your-plaid-secret PLAID_ENV=sandbox +PLAID_WEBHOOK_URL=https://pfm.ngodanguyen.tech/plaid/webhook diff --git a/CLAUDE.md b/CLAUDE.md index e89647b..1561cf5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,7 +7,7 @@ ## 1. Project Overview -Self-hosted personal finance web app. Tracks income, expenses, investments. AI assistant powered by **Groq API** (free tier, fast inference, no local hardware). Receipt OCR via Groq vision model. Bank account sync via Teller API (mTLS) and Schwab Developer API (OAuth 2.0). Bank statement import (CSV, OFX/QFX, PDF). Everything runs on Ubuntu server behind Nginx + Certbot SSL. +Self-hosted personal finance web app. Tracks income, expenses, investments. AI assistant powered by **Groq API** (free tier, fast inference, no local hardware). Receipt OCR via Groq vision model. Bank account sync via Teller API (mTLS), Schwab Developer API (OAuth 2.0), and Plaid API. Bank statement import (CSV, OFX/QFX, PDF). Everything runs on Ubuntu server behind Nginx + Certbot SSL. **Status: All 7 phases complete + all post-MVP features implemented.** @@ -30,16 +30,24 @@ Self-hosted personal finance web app. Tracks income, expenses, investments. AI a - Stale indicator if rate > 1 day old - Period selector: This Month / Last Month / Custom date range - Credit card accounts display "owed" balance (positive Amount Owed) not raw negative +- **Checking & Savings card** — sum of balances for `checking`, `savings`, `cash` account types +- **Investments card** — sum of balances for `investment`, `crypto` account types +- **Reconcile button** — AJAX `GET /api/reconcile`; excludes transactions in any category whose name contains "transfer" (case-insensitive); updates Income / Expenses / Net Cash Flow / Savings Rate cards in-place; toggles back to original; shows notice with excluded amounts and category names ### 2.2 Transactions - Income + Expense entry with Income/Expense tabs - Transfer between accounts - Filter: search, category, account, date range (safe int parsing — no crash on bad params) +- **Quick date filters** — "This Month" and "Last Month" buttons above the filter bar; active button highlighted; ✕ clear button shown when a quick filter is active - Pagination (30/page) - Receipt upload (PNG/JPG/WEBP/GIF/PDF, max 10MB) - **AI Receipt OCR** — drag-drop receipt image → Groq vision extracts amount/date/merchant/category → auto-fills form - Re-extract from already-uploaded receipt (edit mode) - **Inline category change** — Category column is a ` + AJAX; pagination info +│ │ ├── dashboard/index.html # + savings_rate card; Schwab warning; Reconcile btn; Checking/Savings + Investments cards +│ │ ├── accounts/index.html # Teller/Schwab/Plaid badges + action buttons; Plaid CC billing card +│ │ ├── transactions/index.html # inline category + + + {% endif %} + + + {% if items %} {% for item in items %}
diff --git a/requirements.txt b/requirements.txt index ad2bed4..eb2f6e7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,3 +22,5 @@ pyotp==2.9.0 qrcode==7.4.2 # Monitoring sentry-sdk[flask]==2.7.0 +# Plaid webhook JWT verification (requires cryptography extra, already installed above) +PyJWT==2.9.0