Run artifact

workspace/targets/LayersTesting/blueprint/DATABASE.md

DATABASE: Ledger Persistence

FieldValue
Version20261020 V1
DescriptionDefine the relational ledger schema and typed persistence operations.
Depends OnARCHITECTURE.md
Providesaccounts table, categories table, transactions table, schema initialization
Consumes—

Stores

The application uses the relational database selected by DATABASE_URL, then DATABASE_PATH, then data/app.db. SQLite paths may be prefixed with sqlite://; PostgreSQL DSNs begin with postgres:// or postgresql://. Application callers use only persistence.open_database.

Access Patterns

FEATURE-DB-001 — Initialize schema

FieldValue
OwnerDATABASE.md
Accesswrite
Repository operationaccounts.create
Compatibilityrebuild

Input: InitializeSchema

FieldType
drop_existingINTEGER

Output: SchemaStatus

FieldType
tablesTEXT

FEATURE-DB-002 — Account operations

FieldValue
OwnerFEATURE-Account-Category-Loading.md
Accessread-write
Repository operationaccounts.create
Compatibilityunchanged

Input: AccountInput

FieldType
accountVARCHAR(12)
nameVARCHAR(40)

Output: AccountRow

FieldType
accountVARCHAR(12)
nameVARCHAR(40)

FEATURE-DB-003 — Category operations

FieldValue
OwnerFEATURE-Account-Category-Loading.md
Accessread-write
Repository operationcategories.create
Compatibilityunchanged

Input: CategoryInput

FieldType
categoryVARCHAR(12)
descriptionVARCHAR(40)

Output: CategoryRow

FieldType
categoryVARCHAR(12)
descriptionVARCHAR(40)

FEATURE-DB-004 — Transaction operations

FieldValue
OwnerFEATURE-Transaction-Loading.md
Accessread-write
Repository operationtransactions.create
Compatibilityunchanged

Input: TransactionInput

FieldType
txn_idINTEGER
dateVARCHAR(10)
accountVARCHAR(12)
categoryVARCHAR(12)
amountINTEGER
memoVARCHAR(60)

Output: TransactionRow

FieldType
txn_idINTEGER
dateVARCHAR(10)
accountVARCHAR(12)
categoryVARCHAR(12)
amountINTEGER
memoVARCHAR(60)

FEATURE-DB-005 — Account reads and mutations

FieldValue
OwnerFEATURE-Account-Management.md
Accessread-write
Repository operationaccounts.get
Compatibilityunchanged

Input: AccountLookup

FieldType
accountVARCHAR(12)

Output: AccountBalanceRow

FieldType
accountVARCHAR(12)
nameVARCHAR(40)
transactionsINTEGER
balanceINTEGER

FEATURE-DB-006 — Transaction reads and mutations

FieldValue
OwnerFEATURE-Transaction-Management.md
Accessread-write
Repository operationtransactions.get
Compatibilityunchanged

Input: TransactionLookup

FieldType
txn_idINTEGER

Output: TransactionRow

FieldType
txn_idINTEGER
dateVARCHAR(10)
accountVARCHAR(12)
categoryVARCHAR(12)
amountINTEGER
memoVARCHAR(60)

FEATURE-DB-007 — Report reads

FieldValue
OwnerDATABASE.md
Accessread
Repository operationaccounts.list
Compatibilityunchanged

Input: ReportQuery

FieldType
reportTEXT

Output: ReportRow

FieldType
valuesTEXT

Schema

accounts

FieldTypeNotes
accountVARCHAR(12) PK NOT NULLAccount code
nameVARCHAR(40) NOT NULLAccount name

categories

FieldTypeNotes
categoryVARCHAR(12) PK NOT NULLCategory code
descriptionVARCHAR(40) NOT NULLCategory description

transactions

FieldTypeNotes
txn_idINTEGER PK NOT NULLTransaction identifier
dateVARCHAR(10) NOT NULLCalendar date in YYYY-MM-DD form
accountVARCHAR(12) NOT NULL REFERENCES accounts(account)Account code
categoryVARCHAR(12) NOT NULL REFERENCES categories(category)Category code
amountINTEGER NOT NULLInteger cents
memoVARCHAR(60) NOT NULLTransaction memo

Atomicity and Invariants

Schema initialization drops and recreates all three tables. Foreign keys are enforced. Every command validates all inputs and prospective balance effects before its first write. Transactions are committed atomically.

Programmatic Acceptance

User Acceptance

Guardrails