Skip to content

TrustUp API is a backend service that orchestrates BNPL (Buy Now Pay Later)

License

Notifications You must be signed in to change notification settings

TrustUp-app/TrustUp-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

90 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TrustUp-Banner

Stellar TypeScript NestJS Node.js

Open Source TypeScript Node.js

Off-chain orchestration layer for Buy Now Pay Later (BNPL) flows on Stellar Network

Features β€’ Tech Stack β€’ Quick Start β€’ Documentation β€’ Contributing


πŸ“– About

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.

Key Features

  • πŸ” 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

πŸ›  Tech Stack

N20 Β· TS5 Β· NJS10/FST4 Β· SSDK11/SRPC Β· SBP15 Β· RDS7 Β· BMQ5 Β· ZOD3 Β· JWT10 Β· PIN8 Β· SNT8

Core Technologies

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

Blockchain Integration

  • 🌟 Stellar Network - Mainnet & Testnet support
  • πŸ”· Soroban - Smart contract interactions
  • πŸ“‘ Horizon API - Transaction queries
  • πŸ”— Soroban RPC - Contract state reading

πŸ“ Project Structure

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

πŸš€ Quick Start

Prerequisites

  • Node.js 20 LTS or higher
  • npm or yarn
  • Redis (for jobs and cache)
  • Supabase account and project

Installation

# 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)

Configuration

  1. 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
  2. Stellar Configuration

    STELLAR_NETWORK=testnet  # or mainnet
    STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
    SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
  3. Redis Setup

    REDIS_HOST=localhost
    REDIS_PORT=6379
  4. JWT Secrets

    JWT_SECRET=your_jwt_secret
    JWT_REFRESH_SECRET=your_refresh_secret

For complete setup instructions, see Installation Guide and Contributing Guide.

Running the Application

# 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

Database Migrations

# 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

πŸ§ͺ Testing

# Unit tests
npm run test

# Watch mode
npm run test:watch

# E2E tests
npm run test:e2e

# Coverage report
npm run test:cov

πŸ“š Documentation

Comprehensive documentation is organized into the following categories:

πŸ— Architecture

πŸš€ Getting Started

πŸ’» Development

πŸ“‘ API Reference

🀝 Contributing

Interactive Documentation

Once the server is running, visit:

  • Swagger UI: http://localhost:4000/api/v1/docs
  • Health Check: http://localhost:4000/api/v1/health

πŸ— Architecture Principles

  • πŸ”— 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

πŸ” Security

  • 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

🀝 Contributing

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.

πŸ™ Acknowledgments

πŸ“ž Support

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ for the Stellar ecosystem

Stellar Open Source MIT License

About

TrustUp API is a backend service that orchestrates BNPL (Buy Now Pay Later)

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors