You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create missing repository layer for loans, transactions, notifications, and liquidity
📄 Description
The architecture defines `src/database/repositories/` as the data access abstraction layer. Only 3 repositories exist (`users`, `sessions`, `merchants`). The four remaining domain services call `supabaseService.getClient()` and inline raw Supabase queries directly inside business logic:
`src/modules/loans/loans.service.ts` — raw queries against `loans`, `loan_payments`, `loan_installments` tables
`src/modules/transactions/transactions.service.ts` — raw queries against `transactions` table
`src/modules/notifications/notifications.service.ts` — raw queries against `notifications` table
`src/jobs/transaction-status-checker/transaction-status-checker.processor.ts` — raw queries against `transactions` and `loans` tables (duplicated from the service)
This means:
Supabase table names are magic strings scattered across business logic
Services cannot be unit-tested without mocking the entire Supabase client
Query optimizations (field selection, indexes, caching hints) have no single place to live
✅ Tasks to complete
Create `src/database/repositories/loans.repository.ts` — encapsulate all `loans`, `loan_payments`, and `loan_installments` queries; expose typed methods (`findById`, `findByUser`, `createLoan`, `updateStatus`, `recordPayment`)
Create `src/database/repositories/transactions.repository.ts` — encapsulate `transactions` queries from both `transactions.service.ts` and `transaction-status-checker.processor.ts`; expose `findPending`, `findByHash`, `updateStatus`, `deleteOlderThan`
🔖 Title
Create missing repository layer for loans, transactions, notifications, and liquidity
📄 Description
The architecture defines `src/database/repositories/` as the data access abstraction layer. Only 3 repositories exist (`users`, `sessions`, `merchants`). The four remaining domain services call `supabaseService.getClient()` and inline raw Supabase queries directly inside business logic:
This means:
✅ Tasks to complete
📚 Documentation/context for AI
(This link never should removed)
https://github.com/TrustUp-app/TrustUp-API/tree/main/docs
Reference implementation:
🗒️ Additional notes