A self-hosted personal finance dashboard for tracking income, budgets, investments, net worth, and retirement projections — all in one place. Runs on SQLite with zero configuration, or PostgreSQL for larger deployments. No external SaaS dependencies; budget-provider sync is an optional integration.
- Retirement planning — A full accumulation-and-decumulation projection engine with Monte Carlo simulation (labeled Simulation in the app), validated against Trinity Study benchmarks. Per-person retirement ages, Social Security amounts and start ages, and pre-retirement raise rates. Nine withdrawal strategies (Fixed, Forgo Inflation After Loss, Spending Decline, Constant Percentage, Endowment, Vanguard Dynamic, Variable Percentage Withdrawal, Guyton-Klinger, RMD Spending) and three withdrawal-routing modes (Bracket Filling — Traditional up to a target tax bracket, then the cheapest remaining source each year; Waterfall — accounts in a set priority order; Percentage — fixed shares). Retirement answers count retirement accounts only — savings tagged Portfolio never prop up the plan. Models RMDs and RMD smoothing, Qualified Charitable Distributions, the age-65+ standard deduction and the temporary OBBBA senior deduction, IRMAA cliff detection with a two-year MAGI lookback, ACA premium-subsidy cliffs, Rule-of-55 and early-withdrawal-penalty rules, lump-sum injections and withdrawals, and a multi-year Roth-conversion bracket-target optimizer.
- Profiles and Plans — Salary, Contribution, Budget and Retirement profiles, each its own complete set of assumptions; a Plan is a saved set of one of each, applied in one step. A Retirement Profile can keep a specific tax year's tables so an old projection reproduces exactly.
- Projection Health — A card that surfaces contribution-order warnings, glide-path mismatches, rosy-assumption flags, and a recommended withdrawal strategy in context.
- Print Full Report — A purpose-built multi-page document: executive summary, Monte Carlo risk analysis with worst-case framing, a withdrawal-strategy narrative, an ACA/IRMAA watchlist, action items, and a condensed year-by-year table.
- Coast FIRE — Automatic Coast FIRE age plus a custom-age check for any age between now and your planned retirement.
- Tax Buckets — Per-account analysis of how much of each balance is reachable now, split into penalty-free and tax-free portions, with Roth ordering rules and Rule-of-55 eligibility applied.
- What-If — Try changes in a sandbox that never touches your active profiles; save the result as profiles when you want to keep it.
- Milestones & Recommendations — Money Guy, Bogleheads and Fidelity rules and your own goals judged once (reached, on track, behind), plus a ranked list of what to do next.
- Paycheck Calculator — Gross-to-net breakdown with federal tax withholding, FICA, Additional Medicare Tax, deductions, and 401k/HSA/IRA contributions. Multiple pay frequencies and filing statuses; a tax-year toggle to compare years.
- Budget — Category-based budgeting with per-profile funding, extra-paycheck handling, and optional two-way sync with YNAB or Actual Budget. Track spending against targets with drift detection.
- Portfolio — Multi-account portfolio with asset allocation, performance history, tax-location analysis, contribution-account tracking, and rebalancing tools. Snapshot pushes to YNAB/Actual post as reconciled.
- Contributions — Household contribution analysis: savings-rate summary, per-person account breakdown, employer-match analysis, IRS-limit enforcement, prior-year tax contributions, and multiple contribution profiles with a swap-diff compare view.
- Net Worth — Year-over-year net worth with asset and liability breakdowns, trend visualization, and a financial-independence progress card.
- Savings Goals — Fund-based savings tracking with per-profile contribution allocation, planned transactions, and projections; optional category links to YNAB/Actual.
- Mortgage — Amortization tables, refinance comparison, and extra-payment modeling.
- Expenses — Expense tracking and categorization across accounts.
- Assets & Liabilities — Detailed tracking of real estate, vehicles, and other assets alongside debts and obligations.
- Performance & Historical — Investment performance analytics and historical data views.
- Investments & Benchmarks — Holdings and fund facts from SimpleFIN, allocation vs your target glide path, costs, and how the same money would have done in an index.
- Taxes — This year's household tax, Roth IRA eligibility (MAGI), and a tax-optimization view of retirement withdrawals.
- Tools — Relocation analysis: compare projected cost of living and net outcome across locations.
- Upkeep — Track utility services and meter readings over time.
- Tax engine — Federal tax with 2025/2026 brackets verified against IRS Publication 15-T and Rev. Proc. 2025-32, FICA, Additional Medicare Tax, LTCG graduated rates (progressive stacking), NIIT surtax, SECURE 2.0 super catch-up contributions, and Social Security taxation. Contribution limits, tax brackets, LTCG brackets, IRMAA brackets, and Federal Poverty Level figures live in the database with year and filing-status versioning, editable from Settings. A CI freshness check fails the build if the calendar year moves past the latest pinned tax year without a deliberate override.
- Credential encryption at rest — YNAB, Actual Budget, and SimpleFIN tokens are encrypted with AES-256-GCM before being stored. Rows stored as plaintext by older versions are encrypted by the upgrade's migration.
- SSRF protection — YNAB, SimpleFIN, Tiingo and SEC requests must be
httpsto a public host, checked both before sending and at the address connected (RFC1918, loopback, link-local and single-label hosts are refused). The Actual Budget server URL is used as entered, LAN addresses and Docker service names included, so only an admin can save or test a budget connection (YNAB or Actual): it can point Ledgr's requests at a host on its network. Redirects stay on the same host for every service, so credentials never reach another one. - RBAC — Role-based access control via Authentik OIDC with granular viewer permissions, plus a standalone local-admin table for deployments without an identity provider. Only an admin sets up an integration (YNAB, Actual Budget, SimpleFIN, Tiingo, SEC) and its account links and mappings; a viewer with the
syncpermission can run a sync from the header, push a portfolio snapshot again, and refresh SEC fund facts. - Onboarding wizard & demo mode — Guided first-run setup with demo profiles to explore before entering real data; a separate read-only
DEMO_ONLYmode with a profile chooser and no login. - Dark mode & accessibility — Full dark/light theming with semantic design tokens and a CI-enforced theme audit. WCAG AA-aligned contrast,
prefers-reduced-motionsupport, keyboard skip-to-content, focus trapping in dialogs, screen-reader error announcements, and ARIA coverage on inline icons and table semantics. - Versioning & backup — Automatic database snapshots on startup, plus a backup before each migration. Cross-version backup import transforms data from any older schema era (v0.2 onward) to the current shape. An import or restore by a viewer with the
versionpermission keeps today's integration credentials and Server URLs, and takes each integration's account links and last sync time from the backup; an admin's carries them whole.pnpm backup:export/pnpm backup:importfor headless use, andscripts/encrypted-backup.shwrapspg_dumpin AES-256 encryption for off-site backups. - Raw Data Browser — Admin-only live database table viewer with row counts, column metadata, pagination, and JSON export.
- Help & Guide — A walkthrough of every feature by section, plus an in-app glossary for finance jargon.
- Health checks —
/api/healthfor container orchestration; an authenticated/api/health/detailed(gated byCRON_SECRET) exposes pool stats, integration status and each scheduled job's last result.
git clone https://github.com/smdion/PersonalFinanceImproved.git ledgr && cd ledgr
cp .env.example .env
# Edit .env: set NEXTAUTH_SECRET, CRON_SECRET and ENCRYPTION_KEY (see below)
# SQLite, zero config:
docker compose up -d
# Or PostgreSQL (also set POSTGRES_PASSWORD in .env):
# docker compose -f docker-compose.postgres.yml up -dBy default Ledgr uses SQLite — no database setup required. On first launch, migrations run automatically, the sign-in page asks you to create the first admin, and the onboarding wizard then sets up your household.
Finish first-run setup (create the admin) before you expose the port or put a public proxy in front of it.
Both compose files pass every variable in .env to the container, so the optional ones below (Authentik, TZ, LEDGR_BACKUP_DIR, …) need no compose edits. Until each required variable is set, docker compose refuses to start and names the one that's missing.
# Each is an independent random 32-byte base64 value
openssl rand -base64 32 # NEXTAUTH_SECRET
openssl rand -base64 32 # CRON_SECRET
openssl rand -base64 32 # ENCRYPTION_KEYENCRYPTION_KEY protects at-rest encryption of budget-provider API tokens. In DEMO_ONLY mode it can be omitted — demo mode blocks all credential writes at the server layer.
All configuration is through environment variables. Copy .env.example to .env and adjust.
| Variable | Description | Default |
|---|---|---|
NEXTAUTH_URL |
Full URL where the app is hosted (e.g. http://localhost:3000) |
(none — must set) |
NEXTAUTH_SECRET |
Random secret for session encryption. openssl rand -base64 32 |
(none — must set) |
AUTH_TRUST_HOST |
Trust the X-Forwarded-Host header (set true behind a reverse proxy) |
true |
CRON_SECRET |
Secret token for authenticating cron/health API calls. Required in production — startup fails without it | (none — must set) |
ENCRYPTION_KEY |
32-byte base64 key for AES-256-GCM encryption of integration credentials at rest. Required in production; not required in DEMO_ONLY |
(none — must set) |
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string (e.g. postgresql://user:pass@host:5432/ledgr). Omit for SQLite. |
(none — SQLite) |
SQLITE_PATH |
Path to the SQLite database file (used only when DATABASE_URL is unset) |
data/ledgr.db |
| Variable | Description | Default |
|---|---|---|
LEDGR_TAX_DATA_SYNC |
off disables the weekly check for community tax-data releases on this server |
(on when an admin turns it on) |
| Variable | Description |
|---|---|
ALLOW_DEV_MODE |
next dev only: true skips sign-in and makes every request an admin (without it, a read-only viewer). Refused in production builds |
AUTH_AUTHENTIK_ISSUER |
Authentik OIDC issuer URL (e.g. https://auth.example.com/application/o/ledgr). Without it, sign-in is local admin only. Read at runtime: the login page offers Authentik when the running server has it |
AUTH_AUTHENTIK_ID |
Authentik OIDC client ID |
AUTH_AUTHENTIK_SECRET |
Authentik OIDC client secret |
DEMO_ONLY |
Set true for demo-only mode — no login, read-only, with a profile chooser |
TRUSTED_PROXY_HEADER |
Which header names the client for rate limits and the sign-in throttle: unset uses X-Real-IP, else the last X-Forwarded-For hop (safe only behind a proxy that overwrites them, like SWAG); x-real-ip or x-forwarded-for trusts only that one; none (no proxy in front) puts every visitor in one shared bucket, so 5 failed sign-ins from anyone lock every visitor out for 15 minutes |
| Variable | Description | Default |
|---|---|---|
LEDGR_ALERT_WEBHOOK_URL |
An http or https URL that gets a JSON POST (source, job, event, ok, message, startedAt; no figures or secrets) when a scheduled job starts failing (failed), every 24 h while it still fails (still_failing) and once when it recovers (recovered). Any service that takes a JSON webhook works. A user name or password in the URL isn't accepted (nothing is sent): use a URL with a token in its path or query, as ntfy, Gotify and Discord do. The alert state is in memory, so a restart clears it: after a redeploy a job that recovered posts no recovered, and one still failing posts failed again. Each job's last result is also in /api/health/detailed |
(none — off) |
YNAB, Actual Budget, SimpleFIN and Tiingo credentials and the SEC contact are not configured via environment variables. Sign in as an admin and set them up in Settings → Integrations; that page and everything on it are admin-only. Whatever you enter is encrypted at rest with AES-256-GCM using ENCRYPTION_KEY before being stored in api_connections.
┌──────────────────────────────────────────────┐
│ Browser │
│ (React 19 + Recharts) │
└──────────────┬───────────────────────────────┘
│ tRPC (type-safe RPC)
┌──────────────▼───────────────────────────────┐
│ Next.js 16 │
│ App Router + API Routes │
│ NextAuth (Authentik OIDC / local admin) │
├──────────────────────────────────────────────┤
│ tRPC Routers │
│ (paycheck, budget, portfolio, …) │
├──────────────────────────────────────────────┤
│ Drizzle ORM (strict) │
└──────────────┬───────────────────────────────┘
│ SQL
┌──────────────▼───────────────────────────────┐
│ SQLite (default) or PostgreSQL 16 │
│ (migrations managed by Drizzle Kit) │
└──────────────────────────────────────────────┘
Layers (one manifest, .dependency-cruiser.mjs; pnpm check:layers holds the import directions in CI):
| Layer | Where | Holds |
|---|---|---|
| UI | src/app/, src/components/, src/lib/hooks/ |
pages and components; reads through tRPC, never imports server code |
| Routers | src/server/routers/ |
parse input, call a service, a read or a pure function, return |
| Services | src/server/services/ |
composition that needs I/O |
| Data | src/server/data/ |
shared reads |
| Infrastructure | src/lib/db/, src/lib/budget-api/, src/lib/simplefin/, … |
database, outside services, crypto |
| Pure | src/lib/pure/<area>/, engine in src/lib/pure/engine/ |
every calculation; no I/O |
| Foundation | src/lib/config/, src/lib/constants/, src/lib/utils/ |
config, constants, small helpers |
One figure, traced: the Budget page's take-home pay reads paycheck.computeSummary (src/server/routers/paycheck.ts), which calls computePaycheckSummary (src/server/services/paycheck/summary.ts); that loads the active profiles, the people and the year's tax tables (tax_brackets, tax_params, seeded from tax-data/us-federal/) and calls calculatePaycheck (src/lib/pure/paycheck/per-check.ts), which does the math.
Key design decisions (the full list: docs/DECISIONS.md):
- End-to-end type safety — TypeScript strict mode from the database schema (Drizzle) through the API (tRPC) to the UI (React).
- Data-driven design — Account-type behavior is declared in one config record; adding an account type is one entry, not code changes. Tax tables and limits are data, versioned by year.
- Single source of truth for schema —
src/lib/db/pg/*.ts(re-exported byschema-pg.ts) define the model;schema-sqlite.tsis generated from it. Each release line starts from a squashed baseline; later migrations are incremental. - Self-hosted — No external SaaS dependencies. SQLite by default, PostgreSQL supported. Budget-provider sync is optional.
- Node.js 26+
- pnpm (
npm install -g pnpm) - PostgreSQL 16+ (optional — SQLite is used by default)
pnpm install
cp .env.example .env
# Edit .env — set NEXTAUTH_SECRET and CRON_SECRET; optionally DATABASE_URL for PostgreSQL
pnpm db:migrate
pnpm devOpen http://localhost:3000. On first launch you'll see the onboarding wizard.
| Command | Description |
|---|---|
pnpm dev |
Start the development server |
pnpm build |
Production build |
pnpm start |
Not for this build: standalone output runs node server.js |
pnpm test |
Run all tests |
pnpm test:watch |
Run tests in watch mode |
pnpm test:e2e |
End-to-end browser tests (Playwright) |
pnpm test:coverage |
Run with coverage thresholds |
pnpm lint |
ESLint + Prettier check |
pnpm format |
Auto-format with Prettier |
pnpm db:generate |
Generate a migration from schema changes |
pnpm db:migrate |
Run pending migrations |
pnpm seed [name] |
Load an invented demo household into an empty dev database |
pnpm db:studio |
Open Drizzle Studio (visual DB browser) |
pnpm backup:export |
Export all data to JSON (stdout or --out) |
pnpm backup:import |
Import a JSON backup (supports --dry-run) |
After editing src/lib/db/pg/*.ts, regenerate the SQLite schema with npx tsx scripts/gen-sqlite-schema.ts — never edit schema-sqlite.ts by hand.
| Mode | When | How |
|---|---|---|
| Local Admin | Always available | Email/password against a local_admins table. On a fresh install, /login offers "Create the first admin" until one exists (or onboarding is completed through Authentik). Sign-ins are throttled: after 5 attempts from one address, or 10 for one email (from an address that already failed), that address or email waits up to 15 minutes; a sign-in resets both counts. |
| Authentik OIDC | AUTH_AUTHENTIK_ISSUER is set |
SSO with RBAC group mapping. Shown alongside the local-admin form. |
| Dev Mode | Running next dev |
No sign-in: a fixed session, admin with ALLOW_DEV_MODE=true, otherwise a read-only viewer. Never in production. |
Local admin is the default install's sign-in: Authentik is optional, and without AUTH_AUTHENTIK_ISSUER the login page offers only the local-admin form. With Authentik configured, the local-admin form stays on purpose: it is the break-glass sign-in when Authentik is down or its groups are misconfigured, throttled the same way. Keep at least one local admin with a strong password, and keep it out of everyday use.
The included Dockerfile is a multi-stage build producing a minimal image:
- deps —
pnpm install --frozen-lockfile - builder — Next.js standalone build
- runner — minimal Alpine image with only the standalone build, migrations, and a non-root
nextjsuser
docker-entrypoint.sh runs pending migrations before starting the server.
docker compose up -d --build
docker compose logs -f ledgr
docker compose restart ledgrProduction notes:
- Listens on port 3000 by default.
- Built-in healthcheck hits
/api/healthevery 30 seconds. - Memory limit of 1 GB is set in
docker-compose.yml. - For HTTPS, put a reverse proxy (NGINX, Caddy, Traefik, …) in front and set
NEXTAUTH_URLto your public URL andAUTH_TRUST_HOST=true. - SQLite mode: the
ledgr_datavolume persists the database file across restarts. PostgreSQL mode: data lives in the PostgreSQL instance; theledgr_datavolume keeps the migrator's pre-upgrade backups.
Migrations are managed by Drizzle Kit: each release line starts from a squashed baseline (0000_v<N>_initial_schema) and adds incremental migrations. On startup db-migrate.ts writes a pre-upgrade JSON backup, applies pending migrations, then reconciles the reference tax data. An install from an older release line is recognised by its baseline and re-baselined without data loss.
- Create an OAuth2/OIDC application in Authentik for Ledgr.
- Set the redirect URI to
https://your-domain/api/auth/callback/authentik. - Put the client ID and secret into
AUTH_AUTHENTIK_ID/AUTH_AUTHENTIK_SECRET. - Set
AUTH_AUTHENTIK_ISSUERto the issuer URL.
All of these are configured from Settings → Integrations, by an admin — there are no credential environment variables. Only one budget provider (YNAB or Actual) can be active at a time; SimpleFIN, Tiingo and SEC EDGAR run alongside either.
- YNAB (You Need A Budget) — Generate a personal access token at YNAB Developer Settings, paste it in, and pick a budget. Syncs accounts, categories, monthly summaries, and transactions. Two-way: category-goal targets and portfolio snapshots can be pushed back.
- Actual Budget — Requires a running Actual Budget HTTP API wrapper in front of your Actual server. Enter the server URL, API key, and budget sync ID. Any host you enter is used, LAN addresses and Docker service names (such as
http://actual-http-api:5007) included; the URL must behttporhttpswith no user name or password in it. Pin the wrapper tojhonderson/actual-http-api26.10.0 (commit 8ef9a0ca), and move it together withactual-serverto the same version. The wrapper checks its API key only whenNODE_ENV=production(its Docker image sets it). Set the wrapper'sTZto the household's time zone: it reads the end and cutoff dates Ledgr sends with each list and balance read as its own local dates. - SimpleFIN Bridge — Read-only daily data per linked account: balances, holdings and investment transactions (used for live balances, benchmarks, holdings history and suggested Performance fills). A SimpleFIN account linked to a mortgage feeds that loan's balance; while it does, budget pulls leave the loan alone. No budget sync.
- Tiingo — An API key for end-of-day index prices, used for the benchmark comparisons. The host is fixed.
- SEC EDGAR — Fund facts (expense ratios and share classes) from public filings. SEC requires a contact in every request, so you enter an email address: it is sent to SEC with each request and identifies you to them. It is stored encrypted and never logged.
- Tax data updates — Optional, off unless you turn it on (onboarding offers it). Once a week Ledgr checks this project's signed tax-data release on GitHub for new tax figures between Ledgr updates — one plain download from
github.com, nothing about your household sent. A newer file is verified against a key built into Ledgr and checked, then waits in Settings → Reference Data for an admin to review and apply; figures you've changed are never touched.LEDGR_TAX_DATA_SYNC=offturns it off for the whole server. Behind a proxy, setNODE_USE_ENV_PROXY=1.
The integration layer hardens every outbound call: typed error classification, exponential backoff with Retry-After support on rate limits, every response checked against its endpoint's schema before anything is written, duplicate guards on writes (each push's transactions carry an import id, so a push finds what it posted when a response was lost; a POST is resent only after a rate limit), and drift detection after every sync that surfaces broken account mappings in the UI.
Sign-in runs on next-auth 5.0.0-beta.32, a pre-release of Auth.js v5, pinned exactly so an update never arrives unreviewed. A beta gets fixes on its own schedule, and a security fix reaches Ledgr only when the pin is raised in a release. The plan is to move sign-in to Better Auth, a stable release line, in a release of its own after v0.11.0; until then the pin stays and its advisories are watched (pnpm audit runs in CI). Credential encryption, request-target checks and permissions are under Features → Platform.
6,000+ tests across 530+ Vitest files plus 15 Playwright end-to-end specs — covering the financial calculators, retirement benchmarks, server and router logic, UI components, database migrations and backup transforms, theme-token regressions, and full browser flows. CI enforces coverage thresholds of 85% statements / 70% branches / 80% functions / 85% lines, and also runs the lint/type-check, a file-size guard, a tax-parameter freshness check, a migration safety check, and a documentation-freshness check.
pnpm test # Run once
pnpm test:watch # Watch mode
pnpm test:e2e # End-to-end browser tests (Playwright)
pnpm test:coverage # Run with coverage thresholds- Next.js 16 — App Router, Turbopack, standalone output
- React 19
- TypeScript — strict mode
- tRPC 11 — end-to-end type-safe API
- Drizzle ORM + SQLite / PostgreSQL 16
- Tailwind CSS 4
- Recharts
- NextAuth.js (v5) — Authentik OIDC / local admin
- Zod 4 — runtime validation
- Vitest 4 + Playwright — testing
Contributions are welcome. Please open an issue to discuss before submitting a PR.