Session: scaffold-invoice-service — 2026-08-18

ledger-api · Claude · branch main · claude-sonnet-4-6 · 2026-08-18 09:10 · 2 msgs · 5 tools · 1 min read · updated 2 months ago

tools: Bash, Edit, Write
← ledger-api Download .md .txt .json
Tool calls
Bash Bash: 2 calls (40.0%) 2 Write Write: 2 calls (40.0%) 2 Edit Edit: 1 call (20.0%) 1
Token usage140.0K total
Input15.0K
Cache creation30.0K
Cache read90.0K
Output5.0K
Cache hit ratio67%· warming up

Project: ledger-api · Branch: main · Mode: default · Model: claude-sonnet-4-6

Summary

Bootstrapped the invoicing service: FastAPI app factory, SQLAlchemy 2.0 models for customers, invoices and line items, Alembic baseline migration, and a pytest fixture that spins up Postgres in Docker. Money is stored as integer minor units from day one.

Conversation

Turn 1 — User

Scaffold a FastAPI service for invoices. Postgres, SQLAlchemy 2.0, Alembic. Money must never be a float.

Turn 1 — Assistant

Plan: app factory in ledger/app.py, typed models in ledger/models.py, amounts as BIGINT minor units plus an ISO-4217 currency column, Alembic baseline, Docker-based Postgres fixture for tests.

class LineItem(Base):
    __tablename__ = "line_items"

    id: Mapped[int] = mapped_column(primary_key=True)
    invoice_id: Mapped[int] = mapped_column(ForeignKey("invoices.id"))
    description: Mapped[str] = mapped_column(String(200))
    quantity: Mapped[int] = mapped_column(default=1)
    unit_amount: Mapped[int]  # minor units (cents)
    currency: Mapped[str] = mapped_column(String(3))

Tools used in this turn:

  • Write: ledger/app.py
  • Write: ledger/models.py
  • Bash: alembic init migrations — exit 0

Turn 2 — User

Add the line-item total as a computed column.

Turn 2 — Assistant

Done as a SQLAlchemy column_property summing quantity * unit_amount; invoice totals are derived, never stored, so they cannot drift. 9 tests pass.

Tools used in this turn:

  • Edit: ledger/models.py — column_property for totals
  • Bash: pytest -q — 9 passed

Connections

  • [[ledger-api]]
  • [[FastAPI]]
  • [[SQLAlchemy]]
  • [[Alembic]]
  • [[MoneyAsMinorUnits]]

Keyboard shortcuts

⌘K / Ctrl+KOpen command palette
/Focus search
g hGo to home
g pGo to projects
g sGo to sessions
j / kNext / prev row (tables)
?Show this help
EscClose dialogs

Structured queries

Mix key:value filters with free text in the palette:

type:sessionOnly session pages
project:llm-wikiFilter by project name (substring)
model:claudeFilter by model name (substring)
date:>2026-03-01Sessions after a date
date:<2026-04-01Sessions before a date
tags:rustPages mentioning a tag/topic
sort:dateSort results by date (newest first)

Example: type:session project:llm-wiki date:>2026-04 sort:date