ADR template
One decision that is hard to undo, why you made it, and what it costs, so people and agents stop reopening it.
docs/adr/, one numbered file per decision. Agents read the matching one before changing the code it covers.
# ADR 0012: Use Postgres for billing data- Status: Accepted- Date: 2026-11-28- Decided by: Priya Shah, Sam Ortiz- Replaces: none## ContextWhat is happening that makes us decide now? State the facts and the pressures, not the answer.Billing runs on a key-value store we picked in 2024 for speed. Finance now needs monthly reports that join invoices, credits, and refunds, and we write those joins by hand in code. Last month two reports disagreed because they joined the data differently.## DecisionWhat we will do, in one or two sentences that start with "We will".We will move billing data to Postgres and write every report as a SQL view that all reports read from.## Options we considered1. **Postgres (chosen).** Joins and transactions are built in, and we already run it for accounts.2. **Keep the key-value store and add a reporting copy.** Quick to start, but two copies that can disagree.3. **A data warehouse.** Good for reports, but too slow and too costly for the live app.## Consequences- Better: one source of truth for invoices, and reports that agree.- Worse: a two-week move, and writes about 20 ms slower at peak (measured on a copy of production).- New work: a script to copy old data, and one week of reading from both stores to compare.## How we'll know it workedEvery finance report matches the invoice totals for a full month after the switch.## For agentsRead this before you change anything under `api/billing/`.If a change goes against this decision, don't edit this file. Write a new ADR that replaces it, and set this one's status to "Replaced by ADR 00NN".
ADR 0012: Use Postgres for billing data
- Status: Accepted
- Date: 2026-11-28
- Decided by: Priya Shah, Sam Ortiz
- Replaces: none
Context
What is happening that makes us decide now? State the facts and the pressures, not the answer.
Billing runs on a key-value store we picked in 2024 for speed. Finance now needs monthly reports that join invoices, credits, and refunds, and we write those joins by hand in code. Last month two reports disagreed because they joined the data differently.
Decision
What we will do, in one or two sentences that start with "We will".
We will move billing data to Postgres and write every report as a SQL view that all reports read from.
Options we considered
- Postgres (chosen). Joins and transactions are built in, and we already run it for accounts.
- Keep the key-value store and add a reporting copy. Quick to start, but two copies that can disagree.
- A data warehouse. Good for reports, but too slow and too costly for the live app.
Consequences
- Better: one source of truth for invoices, and reports that agree.
- Worse: a two-week move, and writes about 20 ms slower at peak (measured on a copy of production).
- New work: a script to copy old data, and one week of reading from both stores to compare.
How we'll know it worked
Every finance report matches the invoice totals for a full month after the switch.
For agents
Read this before you change anything under api/billing/.
If a change goes against this decision, don't edit this file. Write a new ADR that replaces it, and set this one's status to "Replaced by ADR 00NN".