# Database Conventions ## Room - DAO interfaces go in `database/daos/` package - New DAOs must be registered as abstract functions in `AppDatabase` - All DAO query functions must be `suspend` or return `Flow` - Entity classes go in `database/` with `@Entity` annotation ## Repository Layer - Every DAO is wrapped by a Repository in `source/` package - Repositories are the only way screens/controllers access the database - New repositories must be registered in `AppContainer` interface and `DefaultAppContainer` ## DataStore (Secrets) - Cryptographic secrets (AES keys, HMAC keys, device ciphers) use **DataStore + Protobuf**, not Room - Proto definitions are in `app/src/main/proto/` — do not modify without understanding migration implications - User preferences (currency, settings) use DataStore Preferences ## Migrations - Room version bumps require a `Migration` object registered in the database builder - The `items.db` asset database must stay in sync with the Room schema