{"id":50987018,"url":"https://github.com/dasgoutam/personal-finance","last_synced_at":"2026-06-19T20:31:06.440Z","repository":{"id":359574141,"uuid":"1180890609","full_name":"dasgoutam/personal-finance","owner":"dasgoutam","description":"Self hosted personal finance application with double-entry accounting","archived":false,"fork":false,"pushed_at":"2026-06-17T16:03:03.000Z","size":224,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-17T18:05:42.898Z","etag":null,"topics":["finance-management","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"Svelte","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dasgoutam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-13T14:20:25.000Z","updated_at":"2026-06-17T16:05:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dasgoutam/personal-finance","commit_stats":null,"previous_names":["dasgoutam/personal-finance"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dasgoutam/personal-finance","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasgoutam%2Fpersonal-finance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasgoutam%2Fpersonal-finance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasgoutam%2Fpersonal-finance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasgoutam%2Fpersonal-finance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dasgoutam","download_url":"https://codeload.github.com/dasgoutam/personal-finance/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasgoutam%2Fpersonal-finance/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34547787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-19T02:00:06.005Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finance-management","raspberry-pi"],"created_at":"2026-06-19T20:31:05.264Z","updated_at":"2026-06-19T20:31:06.428Z","avatar_url":"https://github.com/dasgoutam.png","language":"Svelte","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Personal Finance\n\nA self-hosted, single-user personal finance dashboard built with SvelteKit, SQLite, and proper double-entry bookkeeping.\n\n## Stack\n\n| Layer | Choice |\n|---|---|\n| Framework | SvelteKit 2 + TypeScript |\n| Styling | Tailwind CSS |\n| Runtime adapter | `@sveltejs/adapter-node` |\n| Database | SQLite via `better-sqlite3` |\n| ORM / migrations | Drizzle ORM + drizzle-kit |\n| Auth | Lucia v3 (session-based, single user) |\n| Password hashing | Argon2id via `@node-rs/argon2` |\n| Deployment | Docker Compose on Raspberry Pi (linux/arm64) |\n\n## Schema overview\n\n```\naccounts          — chart of accounts (hierarchical via parent_id)\n  type: asset | liability | equity | income | expense\n  currency: ISO 4217 (EUR, INR, …)\n\ntransactions      — a dated, described business event\njournal_entries   — individual debit/credit legs of a transaction\n  ∑ amount per currency must equal 0  ← double-entry constraint\n\ncommodities       — tradeable instruments (ETFs, stocks, mutual funds)\nprices            — historical price series per commodity\n```\n\nAmounts are stored as **integers in the smallest currency unit** (euro-cents for EUR, paise for INR). This avoids floating-point rounding issues.\n\nCommodity quantities use **milli-units** (1 000 = 1 share/unit).\n\n## Local development\n\n### Prerequisites\n\n- Node 20+\n- `npm`\n\n### Setup\n\n```bash\n# 1. Install dependencies\nnpm install\n\n# 2. Copy environment config\ncp .env.example .env\n# Edit .env to set your username/password\n\n# 3. Generate \u0026 apply migrations\nnpm run db:generate   # creates drizzle/migrations/ SQL files (already included)\nnpm run db:migrate    # applies migrations to ./data/finance.db\n\n# 4. Seed with sample data (Germany/India dual-currency accounts)\nnpm run db:seed\n\n# 5. Start dev server\nnpm run dev\n```\n\nOpen http://localhost:5173 and log in with the credentials you set in `.env`\n(defaults: `admin` / `changeme`).\n\n### Available npm scripts\n\n| Script | Description |\n|---|---|\n| `npm run dev` | Start Vite dev server with HMR |\n| `npm run build` | Build production bundle |\n| `npm run preview` | Preview production build locally |\n| `npm run check` | Run `svelte-check` type checker |\n| `npm run db:generate` | Generate SQL migrations from schema changes |\n| `npm run db:migrate` | Apply pending migrations |\n| `npm run db:push` | Push schema directly to DB (dev shortcut, no migration files) |\n| `npm run db:seed` | Seed the database with sample accounts and transactions |\n| `npm run db:studio` | Open Drizzle Studio (web UI for the database) |\n\n## Double-entry constraint\n\nThe constraint is enforced at the application layer in `src/lib/server/finance.ts`.\n`createTransaction()` rejects any transaction where the sum of `amount` values,\ngrouped by `currency`, is not exactly zero.\n\n```\nEUR legs: +400 000 (salary credit to bank)  +  -400 000 (income debit)  = 0 ✓\nINR legs: +500 000 (ETF purchase debit)     +  -500 000 (NRE debit)     = 0 ✓\n```\n\nFor multi-currency transactions (e.g. wire transfers where you send EUR and\nreceive INR) each currency group must independently sum to zero — you model the\nexchange as two matching legs per currency.\n\n## Seed data highlights\n\nThe seed script (`scripts/seed.ts`) creates accounts for a person living in\nGermany with EUR as primary currency and INR for Indian investments:\n\n**Assets (EUR):** DKB Girokonto · DKB Tagesgeld · Bargeld\n**Assets (INR):** Zerodha Portfolio · PPF Account · NRE Savings Account\n**Liabilities:** Visa Kreditkarte\n**Income:** Gehalt · Freiberufliche Einnahmen · Dividenden · Investment Returns (INR)\n**Expenses:** Miete · Strom \u0026 Internet · Lebensmittel · Restaurant · ÖPNV ·\nGesundheit · Freizeit · Kleidung · Transfergebühren\n\n**Commodities:** NIFTYBEES · HDFC Flexi Cap Fund · INFY (Infosys)\n\n**Transactions:** ~25 sample transactions spanning Jan 2024 – Mar 2025,\nincluding salary, rent, groceries, PPF deposit, ETF purchases (with commodity\ntracking), remittance via Wise, and PPF interest credit.\n\n## Raspberry Pi deployment\n\n### Build and run with Docker Compose\n\n```bash\n# On the Pi (or cross-compile from x86 with Docker buildx):\ndocker compose up -d --build\n```\n\nThe SQLite database is stored in a named Docker volume (`finance_data`) so it\nsurvives container rebuilds.\n\n### Seed inside the container\n\n```bash\n# First run only — migrate + seed\ndocker compose exec finance node -e \"\n  const { execSync } = require('child_process');\n  execSync('npm run db:migrate', { stdio: 'inherit' });\n\"\n# Then seed (run the seed script directly with tsx)\ndocker compose run --rm finance sh -c \"npm run db:seed\"\n```\n\nOr copy a pre-seeded database file into the volume:\n\n```bash\ndocker cp ./data/finance.db \\\n  $(docker compose ps -q finance):/data/finance.db\n```\n\n### Reverse proxy (nginx example)\n\n```nginx\nserver {\n    listen 80;\n    server_name finance.local;\n\n    location / {\n        proxy_pass http://127.0.0.1:3000;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n    }\n}\n```\n\n### Environment variables\n\n| Variable | Default | Description |\n|---|---|---|\n| `DATABASE_URL` | `./data/finance.db` | Absolute path to the SQLite file |\n| `FINANCE_USERNAME` | `admin` | Username created by `db:seed` |\n| `FINANCE_PASSWORD` | `changeme` | Password created by `db:seed` |\n| `NODE_ENV` | `development` | Set to `production` in Docker |\n| `PORT` | `3000` | HTTP port the server listens on |\n| `HOST` | `0.0.0.0` | Bind address |\n\n## Project structure\n\n```\nsrc/\n  app.css                     Tailwind entry point\n  app.d.ts                    App.Locals type augmentation for Lucia\n  hooks.server.ts             Session validation on every request\n  lib/\n    server/\n      auth.ts                 Lucia instance + type registration\n      finance.ts              createTransaction() with double-entry guard\n      db/\n        index.ts              better-sqlite3 + Drizzle setup\n        schema.ts             All table definitions + inferred types\n  routes/\n    +layout.server.ts         Pass user to all pages\n    +layout.svelte            Nav bar\n    +page.server.ts           Root redirect (→ /dashboard or /login)\n    login/                    Login form\n    logout/                   POST action to invalidate session\n    dashboard/                Recent transactions + account balances\nscripts/\n  migrate.ts                  Standalone migration runner\n  seed.ts                     Sample data seeder\ndrizzle/\n  migrations/                 SQL migration files (generated by drizzle-kit)\nDockerfile                    Multi-stage ARM64 image\ndocker-compose.yml            Pi deployment\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasgoutam%2Fpersonal-finance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdasgoutam%2Fpersonal-finance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasgoutam%2Fpersonal-finance/lists"}