DeFi Payment Streaming on Stellar
Programmable, real-time payment streams and recurring subscriptions powered by Soroban smart contracts.
FlowFi (also known as LiquidFlow) is a comprehensive DeFi platform built on the Stellar network that enables continuous payment streams and recurring subscriptions using stablecoins. By leveraging Soroban smart contracts, FlowFi provides autonomous, accurate-to-the-second distribution of funds for use cases like salary payments, service subscriptions, and yield farming.
FlowFi consists of three main components:
- Frontend: Next.js application with React, TypeScript, and Tailwind CSS
- Backend: Express.js API with TypeScript, Prisma ORM, and PostgreSQL
- Smart Contracts: Soroban contracts written in Rust for on-chain logic
The diagram below shows how a stream event on-chain is intended to reach the dashboard. Each edge is labeled with its current status:
flowchart LR
C[Soroban Contract\nstream_contract] -->|Implemented| H[Stellar Horizon]
H -->|Planned: listener/indexer| I[Backend Indexer]
I -->|Planned: Prisma writes| D[(PostgreSQL\nStream / StreamEvent)]
D -->|Planned| A[Backend API]
A -->|Planned| F[Frontend Dashboard]
- Implemented:
contracts/stream_contract/src/lib.rsemits real Soroban events (stream_created,stream_topped_up, etc.) on every state change. - Planned: a Horizon listener/indexer that consumes those events and writes to the
Stream/StreamEventPrisma models (schema already exists atbackend/prisma/schema.prisma), a backend API that serves that data, and a frontend that consumes it live. Today,createStreamreturns a mock response,frontend/hooks/useContractEvents.tsis a stub, and the dashboard renders hardcoded mock data (frontend/lib/dashboard.ts).
- Real-time Streaming: Pay by the second for services or salaries
- Recurring Subscriptions: Automate monthly or weekly payments
- Soroban Powered: Secure and efficient execution on Stellar's smart contract platform
- Modern Tech Stack: React 19, Next.js 16, TypeScript, Express.js, Prisma
- Docker Support: Containerized deployment with Docker Compose
- Developer Tools: Comprehensive API documentation with Swagger
FlowFi is an npm-workspaces monorepo with three top-level packages:
contracts/— Soroban smart contracts written in Rust, managed as a separate Cargo workspace (not part of the npm workspaces below).backend/— Express.js + TypeScript API using Prisma ORM against PostgreSQL.frontend/— Next.js + Tailwind CSS dashboard, integrating with Soroban/Freighter for wallet interactions.
The root package.json declares "workspaces": ["frontend", "backend"], so a single npm install at the repo root installs dependencies for both frontend/ and backend/. contracts/ is a standalone Rust/Cargo workspace and is built independently with cargo from inside contracts/. Each package's dev/build/test scripts (npm run dev, cargo build, etc.) are still run from within that package's own directory — see Quick Start below for the exact commands.
flowfi/
├── backend/ # Express.js + TypeScript backend
│ ├── src/
│ │ ├── app.ts # Main application setup
│ │ ├── config/ # Configuration files
│ │ ├── controllers/ # Route controllers
│ │ ├── lib/ # Utility libraries
│ │ ├── middleware/ # Express middleware
│ │ ├── routes/ # API routes
│ │ └── validators/ # Input validation schemas
│ ├── prisma/ # Database schema and migrations
│ ├── devOps/ # Docker and deployment configs
│ └── tests/ # Backend test suite
├── contracts/ # Soroban smart contracts
│ ├── stream_contract/ # Core streaming logic contract
│ └── Cargo.toml # Rust workspace configuration
├── frontend/ # Next.js + Tailwind CSS frontend
│ ├── app/ # Next.js app router pages
│ ├── components/ # Reusable React components
│ ├── context/ # React context providers
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utility libraries
│ └── public/ # Static assets
├── .github/ # GitHub workflows and templates
└── CONTRIBUTING.md # Detailed contribution guidelines
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- npm (comes with Node.js)
- Git
- Rust (latest stable version)
- Cargo (comes with Rust)
- Docker & Docker Compose (recommended for full stack)
- PostgreSQL (if not using Docker)
- Stellar CLI (for contract deployment and interaction)
- Prisma Studio (for database management)
The fastest way to run the complete FlowFi stack locally:
-
Clone and navigate to the project:
git clone <repository-url> cd LiquidFlow
-
Set up environment variables:
cp backend/.env.example backend/.env # Edit backend/.env with your configuration -
Start all services:
cd backend/devOps/docker docker compose up --build
This starts:
- PostgreSQL database on port
5432 - Backend API on port
3001 - Nginx reverse proxy on ports
80and443
- In a separate terminal, start the frontend:
cd frontend npm install npm run dev
The frontend will be available at http://localhost:3000
-
Install dependencies:
cd backend npm install -
Set up environment:
cp .env.example .env # Edit .env with your database and Stellar configuration -
Set up the database:
npx prisma generate npx prisma migrate dev
-
Start the backend:
npm run dev
The backend API will be available at http://localhost:3001
-
Install dependencies:
cd frontend npm install -
Start the development server:
npm run dev
The frontend will be available at http://localhost:3000
-
Build the contracts:
cd contracts cargo build --target wasm32-unknown-unknown --release -
For contract development and testing:
cd stream_contract cargo test
Key environment variables in backend/.env:
# Server Configuration
PORT=3001
NODE_ENV=development
# Stellar Network
STELLAR_NETWORK=testnet
STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
# Database
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_DB=liquidflow
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}- View database:
npx prisma studio - Generate migrations:
npx prisma migrate dev - Reset database:
npx prisma migrate reset - Generate Prisma client:
npx prisma generate
Once the backend is running, visit http://localhost:3001/api-docs for interactive Swagger documentation.
- Backend tests:
cd backend && npm test - Contract tests:
cd contracts && cargo test - Frontend tests:
cd frontend && npm test(if configured)
# Start all services
docker compose up --build
# Start in detached mode
docker compose up -d --build
# View logs
docker compose logs -f
# Stop services
docker compose down
# Stop and remove volumes (reset database)
docker compose down -v
# Rebuild specific service
docker compose up --build backendFor production deployment, use the production Docker Compose configuration:
docker compose -f docker-compose.prod.yml up -d --build- Install Freighter wallet browser extension
- Switch to Testnet in Freighter settings
- Get testnet tokens from the Stellar testnet faucet
-
Build contracts for deployment:
cd contracts cargo build --target wasm32-unknown-unknown --release -
Deploy using Stellar CLI:
stellar contract deploy ./target/wasm32-unknown-unknown/release/stream_contract.wasm \ --source <your-account> \ --network testnet
- Port conflicts: Ensure ports 3000, 3001, and 5432 are available
- Database connection: Verify PostgreSQL is running and credentials are correct
- Stellar network: Ensure you're using the correct network (testnet/mainnet)
- Contract build failures: Verify Rust and wasm32 target are installed
- Check the GitHub Issues for known problems
- Review the Contributing Guide for development guidelines
- Join our community discussions for support
We welcome contributions! Please see our Contributing Guide for detailed guidelines on:
- Bug reporting procedures
- Pull request submission process
- Code style and standards
- External developer guidelines
- Framework: Next.js 16 with App Router
- UI Library: React 19
- Styling: Tailwind CSS 4
- TypeScript: Full type safety
- Stellar Integration: Soroban React, Freighter API
- Icons: Lucide React
- State Management: React Context
- Runtime: Node.js with ES modules
- Framework: Express.js 5
- Language: TypeScript
- Database: PostgreSQL with Prisma ORM
- Validation: Zod schemas
- Logging: Winston
- Documentation: Swagger/OpenAPI
- Testing: Vitest
- Language: Rust
- Platform: Soroban (Stellar)
- Build Target: WASM32
- Containerization: Docker & Docker Compose
- Reverse Proxy: Nginx
- Version Control: Git with Husky hooks
- CI/CD: GitHub Actions
This project is licensed under the MIT License - see the LICENSE file for details.
- Stellar Development Foundation for the Soroban platform
- All contributors who help improve FlowFi
- Open source community for the tools and libraries that make this project possible
This project follows the all-contributors specification. Contributions of any kind welcome!