Planned Wallet Architecture: Startup Mode, Cost Minimization, and Database Scale Tradeoffs
Tradeoffs
Planned Wallet was engineered to be simple to operate, inexpensive to host, and fast to iterate on without sacrificing strict API contracts or security boundaries. However, this simple architecture, while fast to deliver and execute, will suffer at scale. There is no eventing ecosystem in the current form, so the database becomes the focal point for all persisted data, both read and writes.
I believe in current form I could handle somewhere in the neighborhood of 500 users, with maybe 30 concurrent active users at one time.
It will scale based on Postgres read replicas, as most demand will be read operations of existing account data, but that scale will require additional deployments in the cloud.
Given the total cost of ownership is right now around $200 and 1 month of time, I think my choice is correct. I can evaluate demand once I find a Merchant of Record and determine if the scale is needed and worth pursuing.
High-Level System Architecture
The production and local stacks are intentionally minimal:
The user interface is a static-exported Next.js / React SPA. All routing happens in-memory in React state so the browser URL stays at / and page reloads never 403/404 on static object storage. The static content is hosted in Amazon S3 behind CloudFront. Zero Node.js SSR servers to patch, scale, or pay for.
The backend API is a 12-factor application, a stateless Golang 1.27 + Gin microservice compiled into a static binary inside a scratch Docker container. The API is hosted on AWS ECS Fargate behind an ALB + CloudFront, with strict origin verification. I directed Gemini to follow old-school MVC, with a repository interface supporting an in-memory parity API so you can run the container locally without Postgres.
The database is a PostgreSQL 16 dockerized locally, using a managed Amazon RDS in stage and prod.
Ease of Development
The entire stack will run from a single docker compose file. I use an nginx instance to route / to the NextJS content, and /api to the Golang back-end, mirroring the configuration with the AWS ALB. The entire compose definition can be stood up and integration tested locally, with a 20 second restart cycle time.
Account creation requires CAPTCHA when in production mode, but for local development (and integration tests) the CAPTCHA is presented, but not required in the API for account creation. Meaning you can create an account locally bypassing the CAPTCHA, intentionally.
Ease of Deployment & Cost Minimization
Minimalist Deployment Pipeline
There is a single Idempotent Schema (init.sql) bringing the database up to speed. Rather than managing dozens of sequential migration files, init.sql uses idempotent CREATE TABLE IF NOT EXISTS, CREATE INDEX IF NOT EXISTS, and guarded ALTER TABLE blocks. In CI/CD, an ephemeral ECS Fargate RunTask executes init.sql against RDS before deploying the new backend task revision.
I used GitHub Actions + federated identity with AWS using GitHub OIDC for deployment authentication. There are no IAM keys stored in GitHub Secrets. Deployment of the built container is verified using /api/v1/version with the golang application carrying a Git SHA sum and/or release tag to validate the appropriate build was activated.
Cost Controls
- Serving prebuilt HTML/JS/CSS/PDF assets from S3 eliminates frontend compute costs entirely.
- The only compute is a tiny
scratchGo Container. The compiled Go binary uses a fraction of the RAM and CPU of JVM or Node.js API servers, allowing small ECS Fargate task sizes with fast cold starts.
Current Scale Limitations with a Single Database
While the stateless Go API can scale horizontally behind an ALB by adding ECS Fargate tasks, a single primary PostgreSQL instance introduces concrete bottlenecks as usage grows:
- Write Contention & Connection Limits: Every checking record, bulk CSV import (up to 1,000 records per API batch), asset valuation, snapshot, and
user_settingsJSONBupdate hits the single primary RDS instance. - Read-Heavy Analytics Queries: Perspective views and multi-year balance trends currently fetch and aggregate records on demand. At high concurrency, read queries compete with writes on the same primary instance unless offloaded to read replicas or cached/pre-aggregated.
- Startup / Migration Locking: Running
init.sqlagainst large live tables (ALTER TABLE,CREATE INDEXwithoutCONCURRENTLY) can briefly acquire metadata/table locks during deployments if tables grow to millions of rows.
The Path Forward When Scale Demands It
Because all data access is isolated behind the Repository interface, the transition path is straightforward without rewriting business logic:
- Introduce RDS Proxy between ECS Fargate tasks and PostgreSQL.
- Route read-heavy trend/perspective queries to a PostgreSQL Read Replica.
- Move high-churn tables or
init.sqlindex creations toCONCURRENTLY/ versioned migrations once tables reach high row counts.
Until then, keeping the stack lean—static S3/CloudFront + scratch Go on Fargate + a single PostgreSQL 16 database—gives Planned Wallet predictable, minimal infrastructure overhead and rapid deployment velocity.