Skip to content

About

Self-hosted budget tracker — SpacetimeDB + Next.js

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

BudhiDocki

A self-hosted budget tracker for personal and shared finances. Built on SpacetimeDB and Next.js.

Features

  • Multi-budget support -- create separate budgets for different purposes (household, personal, travel)
  • Shared budgets -- invite other users by username, assign roles (Owner / Admin / Member), collaborate in real time
  • Transaction management -- add, edit, delete, and bulk delete transactions with category and tag support
  • Recurring transactions -- define rules (daily, weekly, biweekly, monthly, quarterly, half-yearly, yearly) that automatically generate transactions on schedule
  • Categories -- fully customizable per budget with icons and colors; default category seeded on budget creation
  • Auto-categorization rules -- pattern-based rules that automatically categorize bank-imported transactions; retroactive recategorization supported
  • Spending limits -- set daily, weekly, monthly, or yearly limits per budget and category; automatic notifications at 80% and 100%
  • Savings goals -- create goals with target amounts and dates, allocate funds from any budget, withdraw when needed
  • Split expenses -- split transaction costs between budget members, track individual settlements
  • Bank integration -- import real bank transactions via Enable Banking (PSD2 open banking) with automatic deduplication and 6-hour background sync
  • Real-time sync -- all data changes push instantly to connected clients via SpacetimeDB WebSocket subscriptions
  • CSV import -- bulk import transactions from CSV files
  • Analytics -- 13 chart types including spending trends, category breakdowns, income breakdown, money flow (Sankey), cumulative balance, weekday patterns, recurring vs one-time analysis, budget comparison, member comparison, top expenses, spending limit progress, and savings rate
  • Calendar view -- see transactions by day and month with deep linking support
  • Universal search -- command-palette style search across pages, settings sections, analytics charts, and data (transactions, categories, budgets, tags, savings goals)
  • Notifications -- spending limit warnings, budget invitations, shared budget activity alerts, bank sync status
  • Internationalization -- German (default) and English, with bilingual search matching
  • Dark / light mode -- system preference detection with manual toggle
  • Mobile-friendly layout -- responsive design with bottom tab navigation on mobile

Tech Stack

Backend

  • SpacetimeDB 2.0 -- Rust modules compiled to WASM, running inside SpacetimeDB as both database and application server
  • argon2 0.5 -- Argon2id password hashing (pure Rust, WASM-compatible)

Frontend

  • Next.js 16 with React 19, TypeScript 5
  • Tailwind CSS 4 with shadcn/ui components
  • recharts + d3-sankey for charts and visualizations
  • i18next + react-i18next for internationalization
  • Vitest for unit testing

Infrastructure

  • Docker Compose -- 5 services behind a single nginx port
  • nginx -- reverse proxy routing all traffic through port 8080

Prerequisites

  • Docker and Docker Compose
  • git
  • Optional: Tailscale for remote access from mobile or other devices
  • Optional: Node.js 22+ (only needed for running the seed script locally)

Quick Start

  1. Clone the repository:
git clone https://github.com/Seborider/budhidocki.git
cd budhidocki
  1. Create your environment file:
cp .env.example .env

Review .env and adjust if needed. See Environment Variables for details. The defaults work for local use.

  1. Start all services:
docker compose up -d

The first launch builds the Rust module, publishes it to SpacetimeDB, generates TypeScript bindings, and builds the frontend. This takes a few minutes on the first run.

  1. Open http://localhost:8080 in your browser.

Enable Banking Setup

BudhiDocki supports importing real bank transactions via Enable Banking, a PSD2 open banking aggregator. This is optional -- the app works fully without it.

What it does

Once connected, bank transactions are automatically imported every 6 hours (the PSD2 limit is 4 background requests per day per account). Transactions are deduplicated on import, so duplicates are never created. Auto-categorization rules can classify imported transactions by matching patterns in the description.

Getting credentials

  1. Sign up at enablebanking.com and create an application
  2. Note your Application ID
  3. Generate an RS256 private key (.pem file) through their dashboard

Configuration

  1. Place your private key file at secrets/enable-banking.pem in the project root. This directory is git-ignored and mounted read-only into the frontend container.

  2. Add these variables to your .env:

ENABLE_BANKING_APP_ID=your-application-id
ENABLE_BANKING_PRIVATE_KEY_PATH=/app/secrets/enable-banking.pem
BANKING_CRON_SECRET=<generate with: openssl rand -hex 32>
SPACETIMEDB_INTERNAL_URI=ws://spacetimedb:3000
  1. Restart the services:
docker compose up -d

Connecting a bank account

  1. Go to Settings in the app
  2. Open the Banking tab
  3. Click Add Bank
  4. Select your country, bank, budget to import into, and consent duration
  5. You will be redirected to your bank's login page to approve the connection
  6. After approval, you are redirected back to BudhiDocki and the account appears in Settings

Transactions sync automatically every 6 hours. You can also trigger a manual sync from the Banking settings. Bank consent expires after 90-180 days (depending on the bank) and will need to be renewed -- the app sends notifications before expiry.

Local Development

For faster iteration, run SpacetimeDB in Docker but the frontend locally:

# 1. Start SpacetimeDB
docker compose up spacetimedb -d

# 2. Build and publish the Rust module + generate TypeScript bindings
docker compose up publish-module

# 3. Copy generated bindings to the frontend source
docker compose cp publish-module:/app/bindings/. client/src/module_bindings/

# 4. Start Next.js dev server (connects directly to SpacetimeDB, bypassing nginx)
cd client
NEXT_PUBLIC_SPACETIMEDB_URI=ws://localhost:3000 npx next dev --port 8080

Seed sample data (optional)

Creates two sample users with budgets, transactions, categories, tags, spending limits, savings goals, and a shared budget:

cd client
SEED_PASSWORD=yourpassword STDB_URI=ws://localhost:8080 npm run seed

Run tests

cd client
npx vitest

Architecture

                        +-----------------+
         Clients ------>|  nginx (:8080)  |
                        +--------+--------+
                                 |
                    +------------+------------+
                    |                         |
              /v1/* |                    /*   |
                    v                         v
          +-----------------+     +-------------------+
          |  SpacetimeDB    |     |  Next.js Frontend  |
          |  (DB + App      |     |  (standalone)      |
          |   Server, WASM) |     |                    |
          +-----------------+     +-------------------+

All traffic goes through a single nginx port (8080). This matters for mobile access over Tailscale, where exposing multiple ports can be unreliable.

SpacetimeDB handles both data storage and business logic. The Rust module defines tables and reducers (RPC endpoints), compiles to WASM, and runs inside the SpacetimeDB process. Clients connect via WebSocket, call reducers for mutations, and subscribe to tables for real-time reads. No separate database or REST API needed.

Docker Services

Service Purpose
spacetimedb Database + application server (Rust/WASM)
publish-module Builds Rust module, generates TS bindings, publishes to SpacetimeDB (one-shot)
frontend Next.js standalone server
nginx Reverse proxy, single entry point on port 8080
banking-cron Triggers bank transaction sync every 6 hours

Project Structure

budhidocki/
├── server/               # SpacetimeDB Rust module
│   └── src/              # tables.rs, helpers.rs, reducers/
├── client/               # Next.js frontend
│   └── src/
│       ├── app/          # Pages (App Router) and API routes
│       ├── components/   # UI components (shadcn/ui + feature components)
│       ├── lib/          # Providers, hooks, utilities, banking integration
│       ├── locales/      # i18n translations (de, en)
│       └── module_bindings/ # Auto-generated SpacetimeDB TypeScript SDK
├── nginx/                # Reverse proxy configuration
├── scripts/              # deploy.sh, publish-module.sh, seed.ts
├── secrets/              # Enable Banking private key (not in git)
├── docker-compose.yml
├── .env.example
└── CLAUDE.md             # Detailed technical documentation

Environment Variables

Variable Default Description
STDB_PORT 3000 SpacetimeDB server port
STDB_WS_URI ws://localhost:3000 WebSocket URI for the frontend to reach SpacetimeDB
FRONTEND_PORT 8080 External port exposed by nginx
DELETE_DATA (empty) Controls data behavior on publish (see below)

Data Management

By default, publishing the module preserves existing data. If you change the schema in a way that's incompatible with existing data (renaming a column, changing a type), the publish will fail.

DELETE_DATA value Behavior
(empty or unset) Safe mode — data always preserved, fails on incompatible schema
on-conflict Clears data only when the schema change is incompatible
force Wipes all data and republishes fresh
# Rebuild with data preserved (default)
docker compose up --build -d

# Allow data clearing on schema conflicts
DELETE_DATA=on-conflict docker compose up --build -d

# Full reset
DELETE_DATA=force docker compose up --build -d

To completely wipe the database and start over:

docker compose down
docker volume rm budhidocki_stdb_data budhidocki_stdb_config budhidocki_stdb_cli_config
docker compose up -d

Use docker compose down (without -v) to stop services while keeping your data intact.

One-Command Proxmox Install

If you're running Proxmox VE, you can create a fully configured BudhiDocki VM with a single command. Run this on your Proxmox host (not inside a VM):

bash -c "$(curl -fsSL https://raw.githubusercontent.com/Seborider/budhidocki/main/proxmox/vm/budhidocki-vm.sh)"

This opens an interactive menu to choose the OS (Debian 13/12, Ubuntu 24.04/22.04), VM resources, and network settings. The script then:

  1. Downloads a cloud image and pre-installs Docker inside it
  2. Creates a QEMU VM with your chosen settings (defaults: 2 cores, 4 GB RAM, 32 GB disk)
  3. On first boot, automatically clones the repo, generates secrets, and starts all services

BudhiDocki is accessible at http://<VM-IP>:8080 roughly 3-5 minutes after the VM boots. Check first-boot progress with cat /var/log/budhidocki-setup.log inside the VM.

Deploying on a Proxmox VM (Ubuntu 24.04)

Step-by-step guide for deploying BudhiDocki on a fresh Ubuntu 24.04 LTS VM with remote access via Tailscale.

Prerequisites

  • A Proxmox VM running Ubuntu 24.04.2 LTS (allocate at least 40GB disk)
  • SSH access with sudo privileges
  • A GitHub account (for cloning the repo)
  • A Tailscale account (for remote access)

1. Update system packages

sudo apt update && sudo apt upgrade -y

2. Install Docker Engine (official apt repository)

Do not use snap or the Ubuntu docker.io package — use the official Docker repository:

sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
  https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Add your user to the docker group so you don't need sudo:

sudo usermod -aG docker $USER
newgrp docker

Verify:

docker --version
docker compose version

3. Clone the repo

git clone https://github.com/Seborider/budhidocki.git
cd budhidocki

Git will prompt for your GitHub username and a personal access token (classic, with repo scope) as the password.

4. Configure environment variables

cp .env.example .env

Edit .env and make these changes:

  • Clear STDB_WS_URI — this is critical. If left as ws://localhost:3000, the frontend will try to connect directly to SpacetimeDB instead of going through nginx, which breaks remote access. Leave it empty so the frontend auto-detects from window.location:
    STDB_WS_URI=
    
  • Set DELETE_DATA=force for the first deploy (wipes any stale data):
    DELETE_DATA=force
    

Your .env should look like:

STDB_PORT=3000
STDB_WS_URI=
FRONTEND_PORT=8080
DELETE_DATA=force

5. Start all services

docker compose up -d

First run pulls images, compiles the Rust module to WASM, generates TypeScript bindings, and builds the Next.js frontend. This takes several minutes.

Verify all services are running:

docker compose ps

You should see:

  • spacetimedb — healthy
  • publish-module — exited (one-shot task, this is expected)
  • frontend — running
  • nginx — running, port 8080 exposed

6. Seed sample data (optional)

The seed script requires Node.js 22+ on the VM:

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

Install dependencies, copy bindings, and run the seed:

cd client
npm install
docker compose -f ~/budhidocki/docker-compose.yml cp publish-module:/app/bindings/. src/module_bindings/
SEED_PASSWORD=yourpassword STDB_URI=ws://localhost:8080 npm run seed
cd ..

This creates two sample users with budgets, transactions, categories, and a shared budget.

7. Install and connect Tailscale

curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up

Open the printed URL in your browser to authenticate. Once connected, get your Tailscale IP:

tailscale ip -4

The app is now reachable at http://<tailscale-ip>:8080 from any device on your Tailnet.

8. Set DELETE_DATA back to safe mode

After the first successful deploy, update .env to prevent accidental data loss:

sed -i 's/^DELETE_DATA=force/DELETE_DATA=/' ~/budhidocki/.env

Gotchas

Issue Cause Fix
WebSocket connects to localhost:3000 STDB_WS_URI is set in .env. The frontend bakes NEXT_PUBLIC_SPACETIMEDB_URI at build time. Clear STDB_WS_URI= in .env and recreate the frontend: docker compose up -d frontend
Changing .env has no effect docker compose restart doesn't re-read .env. Use docker compose up -d instead of restart to pick up env changes
npm ci fails in Docker build package-lock.json is out of sync (e.g. after installing packages locally). Run npm install in client/ to update the lock file, then rebuild
Build fails with "no space left on device" Ubuntu 24.04 default LVM only uses ~50% of the allocated disk. Expand: sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv && sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Seed script: Promise.withResolvers is not a function Node.js < 22. The SpacetimeDB SDK requires Promise.withResolvers. Install Node 22+: curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs
Seed script: "Cannot find module spacetimedb" Running from wrong directory or missing node_modules. Run from client/: cd client && npm install
Seed script: "No global WebSocket found" Node needs the undici polyfill for WebSocket. npm install undici@6 --legacy-peer-deps (v6 required for spacetimedb SDK peer dep)

Common Operations

Starting and stopping

# Start all services (first run or after env changes)
docker compose up -d

# Stop all services (data preserved in volumes)
docker compose down

# View logs (all services)
docker compose logs -f

# View logs for a specific service
docker compose logs -f frontend
docker compose logs -f spacetimedb

# Check service status
docker compose ps

Rebuilding after code changes

# Rebuild frontend only (e.g. after changing client code)
docker compose up --build frontend -d

# Rebuild everything
docker compose up --build -d

# Force rebuild without cache (e.g. after dependency changes)
docker compose build --no-cache frontend && docker compose up -d frontend

Schema changes and data management

# Safe publish — data preserved, fails on incompatible schema (default)
docker compose up --build -d

# Clear data only if schema is incompatible
DELETE_DATA=on-conflict docker compose up --build -d

# Wipe all data and republish fresh
DELETE_DATA=force docker compose up --build -d

Full database reset

Remove all volumes to start completely fresh:

docker compose down
docker volume rm budhidocki_stdb_data budhidocki_stdb_config budhidocki_stdb_cli_config
docker compose up -d

After a reset, copy fresh bindings to your local source if you're developing locally:

docker compose cp publish-module:/app/bindings/. client/src/module_bindings/

Seeding data

cd client
SEED_PASSWORD=yourpassword STDB_URI=ws://localhost:8080 npm run seed

The seed script creates two users (sebo, anna) with budgets, transactions, categories, tags, spending limits, savings goals, and a shared budget. Set SEED_PASSWORD to the password you want for both users.

Docker cleanup

# Remove unused images and build cache (keeps volumes/data)
docker system prune -a --volumes=false -f

# Check disk usage by Docker
docker system df

# Remove ALL volumes (destroys all data — use with caution)
docker compose down -v

Tailscale

# Check Tailscale status and connected devices
tailscale status

# Get your Tailscale IP
tailscale ip -4

# Disconnect Tailscale
sudo tailscale down

# Reconnect Tailscale
sudo tailscale up

Troubleshooting

Port already in use — A leftover container is holding the port:

docker rm -f $(docker ps -aq) && docker compose up -d

Mobile can't connect / login hangs — Make sure all traffic goes through the single nginx port (8080). If the frontend tries to reach SpacetimeDB on a separate port, it won't work over Tailscale. Check that the WebSocket URI resolves to the same origin.

Data lost after rebuild — The default publish mode preserves data. If you made an incompatible schema change, publish fails rather than deleting data. Use DELETE_DATA=on-conflict to allow clearing when needed. Also make sure you're using docker compose down (not down -v), since -v removes volumes.

License

TBD

About

Self-hosted budget tracker — SpacetimeDB + Next.js

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages