The Backend of Tansy was chosen to prioritize flexibility, speed, and self-containment at the cost of future scalability.

Pocketbase

Pocketbase is an open-source “firebase alternative”, meaning it provides most crucial web app functionality out of the box. It is packaged as a single lightweight executable.

We use it for:

  • Database (SQLite)
  • Admin UI
  • User Permissions
  • User Authentication
  • OAuth
  • File Storage
  • API framework
  • Realtime websockets
  • Database Backups
  • Transaction Emails

The PocketBase Directory

pocketbase/
pb_data/ (Database data)
pb_hooks/ (API framework functions)
pb_seed/ (Seed data)
pb_migrations/ (Database migrations)
pocketbase (30MB executable)
CHANGELOG.md
LICENSE.md
schema.dbml (ERD diagram)
README.md
installpb.sh (Install script)

pb_data

This is the location where pocketbase stores all data. You can backup and restore this folder.

pb_hooks

Where API endpoints and data hooks can be added using the pocketbase extend with js framework.
This is a lightweight and limited js environment, not a full node instance, so node sdk packages are not usable here.

pb_seed

simply a pb_data folder copied with developer seed data.
Copy as pb_data to restore the seeded state.

pb_migrations

Generated by pocketbase admin UI when changes are made to the database Schema. Syncing this via git updates the production instance.

pocketbase

The pocketbase executable.
By running this inside this folder, you will have a pocketbase instance.
See Deployment for details how how it is setup in production.

Various .md markdown files

These come from pocketbase when the archive is unzipped.

schema.dbml

A seperate file maintained with the current schema for visualizing in a ERD diagram.
This can be viewed within cursor or vscode with the DBML Entity-Relationship Diagrams visualizer extension

More details on this here: Schema

installpb.sh

Install script used for updating the pocketbase executable.

It has been setup to use a couple variables kept in your .env file.
- PB_VERSION - The version of pocketbase. Example: 0.26.3
- PB_SYSTEM - System you are installing on. Example: linux, darwin (macOS)
- PB_ARCH - CPU Architecture you are installing to. Example: arm64, amd64

It works by fetching the pocketbase archive directly from github releases.
For more details visit the github releases page or the pocketbase docs