Off-chain orchestration layer for Buy Now Pay Later (BNPL) flows on Stellar Network
Features β’ Tech Stack β’ Quick Start β’ Documentation β’ Contributing
TrustUp API is a production-ready backend service that orchestrates BNPL (Buy Now Pay Later) transactions on the Stellar blockchain. Built with NestJS and Fastify, it provides a fast, scalable off-chain layer that enhances user experience while maintaining blockchain decentralization.
- π Wallet-based Authentication - Secure signature-based auth with JWT
- π° BNPL Loan Management - Create, track, and repay loans on-chain
- β Reputation System - On-chain reputation scoring with fast cache
- πͺ Merchant Integration - Merchant registry and loan quotes
- π§ Liquidity Pool - Investor deposits and withdrawals
- π Real-time Indexing - Background jobs sync blockchain events
- π Notifications - Loan reminders and status updates
- π Production Ready - Comprehensive testing, logging, and monitoring
N20 Β· TS5 Β· NJS10/FST4 Β· SSDK11/SRPC Β· SBP15 Β· RDS7 Β· BMQ5 Β· ZOD3 Β· JWT10 Β· PIN8 Β· SNT8
| Category | Technology | Version |
|---|---|---|
| Runtime | Node.js | 20 LTS |
| Language | TypeScript | 5.4 |
| Framework | NestJS | 10.3 |
| HTTP Server | Fastify | 4.28 |
| Blockchain | Stellar SDK | 11.2 |
| Database | Supabase (Postgres) | 15 |
| Cache/Jobs | Redis | 7 |
| Queue | BullMQ | 5.12 |
| Validation | Zod | 3.23 |
| Auth | JWT | 10.2 |
| Logging | Pino | 8.21 |
| Monitoring | Sentry | 8.14 |
- π Stellar Network - Mainnet & Testnet support
- π· Soroban - Smart contract interactions
- π‘ Horizon API - Transaction queries
- π Soroban RPC - Contract state reading
TrustUp-API/
βββ src/
β βββ main.ts # Application bootstrap
β βββ app.module.ts # Root module
β βββ config/ # Configuration (env, swagger)
β βββ modules/ # API modules (auth, loans, reputation, etc.)
β βββ blockchain/ # Stellar/Soroban clients
β β βββ stellar/ # Stellar network client
β β βββ soroban/ # Soroban RPC client
β β βββ contracts/ # Contract clients (TypeScript wrappers)
β βββ database/ # Supabase client and repositories
β βββ jobs/ # Background jobs (BullMQ)
β βββ common/ # Shared utilities (guards, filters, utils)
βββ test/
β βββ unit/ # Unit tests
β βββ e2e/ # End-to-end tests
β βββ fixtures/ # Test data
β βββ helpers/ # Test helpers
βββ docs/ # Documentation
β βββ architecture/ # Architecture documentation
β βββ development/ # Development guides and standards
β βββ setup/ # Setup and configuration guides
β βββ api/ # API reference
βββ supabase/
β βββ migrations/ # Database migrations
βββ CONTRIBUTING.md # Contribution guidelines
βββ ROADMAP.md # Development roadmap
βββ SECURITY.md # Security policy
βββ LICENSE # MIT License
- Node.js 20 LTS or higher
- npm or yarn
- Redis (for jobs and cache)
- Supabase account and project
# Clone the repository
git clone https://github.com/TrustUp-app/TrustUp-API.git
cd TrustUp-API
# Install dependencies
npm install
# Copy environment file
cp .env.example .env
# Configure your .env file (see Configuration section)-
Supabase Setup
- Create a project at supabase.com
- Get your credentials from Settings β API
- Add to
.env:SUPABASE_URL=your_project_url SUPABASE_ANON_KEY=your_anon_key SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
-
Stellar Configuration
STELLAR_NETWORK=testnet # or mainnet STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
-
Redis Setup
REDIS_HOST=localhost REDIS_PORT=6379
-
JWT Secrets
JWT_SECRET=your_jwt_secret JWT_REFRESH_SECRET=your_refresh_secret
For complete setup instructions, see Installation Guide and Contributing Guide.
# Development mode (with hot reload)
npm run dev
# Production build
npm run build
npm run start:prod
# The API will be available at http://localhost:4000/api/v1# Install Supabase CLI (if not already installed)
npm install -g supabase
# Login to Supabase
supabase login
# Link your project
supabase link --project-ref your-project-ref
# Apply migrations
supabase db push# Unit tests
npm run test
# Watch mode
npm run test:watch
# E2E tests
npm run test:e2e
# Coverage report
npm run test:covComprehensive documentation is organized into the following categories:
- Architecture Overview - System architecture and design principles
- Blockchain Layer - Stellar/Soroban integration
- Database Schema - PostgreSQL database design
- Installation Guide - Step-by-step setup instructions
- Environment Variables - Configuration reference
- Supabase Setup - Database setup guide
- Naming Conventions - Code style and conventions
- Controllers Structure - Controller patterns
- Services Structure - Service layer patterns
- DTO Standards - Data transfer object patterns
- Response Standards - API response formats
- Error Handling - Error handling standards
- Guards & Filters - Authentication and validation
- Logging Standards - Logging best practices
- Testing Structure - Testing guidelines
- API Endpoints - Complete API documentation
- Roadmap - Development phases and progress
- Contributing Guide - How to contribute to the project
- Security Policy - Security guidelines and reporting vulnerabilities
Once the server is running, visit:
- Swagger UI:
http://localhost:4000/api/v1/docs - Health Check:
http://localhost:4000/api/v1/health
- π On-chain is truth - Blockchain is the source of truth
- β‘ Fast UX - Off-chain indexing for quick queries
- π Decentralized - Users sign transactions, API doesn't hold keys
- π§© Modular - Replaceable backend components
- π Observable - Comprehensive logging and monitoring
- β Tested - Unit, integration, and E2E tests
- Wallet Signature Authentication - No password storage
- JWT Tokens - Secure access and refresh tokens
- Helmet - Security headers
- Rate Limiting - Throttler protection
- Row Level Security - Database-level access control
- Input Validation - Zod schema validation
We welcome contributions! Please see our Contributing Guide for:
- Development setup
- Code style guidelines
- Testing requirements
- Pull request process
Check out the Roadmap to see what we're working on and find areas where you can contribute.
- Stellar Development Foundation - For the amazing blockchain platform
- NestJS - For the excellent framework
- Supabase - For the database infrastructure
- π Documentation
- π Issue Tracker
- π¬ Discussions
This project is licensed under the MIT License - see the LICENSE file for details.