# Cost Model ## Architecture Compute and storage are separate. One palacering app server handles all masters — stateless, just routing requests to the right palace's files. Palace data lives on cheap storage, mounted at `PALACE_DATA_ROOT`. The app doesn't care where storage physically lives. This means infrastructure cost stays nearly flat as masters grow. The variable cost is Claude API usage — one conversation = one Claude call. That is where the money goes. ## Assumptions - 1 GB storage per palace - Claude API cost: ~$5–20/master/month depending on activity (butler conversations, heartbeats, research tasks) - Cloudflare R2 storage: $0.015/GB/month after free tier (first 10GB free) - Compute: shared app server across all masters ## Cost by Scale | Masters | Compute | Storage | Claude (avg $10/master) | Total/mo | |---------|---------|---------|-------------------------|----------| | 2 | $14 (palacestableserver VM) | free (under 10GB) | $20 | ~$34 | | 10 | $14 | free (under 10GB) | $100 | ~$114 | | 100 | $14 | $1.35 (90GB × $0.015) | $1,000 | ~$1,015 | | 1,000 | $40 (larger VM) | $14.85 (990GB × $0.015) | $10,000 | ~$10,055 | | 10,000 | $200 (multiple servers) | $149 (9,990GB × $0.015) | $100,000 | ~$100,349 | Infrastructure (compute + storage) is noise at every scale. Claude is the cost. ## Implications for Pricing To be profitable, Palace Ring must charge more per master per month than Claude costs per active master. If average Claude cost is $10/master/month, pricing at $20–30/master/month covers Claude, infrastructure, and margin. Heavy masters (frequent butler conversations, lots of research tasks) cost more in Claude. Light masters (check diary once a day, occasional questions) cost much less. Pricing should account for this — either a usage cap per tier or metered billing above a baseline. ## Infrastructure Split **Compute (app server):** Shared. One or a few VMs running the palacering Docker container. Scales up only when concurrent request volume demands it — not when master count grows. **Storage (palace data):** Per-master, isolated. 1GB per palace. Options: - Same VM (simple, fine up to ~500 masters on an 80GB disk) - Dedicated storage volume (attach to VM, expand as needed) - Object storage at scale (Cloudflare R2, Backblaze B2 — fractions of a cent per GB, no egress fees on R2) **Database:** Postgres on same VM. Only stores masters and palaces (auth/identity). Tiny — thousands of rows even at 10,000 masters. ## Beta: Claude Code OAuth (not API) For Junwon and Elizabeth, the butler runs via `claude -p` on the palacestableserver VM using Junwon's Claude Code OAuth. Same bridge pattern as Manglasabang — spawn `claude -p` as a subprocess, persist session ID for `--resume`. This means zero Claude API cost for the beta. The subscription covers it. **What's needed on the VM:** - Claude Code installed - Junwon's OAuth credentials placed on the VM - ClaudeBridge spawns `claude -p` per butler session, same as on the Mac **At scale:** One person's OAuth can't serve thousands of masters. When Palace Ring grows beyond trusted beta masters, butler calls must move to the Anthropic API with a paid key — and that's when the per-master Claude cost in the table above applies. The bridge code stays the same; only the auth method changes. ## Current Setup palacestableserver VM ($14/mo, 2 vCPU / 8GB / 80GB) handles everything for the beta. Sufficient for first 50–100 palaces before needing to think about scaling.