This document outlines the development roadmap for the TrustUp API backend, organized into 10 sequential phases. Each phase builds upon the previous one to create a complete BNPL (Buy Now, Pay Later) system integrated with Stellar blockchain.
The TrustUp API provides the backend infrastructure for a decentralized BNPL platform. It handles user authentication, reputation management, loan processing, liquidity pool operations, and blockchain integration.
Total Issues: 26 Completed: 0/26 In Progress: 0/26 Pending: 26/26
Goal: Implement secure authentication using Stellar wallet signatures Dependencies: None (Foundation) Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: High
- Description: Create endpoint to generate unique nonces for wallet authentication
- Tasks:
- Generate cryptographically secure random nonce
- Associate nonce with wallet address
- Store nonce temporarily (5-10 minutes TTL)
- Return nonce to client
- Endpoint:
POST /auth/nonce - Response:
{ nonce: string, expiresAt: timestamp }
- Status: 🔴 Pending
- Priority: High
- Description: Verify Stellar wallet signature and issue JWT tokens
- Tasks:
- Verify Stellar signature against nonce
- Validate signature timestamp
- Generate JWT access token (15min expiry)
- Generate JWT refresh token (7 days expiry)
- Store refresh token in Supabase
- Clear used nonce
- Endpoint:
POST /auth/verify - Request:
{ wallet: string, signature: string, nonce: string } - Response:
{ accessToken: string, refreshToken: string }
- Status: 🔴 Pending
- Priority: High
- Description: Protect authenticated endpoints with JWT validation
- Tasks:
- Create NestJS auth guard
- Validate JWT access token
- Extract wallet address from token
- Inject wallet into request context
- Handle token expiration errors
- Usage:
@UseGuards(JwtAuthGuard)
Goal: Enable users to view and update their profile information Dependencies: Phase 1 (Authentication required) Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: Medium
- Description: Retrieve authenticated user's profile from database
- Tasks:
- Query Supabase
userstable by wallet - Return profile data (name, avatar, preferences)
- Handle non-existent users (create default profile)
- Query Supabase
- Endpoint:
GET /users/me - Response:
{ wallet: string, name: string, avatar: string, preferences: object }
- Status: 🔴 Pending
- Priority: Medium
- Description: Allow users to update their profile information
- Tasks:
- Validate input data (DTO validation)
- Update Supabase
userstable - Sanitize user inputs
- Return updated profile
- Endpoint:
PATCH /users/me - Request:
{ name?: string, avatar?: string, preferences?: object } - Response: Updated user profile
Goal: Provide merchant discovery and details Dependencies: Phase 1 (Authentication required) Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: Medium
- Description: List all active merchants available for BNPL purchases
- Tasks:
- Query Supabase
merchantstable - Filter by
is_active = true - Support pagination (limit, offset)
- Return merchant summaries
- Query Supabase
- Endpoint:
GET /merchants - Query Params:
?limit=20&offset=0 - Response:
{ merchants: Array<MerchantSummary>, total: number }
- Status: 🔴 Pending
- Priority: Medium
- Description: Get detailed information about a specific merchant
- Tasks:
- Query merchant by ID or wallet address
- Validate merchant exists
- Return complete merchant metadata
- Endpoint:
GET /merchants/:id - Response:
MerchantDetailobject
Goal: Integrate with on-chain reputation contract Dependencies: Phase 1, Reputation smart contract deployed Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: High
- Description: Query user reputation score from Soroban contract
- Tasks:
- Initialize Stellar SDK Soroban client
- Call
get_score()on Reputation contract - Parse contract response (u32 score)
- Normalize to 0-100 range
- Handle contract errors gracefully
- Endpoint:
GET /reputation/:wallet - Response:
{ wallet: string, score: number, tier: string }
- Status: 🔴 Pending
- Priority: Medium
- Description: Cache reputation scores for fast UX
- Tasks:
- Implement Redis caching layer
- Cache score with 5-minute TTL
- Invalidate cache on reputation changes
- Fallback to blockchain on cache miss
- Cache Key:
reputation:{wallet}
Goal: Core loan functionality - quote, create, repay, list Dependencies: Phase 1, 3, 4 (Auth, Merchants, Reputation) Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: High
- Description: Calculate loan terms based on reputation score
- Tasks:
- Fetch user reputation score
- Calculate interest rate from tier
- Determine max credit limit
- Generate repayment schedule
- Return quote (no blockchain interaction)
- Endpoint:
POST /loans/quote - Request:
{ amount: number, merchant: string, term: number } - Response:
{ interestRate: number, totalRepayment: number, schedule: Array }
- Status: 🔴 Pending
- Priority: High
- Description: Construct unsigned transaction for loan creation
- Tasks:
- Validate merchant exists and is active
- Verify user reputation meets minimum
- Build
create_loan()Soroban transaction - Set guarantee amount (20% of purchase)
- Return unsigned XDR for user to sign
- Endpoint:
POST /loans/create - Request:
{ amount: number, merchant: string, guarantee: number } - Response:
{ xdr: string, loanId: string }
- Status: 🔴 Pending
- Priority: High
- Description: Construct unsigned transaction for loan repayment
- Tasks:
- Validate loan exists and is active
- Verify user owns the loan
- Build
repay_loan()Soroban transaction - Calculate remaining balance
- Return unsigned XDR
- Endpoint:
POST /loans/:loanId/repay - Request:
{ amount: number } - Response:
{ xdr: string, remainingBalance: number }
- Status: 🔴 Pending
- Priority: Medium
- Description: List all loans for authenticated user
- Tasks:
- Query indexed loans from Supabase
- Optionally fetch latest state from blockchain
- Filter by status (active, completed, defaulted)
- Support pagination
- Endpoint:
GET /loans/me - Query Params:
?status=active&limit=20&offset=0 - Response:
{ loans: Array<Loan>, total: number }
Goal: Handle transaction submission and status tracking Dependencies: Phase 5 (Requires loan transactions) Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: High
- Description: Submit signed XDR to Stellar network
- Tasks:
- Receive signed XDR from client
- Validate XDR format
- Submit to Stellar via Horizon
- Store transaction hash in Supabase
- Return transaction hash and initial status
- Endpoint:
POST /transactions/submit - Request:
{ xdr: string } - Response:
{ hash: string, status: 'pending' }
- Status: 🔴 Pending
- Priority: High
- Description: Query transaction status from Stellar
- Tasks:
- Query Horizon API by transaction hash
- Parse transaction result
- Normalize status (pending, success, failed)
- Return detailed error on failure
- Endpoint:
GET /transactions/:hash - Response:
{ hash: string, status: string, result?: object, error?: string }
Goal: Enable liquidity provider operations Dependencies: Phase 1, Liquidity Pool contract deployed Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: Medium
- Description: Show liquidity pool metrics
- Tasks:
- Query pool contract for total liquidity
- Calculate current APY from recent interest
- Get utilization rate (loaned / total)
- Cache metrics with 1-minute TTL
- Endpoint:
GET /liquidity/overview - Response:
{ totalLiquidity: number, apy: number, utilization: number }
- Status: 🔴 Pending
- Priority: Medium
- Description: Show LP's shares and returns
- Tasks:
- Query LP shares from pool contract
- Calculate current share value
- Show deposited amount vs current value
- Calculate unrealized gains
- Endpoint:
GET /liquidity/position - Response:
{ shares: number, value: number, deposited: number, gains: number }
- Status: 🔴 Pending
- Priority: High
- Description: Construct deposit transaction
- Tasks:
- Validate deposit amount
- Build
deposit()pool contract transaction - Calculate expected shares to receive
- Return unsigned XDR
- Endpoint:
POST /liquidity/deposit - Request:
{ amount: number } - Response:
{ xdr: string, expectedShares: number }
- Status: 🔴 Pending
- Priority: High
- Description: Construct withdrawal transaction
- Tasks:
- Validate user has shares
- Check pool has available liquidity
- Build
withdraw()pool contract transaction - Calculate expected withdrawal amount
- Return unsigned XDR
- Endpoint:
POST /liquidity/withdraw - Request:
{ shares: number } - Response:
{ xdr: string, expectedAmount: number }
Goal: Sync blockchain state with API database Dependencies: Phases 5, 6 (Loans and Transactions) Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: High
- Description: Background job to index blockchain events
- Tasks:
- Poll Stellar for new contract events
- Index loan creation events
- Index repayment events
- Index reputation changes
- Update Supabase tables
- Run every 30 seconds
- Events Indexed:
LOAN_CREATED,LOAN_REPAID,SCORE_CHANGED
- Status: 🔴 Pending
- Priority: High
- Description: Update pending transaction statuses
- Tasks:
- Query Supabase for pending transactions
- Check Stellar status for each
- Update to success/failed
- Trigger follow-up actions (update loan status)
- Run every 15 seconds
- Cron:
*/15 * * * * *
- Status: 🔴 Pending
- Priority: Medium
- Description: Detect loans approaching due date
- Tasks:
- Query active loans from Supabase
- Check next payment due date
- Create notification if due in 3 days
- Create notification if due in 1 day
- Create notification if overdue
- Run daily at 9 AM UTC
- Cron:
0 9 * * *
Goal: User notification system Dependencies: Phase 8 (Notifications created by jobs) Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: Medium
- Description: Retrieve user notifications
- Tasks:
- Query Supabase
notificationstable - Filter by user wallet
- Support read/unread filter
- Order by created date (newest first)
- Support pagination
- Query Supabase
- Endpoint:
GET /notifications - Query Params:
?unread=true&limit=20&offset=0 - Response:
{ notifications: Array<Notification>, unreadCount: number }
- Status: 🔴 Pending
- Priority: Low
- Description: Mark notification(s) as read
- Tasks:
- Validate notification belongs to user
- Update
is_read = truein Supabase - Support bulk mark as read
- Return updated notification
- Endpoint:
PATCH /notifications/:id/read - Endpoint:
PATCH /notifications/read-all - Response:
{ success: boolean }
Goal: Comprehensive testing and validation Dependencies: All phases Status: 🔴 Not Started
- Status: 🔴 Pending
- Priority: High
- Description: Unit test coverage for critical services
- Scope:
- AuthService: nonce generation, signature verification
- ReputationService: score fetching, caching
- LoanService: quote calculation, transaction building
- LiquidityService: deposit/withdrawal logic
- Target: 80%+ coverage for services
- Status: 🔴 Pending
- Priority: High
- Description: End-to-end testing of complete user journeys
- Test Cases:
- Happy path: Auth → Quote → Create Loan → Repay → Complete
- Reputation update flow
- Default scenario
- Liquidity provider deposit/withdraw
- API ↔ Smart Contract integration
- Target: All critical flows tested
| Phase | Name | Issues | Completed | Status |
|---|---|---|---|---|
| 1 | Wallet Authentication | 3 | 0/3 | 🔴 Not Started |
| 2 | User Profile | 2 | 0/2 | 🔴 Not Started |
| 3 | Merchants | 2 | 0/2 | 🔴 Not Started |
| 4 | Reputation | 2 | 0/2 | 🔴 Not Started |
| 5 | BNPL Loans | 4 | 0/4 | 🔴 Not Started |
| 6 | Transactions | 2 | 0/2 | 🔴 Not Started |
| 7 | Liquidity Pool API | 4 | 0/4 | 🔴 Not Started |
| 8 | Indexation & Jobs | 3 | 0/3 | 🔴 Not Started |
| 9 | Notifications | 2 | 0/2 | 🔴 Not Started |
| 10 | Quality Assurance | 2 | 0/2 | 🔴 Not Started |
Phase 1 (Auth)
├─> Phase 2 (Profile)
├─> Phase 3 (Merchants)
├─> Phase 4 (Reputation)
│ └─> Phase 5 (Loans)
│ ├─> Phase 6 (Transactions)
│ │ └─> Phase 8 (Indexer)
│ │ └─> Phase 9 (Notifications)
│ └─> Phase 7 (Liquidity)
│ └─> Phase 8 (Indexer)
└─> Phase 10 (Testing) - Depends on all phases
- Start with Phase 1: Implement wallet-based authentication
- Setup Testing: Configure Jest and create test utilities
- Deploy Contracts: Ensure Reputation contract is on testnet
- Configure Supabase: Create necessary tables and migrations
- Setup Redis: For caching layer (Phase 4)
- Testnet First: All development should be done on Stellar testnet
- API Documentation: Use Swagger/OpenAPI for endpoint documentation
- Error Handling: Follow error-handling.md standards
- Security: Never expose private keys, validate all inputs
- Performance: Cache blockchain reads when possible
Last Updated: 2026-02-13