Production-ready Next.js frontend for blockchain-powered logistics platform on Stellar
FaniLab is a decentralized logistics platform that connects senders with delivery drivers using blockchain technology for trustless escrow and transparent delivery tracking.
- π Secure Escrow: Smart contract-based payment protection
- π¦ Real-time Tracking: Monitor delivery status on blockchain
- π° Instant Settlement: Automatic payment release upon completion
- π Decentralized: No central authority or intermediaries
- π Transparent: All transactions verifiable on Stellar blockchain
βββββββββββββββββββ
β Next.js App β
β (Frontend) β
ββββββββββ¬βββββββββ
β
ββββ Freighter Wallet (User Auth)
β
ββββ Soroban RPC (Blockchain)
β βββ Smart Contracts
β βββ Escrow
β βββ Delivery
β βββ Dispute
β
ββββ API Server (Indexer)
βββ Database
# Clone the repository
git clone https://github.com/your-org/fanilab-frontend.git
cd fanilab-frontend
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env.local
# Configure your contract addresses in .env.local
# NEXT_PUBLIC_ESCROW_CONTRACT_ID=C...
# NEXT_PUBLIC_DELIVERY_CONTRACT_ID=C...
# NEXT_PUBLIC_DISPUTE_CONTRACT_ID=C...
# Start development server
npm run devOpen http://localhost:3000 in your browser.
fanilab-frontend/
βββ app/ # Next.js App Router
β βββ create-delivery/ # Create delivery page
β βββ deliveries/ # Browse deliveries
β βββ dashboard/ # User dashboard
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
βββ components/ # React components
β βββ Header.tsx
β βββ Footer.tsx
β βββ Toaster.tsx
βββ lib/ # Business logic
β βββ soroban/ # Stellar/Soroban SDK
β β βββ index.ts # Core utilities
β β βββ contracts/ # Contract integrations
β β βββ escrow.ts
β β βββ delivery.ts
β βββ store/ # State management (Zustand)
β β βββ wallet-store.ts
β β βββ delivery-store.ts
β βββ hooks/ # Custom React hooks
β β βββ useWallet.ts
β β βββ useDeliveries.ts
β βββ validations/ # Zod schemas
β βββ errors/ # Error handling
β βββ stellar.ts # Wallet integration
β βββ contracts.ts # High-level API
β βββ utils.ts
βββ types/ # TypeScript definitions
βββ __tests__/ # Unit tests (Vitest)
βββ e2e/ # E2E tests (Playwright)
βββ public/ # Static assets
βββ [config files]
| Variable | Description | Example |
|---|---|---|
NEXT_PUBLIC_STELLAR_NETWORK |
Network to use | testnet or mainnet |
NEXT_PUBLIC_SOROBAN_RPC_URL |
Soroban RPC endpoint | https://soroban-testnet.stellar.org |
NEXT_PUBLIC_NETWORK_PASSPHRASE |
Network passphrase | Test SDF Network ; September 2015 |
NEXT_PUBLIC_ESCROW_CONTRACT_ID |
Escrow contract address | C... |
NEXT_PUBLIC_DELIVERY_CONTRACT_ID |
Delivery contract address | C... |
NEXT_PUBLIC_DISPUTE_CONTRACT_ID |
Dispute contract address | C... |
NEXT_PUBLIC_API_URL |
Backend API URL | http://localhost:3001 |
Testnet (Development)
NEXT_PUBLIC_STELLAR_NETWORK=testnet
NEXT_PUBLIC_SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
NEXT_PUBLIC_NETWORK_PASSPHRASE=Test SDF Network ; September 2015Mainnet (Production)
NEXT_PUBLIC_STELLAR_NETWORK=mainnet
NEXT_PUBLIC_SOROBAN_RPC_URL=https://soroban.stellar.org
NEXT_PUBLIC_NETWORK_PASSPHRASE=Public Global Stellar Network ; September 2015# Run all tests
npm run test
# Run with UI
npm run test:ui
# Generate coverage report
npm run test:coverage# Run E2E tests
npm run test:e2e
# Run in headed mode
npx playwright test --headed
# Run specific test
npx playwright test e2e/home.spec.tsnpm run type-check# Check for issues
npm run lint
# Auto-fix issues
npm run lint:fix# Format all files
npm run format
# Check formatting
npm run format:checkGit hooks automatically run linting and formatting on commit using Husky and lint-staged.
# Create production build
npm run build
# Test production build locally
npm start
# Analyze bundle size
npm run build -- --analyze# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod# Build image
docker build -t fanilab-frontend .
# Run container
docker run -p 3000:3000 --env-file .env.production fanilab-frontendSee PRODUCTION_SETUP.md for detailed deployment instructions.
- Deploy smart contracts from
FaniLab-SmartContractrepository - Note contract IDs
- Update
.env.localwith contract addresses - Verify contracts on Stellar Expert
// 1. Create delivery with escrow
const { deliveryId, escrowId } = await createDelivery({
sender: address,
amount: 10.5,
pickupLocation: "123 Main St",
deliveryLocation: "456 Oak Ave"
});
// 2. Driver accepts delivery
await acceptDelivery({
deliveryId,
driverAddress: driverAddress
});
// 3. Recipient confirms delivery (releases payment)
await confirmDelivery({
deliveryId,
recipientAddress: address,
escrowId
});import { useWallet } from '@/lib/hooks/useWallet';
const {
address, // User's Stellar address
balance, // XLM balance
isConnected, // Connection status
connect, // Connect wallet
disconnect, // Disconnect wallet
refreshBalance // Refresh balance
} = useWallet();import { createDelivery, acceptDelivery } from '@/lib/contracts';
// Create delivery
const result = await createDelivery({
sender: 'G...',
amount: 10.5,
pickupLocation: 'Location A',
deliveryLocation: 'Location B',
description: 'Package details'
});
// Accept delivery
await acceptDelivery({
deliveryId: 'delivery-id',
driverAddress: 'G...'
});See API.md for complete API documentation.
- Framework: Next.js 14 (App Router)
- Language: TypeScript 5
- Styling: TailwindCSS 3
- State: Zustand + SWR
- Validation: Zod
- Forms: React Hook Form
- Testing: Vitest + Playwright
- Blockchain: Stellar SDK 11
- Wallet: Freighter API
Wallet not connecting?
- Ensure Freighter extension is installed
- Check you're on the correct network (testnet/mainnet)
- Refresh the page
Transaction failing?
- Verify contract addresses are correct
- Ensure sufficient XLM balance (including fees)
- Check network connectivity
Build errors?
- Clear
.nextfolder:rm -rf .next - Delete
node_modulesand reinstall:rm -rf node_modules && npm install - Check Node.js version:
node --version(requires 18+)
See TROUBLESHOOTING.md for more help.
We welcome contributions! Please see CONTRIBUTING.md for details.
Thanks to all contributors! π
This project is licensed under the MIT License - see LICENSE file for details.
- FaniLab-SmartContract - Soroban smart contracts
- FaniLab-Backend - Node.js API server and indexer
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@fanilab.com
- Discord: Join our Discord
- Stellar Development Foundation
- Freighter Wallet Team
- Next.js Team
- Open source community
Built with β€οΈ for the Stellar ecosystem