|
| 1 | +# FinMind — AI-Powered Budget & Bill Tracking |
| 2 | + |
| 3 | +FinMind helps users control spending, track bills, and get smart financial insights. Built for free-tier friendly deployment with scalable architecture. |
| 4 | + |
| 5 | +## System Architecture |
| 6 | + |
| 7 | +```mermaid |
| 8 | +flowchart LR |
| 9 | + subgraph Client |
| 10 | + A[React + Vite + TS] |
| 11 | + A -->|JWT| LS[(LocalStorage)] |
| 12 | + end |
| 13 | +
|
| 14 | + subgraph Edge |
| 15 | + CDN[CDN/Vercel Edge] |
| 16 | + end |
| 17 | +
|
| 18 | + subgraph Backend[Flask API] |
| 19 | + API[Flask + Gunicorn] |
| 20 | + JWT[PyJWT] |
| 21 | + AI[Insights Service] |
| 22 | + SCH[Scheduler/APScheduler] |
| 23 | + end |
| 24 | +
|
| 25 | + subgraph Data |
| 26 | + PG[(PostgreSQL)] |
| 27 | + RD[(Redis)] |
| 28 | + end |
| 29 | +
|
| 30 | + subgraph ThirdParty |
| 31 | + TW[Twilio WhatsApp] |
| 32 | + SMTP[Email Provider] |
| 33 | + OAI[OpenAI or Local ML] |
| 34 | + end |
| 35 | +
|
| 36 | + A -->|HTTPS| CDN --> API |
| 37 | + API -->|ORM| PG |
| 38 | + API -->|Cache| RD |
| 39 | + API -->|JWT verify| JWT |
| 40 | + API -->|reminder jobs| SCH |
| 41 | + SCH --> TW |
| 42 | + SCH --> SMTP |
| 43 | + AI --> OAI |
| 44 | +``` |
| 45 | + |
| 46 | +## PostgreSQL Schema (DDL) |
| 47 | +See `backend/app/db/schema.sql`. Key tables: |
| 48 | +- users, categories, expenses, bills, reminders |
| 49 | +- ad_impressions, subscription_plans, user_subscriptions |
| 50 | +- refresh_tokens (optional if rotating), audit_logs |
| 51 | + |
| 52 | +## Redis Caching Policy |
| 53 | +- Keys |
| 54 | + - `user:{id}:monthly_summary:{yyyy-mm}` — 30 min TTL |
| 55 | + - `user:{id}:categories` — 24h TTL |
| 56 | + - `user:{id}:upcoming_bills` — 15 min TTL |
| 57 | + - `insights:{id}` — 24h TTL (invalidate on new expense/bill) |
| 58 | +- Invalidation |
| 59 | + - On expense/bill create/update/delete -> delete affected monthly_summary, upcoming_bills, insights |
| 60 | +- Rate limiting (optional): `rl:{userId}:{endpoint}:{minute}` with short TTL |
| 61 | + |
| 62 | +## API Endpoints |
| 63 | +OpenAPI: `backend/app/openapi.yaml` |
| 64 | +- Auth: `/auth/register`, `/auth/login`, `/auth/refresh` |
| 65 | +- Expenses: CRUD `/expenses` |
| 66 | +- Bills: CRUD `/bills`, pay/mark `/bills/{id}/pay` |
| 67 | +- Reminders: CRUD `/reminders`, trigger `/reminders/run` |
| 68 | +- Insights: `/insights/monthly`, `/insights/budget-suggestion` |
| 69 | + |
| 70 | +## MVP UI/UX Plan |
| 71 | +- Auth screens: register/login. |
| 72 | +- Dashboard: |
| 73 | + - Monthly spend chart, category breakdown donut. |
| 74 | + - Upcoming bills list with due dates and pay status. |
| 75 | + - AI budget suggestion card. |
| 76 | +- Expenses page: add expense (amount, category, notes, date), list & filter. |
| 77 | +- Bills page: create bill (name, amount, cadence, due date, channel), toggle WhatsApp/email. |
| 78 | +- Settings: profile, categories, reminders default channel, export (premium). |
| 79 | + |
| 80 | +## Monetization Plan |
| 81 | +- Free: ads in dashboard and list pages (lightweight, non-intrusive). Record impressions in `ad_impressions`. |
| 82 | +- Premium ($/mo): CSV/Excel export, multi-device sync, priority insights, remove ads. |
| 83 | +- Payments stubbed; swap in Stripe when moving off free tier. |
| 84 | + |
| 85 | +## Organic Marketing Strategies |
| 86 | +- Content: budgeting tips, “FinMind monthly challenge” on socials. |
| 87 | +- SEO: landing with calculators (50/30/20, debt snowball), schema markup. |
| 88 | +- Communities: Reddit PF, indie hackers build-in-public. |
| 89 | +- Referral: give 1 month premium for inviting 3 friends. |
| 90 | + |
| 91 | +## Project Structure |
| 92 | +``` |
| 93 | +finmind/ |
| 94 | + backend/ |
| 95 | + app/ |
| 96 | + __init__.py |
| 97 | + config.py |
| 98 | + extensions.py |
| 99 | + models.py |
| 100 | + routes/ |
| 101 | + __init__.py |
| 102 | + auth.py |
| 103 | + expenses.py |
| 104 | + bills.py |
| 105 | + reminders.py |
| 106 | + insights.py |
| 107 | + services/ |
| 108 | + __init__.py |
| 109 | + ai.py |
| 110 | + cache.py |
| 111 | + reminders.py |
| 112 | + db/ |
| 113 | + schema.sql |
| 114 | + openapi.yaml |
| 115 | + wsgi.py |
| 116 | + requirements.txt |
| 117 | + Dockerfile |
| 118 | + frontend/ |
| 119 | + index.html |
| 120 | + src/ |
| 121 | + main.tsx |
| 122 | + App.tsx |
| 123 | + components/ |
| 124 | + AdBanner.tsx |
| 125 | + Charts.tsx |
| 126 | + pages/ |
| 127 | + Dashboard.tsx |
| 128 | + Expenses.tsx |
| 129 | + Bills.tsx |
| 130 | + Settings.tsx |
| 131 | + package.json |
| 132 | + tsconfig.json |
| 133 | + vite.config.ts |
| 134 | + Dockerfile |
| 135 | + .github/ |
| 136 | + workflows/ |
| 137 | + ci.yml |
| 138 | + docker-compose.yml |
| 139 | + .env.example |
| 140 | +``` |
| 141 | + |
| 142 | +## Deployment |
| 143 | +- Backend: Dockerized Flask to Railway/Render free tier (Postgres & Redis managed or via Compose locally). |
| 144 | +- Frontend: Vercel. |
| 145 | +- Secrets: use environment variables (.env locally, platform secrets in cloud). |
| 146 | + |
| 147 | +## Local Development |
| 148 | +1) Prereqs: Docker, Docker Compose, Node 20+, Python 3.11+ |
| 149 | +2) Copy env: `cp .env.example .env` and fill secrets |
| 150 | +3) Start: `docker compose up --build` |
| 151 | +4) Frontend at http://localhost:5173, Backend at http://localhost:8000 |
| 152 | + |
| 153 | +## Testing & CI |
| 154 | +- Backend: pytest, flake8, black. Frontend: vitest, eslint. |
| 155 | +- GitHub Actions `ci.yml` runs lint, tests, and builds both apps; optional docker build. |
| 156 | + |
| 157 | +## Notes on Free-Tier Reminders |
| 158 | +- Primary: schedule via APScheduler in-process with persistence in Postgres (job table) and a simple daily trigger. Alternatively, use Railway/Render cron to hit `/reminders/run`. |
| 159 | +- Twilio WhatsApp free trial supports sandbox; email via SMTP (e.g., SendGrid free tier). |
| 160 | + |
| 161 | +## Security & Scalability |
| 162 | +- JWT access/refresh, secure cookies OR Authorization header. |
| 163 | +- RBAC-ready via roles on `users.role`. |
| 164 | +- N+1 avoided via SQLAlchemy eager loading. |
| 165 | +- Redis caching for hot paths to cut DB load. |
| 166 | +- 12-factor app env config; stateless API. |
| 167 | + |
| 168 | +--- |
| 169 | + |
| 170 | +MIT Licensed. Built with ❤️. |
0 commit comments