mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 11:08:47 +02:00
The baseline (c3da001a0eb3) was autogenerated against an empty Postgres and schema-diffed against the live dev schema until column-identical (two model fixes fell out: deferred_to_next_cycle now declares its server_default, usersettings.data is JSONB on Postgres to match the live type). Startup replaces init_db/run_migrations with run_alembic_upgrade(): pre-Alembic databases that already match the baseline are adopted via stamp; fresh databases build from the migration. The section is serialized with a pg advisory lock because prod uvicorn runs 2 workers, each executing the lifespan. Verified: adoption + idempotent re-run on the dev DB, fresh 13-table build on an empty DB, full container boot, 55/55 tests. (ARCH-02, BE-19) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
71 lines
2.2 KiB
Markdown
71 lines
2.2 KiB
Markdown
# WealthySmart
|
|
|
|
Personal finance management web app.
|
|
|
|
## Stack
|
|
|
|
- **Frontend:** React 19 + Vite + TypeScript + Tailwind CSS 4
|
|
- **Package manager:** pnpm
|
|
|
|
## Development
|
|
|
|
```bash
|
|
cd frontend && pnpm install && pnpm run dev
|
|
```
|
|
|
|
The backend refuses to boot without `SECRET_KEY`, `ADMIN_USERNAME`, and
|
|
`ADMIN_PASSWORD` (no insecure defaults). Copy `.env.example` to `.env` and fill
|
|
it in; the dev docker-compose reads it.
|
|
|
|
## Database Migrations
|
|
|
|
Schema changes go through Alembic — never edit the schema by hand and never
|
|
reset the prod DB. Workflow:
|
|
|
|
```bash
|
|
cd backend
|
|
# 1. Edit app/models/models.py
|
|
# 2. Autogenerate against the dev DB, then REVIEW the generated file
|
|
DATABASE_URL='postgresql://wealthy_user:wealthy_pass@localhost:5433/wealthysmart' \
|
|
.venv/bin/alembic revision --autogenerate -m "describe the change"
|
|
# 3. Migrations apply automatically at app startup (run_alembic_upgrade)
|
|
```
|
|
|
|
## Tests
|
|
|
|
```bash
|
|
cd backend && .venv/bin/python -m pytest tests/ -q # backend (55+ tests)
|
|
cd frontend && pnpm typecheck # frontend
|
|
```
|
|
|
|
## Local Docker
|
|
|
|
```bash
|
|
# Backend + DB containers
|
|
docker exec wealthysmart-db-dev psql -U wealthy_user -d wealthysmart -c 'SQL;'
|
|
```
|
|
|
|
## Deployment
|
|
|
|
- Deployed via Gitea Actions (self-hosted runner on VPS)
|
|
- Push to `main` triggers: GitHub → webhook → Gitea mirror sync → Actions workflow → Docker build & deploy
|
|
- Domain: wealth.cescalante.dev
|
|
- Reverse proxy: nginx-proxy + acme-companion (auto TLS)
|
|
|
|
## Infrastructure
|
|
|
|
- **Single server**: `ssh old-vps` — runs everything (WealthySmart, n8n, Forgejo, Vaultwarden, nginx-proxy)
|
|
- `ssh production` is **NOT valid** — do not use
|
|
- n8n UI: https://n8n.cescalante.dev — n8n DB queryable via `docker exec portfolio-db-prod psql -U portfolio_user -d n8n`
|
|
|
|
## n8n Flows
|
|
|
|
Four automated flows on old-vps feed data into WealthySmart:
|
|
|
|
1. **BAC Credit Card** — Gmail trigger → POST /transactions/
|
|
2. **Salary Deposits** — Gmail trigger → POST /transactions/
|
|
3. **Municipal Receipts** — Cron trigger → POST /municipal-receipts/upload
|
|
4. **Pension PDFs** (`e88c3UhBeo9WCbcy`) — Gmail trigger (daily midnight) → POST /pensions/upload
|
|
|
|
Flow export: `docs/WealthySmart_ BAC Pensions Statements parser.json`
|