feat(ledger): add append-only double-entry engine

The Lightning bridge is modelled as the boundary with the outside
world and is the one account permitted to go negative; its negative
balance is exactly what is owed to players inside the system. All
other accounts are floored at zero by both the application and a
database trigger.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
drjones
2026-08-05 03:23:49 +00:00
parent 8fccbb2a9a
commit 8045e37c16
7 changed files with 756 additions and 0 deletions

31
docker-compose.yml Normal file
View File

@@ -0,0 +1,31 @@
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: arcade
POSTGRES_PASSWORD: arcade_dev
POSTGRES_DB: arcade
ports: ["5432:5432"]
volumes:
- pgdata:/var/lib/postgresql/data
- ./migrations:/docker-entrypoint-initdb.d:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U arcade"]
interval: 2s
timeout: 3s
retries: 20
redis:
image: redis:7-alpine
ports: ["6379:6379"]
volumes:
- redisdata:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s
timeout: 3s
retries: 20
volumes:
pgdata:
redisdata: