Transparent Agricultural Payment Network built on Stellar
A production-ready agricultural payment platform that enables transparent, escrow-backed, blockchain-verifiable transactions between farmers and buyers using the Stellar Testnet.
- π Website: https://tanichain.arvinlabs.tech
- π Swagger: https://tanichain.arvinlabs.tech/api/docs
- π» GitHub: https://github.com/ArvinFarrelP/tanichain
TaniChain is a modern full-stack web platform that digitizes agricultural transactions by integrating traditional marketplace workflows with blockchain-backed payment verification.
Instead of relying on manual payment confirmation and opaque transaction records, TaniChain records payment commitments and settlement metadata on the Stellar Testnet, providing transparency, traceability, and trust for both farmers and buyers.
The platform combines a responsive Next.js frontend, an Express.js REST API, PostgreSQL database, Docker-based deployment, Nginx reverse proxy, HTTPS encryption via Let's Encrypt, and Cloudflare DNS/CDN for production-grade hosting.
- π± Farmer product marketplace
- π³ Escrow-inspired payment workflow
- βοΈ Stellar Testnet transaction recording
- π JWT Authentication & Role-Based Access Control (RBAC)
- π€ Buyer, Farmer, and Administrator roles
- π¦ Order management system
- πΌ Wallet management
- π Analytics dashboard
- π Activity logging
- π Notification system
- π Interactive Swagger API Documentation
- π³ Dockerized deployment
- π HTTPS production deployment using Nginx + Let's Encrypt + Cloudflare
- Next.js 15
- React
- TypeScript
- Tailwind CSS
- Axios
- Express.js
- TypeScript
- Prisma ORM
- JWT Authentication
- Swagger OpenAPI
- Helmet
- Rate Limiter
- PostgreSQL 16
- Stellar SDK
- Stellar Testnet
- Horizon API
- Docker
- Docker Compose
- Nginx Reverse Proxy
- Let's Encrypt SSL
- Cloudflare DNS & CDN
- Ubuntu Server
tanichain/
βββ backend/
β βββ prisma/schema.prisma
β βββ src/
β β βββ config/ # env, database client
β β βββ middleware/ # auth, validation, rate limiting, error handling
β β βββ modules/
β β β βββ auth/ # register, login, profile
β β β βββ user/ # profile update, change password
β β β βββ wallet/ # Stellar keypair, Friendbot, wallet service, QR codes
β β β βββ escrow/ # platform escrow wallet
β β β βββ product/ # farmer CRUD, buyer browsing
β β β βββ order/ # order lifecycle
β β β βββ payment/ # Payment Commitment + Escrow workflow
β β β βββ transaction/ # transaction history, CSV export
β β β βββ invoice/ # PDF invoice generation
β β β βββ export/ # CSV export helpers
β β β βββ notification/
β β β βββ analytics/ # role-aware + platform-wide analytics
β β β βββ activity/ # audit log
β β β βββ admin/ # admin-only management endpoints
β β βββ utils/ # jwt, crypto, logger, AppError
β β βββ swagger/
β βββ Dockerfile
βββ frontend/
β βββ src/
β β βββ app/
β β β βββ (landing, /login, /register)
β β β βββ products/, products/[id]/ # marketplace
β β β βββ dashboard/
β β β βββ products/, orders/ # farmer/buyer workflows
β β β βββ transactions/, profile/
β β β βββ admin/ # overview, users, products, orders, transactions, wallets, activity
β β βββ components/ui/ # shadcn-style primitives
β β βββ components/layout/ # DashboardHeader, AdminNav
β β βββ components/products/ # ProductForm
β β βββ lib/ # api client, formatting, utils
β β βββ store/ # zustand auth store
β βββ Dockerfile
βββ docker/nginx/
βββ docs/
βββ docker-compose.yml
βββ .env.example
Users
β
β HTTPS
βΌ
Cloudflare CDN
β
βΌ
Let's Encrypt SSL
β
βΌ
Nginx Reverse Proxy
(HTTPS Termination)
β
βββββββββββββββββ΄ββββββββββββββββ
β β
βΌ βΌ
Next.js Frontend Express Backend
(React + TypeScript) (REST API + Prisma)
β β
β REST API β
βββββββββββββββββ¬ββββββββββββββββ
β
βΌ
PostgreSQL 16
β
βββββββββββββββββ΄ββββββββββββββββ
β β
βΌ βΌ
Stellar Horizon API Swagger OpenAPI
(Blockchain) Documentation
Internet
β
βΌ
Cloudflare DNS
β
βΌ
tanichain.arvinlabs.tech
β
HTTPS (TLS)
β
βΌ
Ubuntu Server (AWS EC2)
β
Docker Compose
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Nginx β
β β
β / β Frontend (Next.js) β
β /api/* β Backend (Express.js) β
β /api/docs β Swagger UI β
βββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
PostgreSQL Database
Buyer / Farmer
β
βΌ
Frontend (Next.js)
β
REST API Request
β
βΌ
Express.js Backend
β
JWT Authentication
β
Business Logic
β
Prisma ORM
β
βΌ
PostgreSQL
β
βΌ
Response
β
βΌ
Frontend UI Update
Buyer
β
Creates Order
β
βΌ
Payment Commitment
β
βΌ
Backend Validation
β
βΌ
Record Metadata to
Stellar Testnet
β
βΌ
Transaction Hash Stored
in Database
β
βΌ
Farmer Verification
β
βΌ
Payment Released
Docker Compose
βββ nginx
β β
β βββ HTTPS Reverse Proxy
β βββ SSL Termination
β βββ Route Requests
β
βββ frontend
β β
β βββ Next.js Production Server
β
βββ backend
β β
β βββ Express API
β βββ Prisma ORM
β βββ Swagger Docs
β
βββ postgres
β
βββ Persistent Database
TaniChain is designed with security-first principles and includes multiple layers of protection.
- JWT Authentication
- Secure password hashing
- Role-Based Access Control (RBAC)
- Protected API endpoints
- Helmet Security Headers
- Rate Limiting
- Input Validation
- Centralized Error Handling
- CORS Protection
- HTTPS via Let's Encrypt
- Cloudflare DNS & CDN
- Nginx Reverse Proxy
- Secure Docker Network
- Environment Variable Management
Before running TaniChain, make sure the following software is installed:
- Docker
- Docker Compose
- Git
- Node.js 20+ (optional for local development)
- PostgreSQL 16 (optional for local development)
git clone https://github.com/ArvinFarrelP/tanichain.git
cd tanichainCopy the example environment file.
cp .env.example .envEdit the configuration as needed.
Example:
POSTGRES_USER=tanichain
POSTGRES_PASSWORD=your_password
POSTGRES_DB=tanichain
JWT_SECRET=your_super_secret
WALLET_ENCRYPTION_KEY=your_encryption_key
STELLAR_NETWORK=TESTNET
STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
STELLAR_FRIENDBOT_URL=https://friendbot.stellar.org
CORS_ORIGIN=https://tanichain.arvinlabs.tech
NEXT_PUBLIC_API_URL=https://tanichain.arvinlabs.tech/apiBuild every container.
docker compose buildRun all services.
docker compose up -dCheck running containers.
docker psExpected containers:
tanichain-nginx
tanichain-frontend
tanichain-backend
tanichain-postgres
docker psExpected output:
STATUS
tanichain-nginx healthy
tanichain-frontend healthy
tanichain-backend healthy
tanichain-postgres healthy
Backend Health Endpoint
curl https://tanichain.arvinlabs.tech/api/healthResponse
{
"success": true,
"message": "TaniChain API is healthy"
}TaniChain is deployed using Docker Compose on Ubuntu Server with Nginx Reverse Proxy and HTTPS.
Website
https://tanichain.arvinlabs.tech
Swagger Documentation
https://tanichain.arvinlabs.tech/api/docs
API Endpoint
https://tanichain.arvinlabs.tech/api
Production deployment includes:
- Let's Encrypt SSL Certificate
- Automatic HTTP β HTTPS Redirect
- TLS 1.2 / TLS 1.3
- Nginx Reverse Proxy
- Cloudflare DNS
- Dockerized Infrastructure
cd backend
npm install
npx prisma generate
npx prisma migrate dev
npm run devBackend runs on
http://localhost:4000
cd frontend
npm install
npm run devFrontend runs on
http://localhost:3000
Swagger UI
Production
https://tanichain.arvinlabs.tech/api/docs
Development
http://localhost:4000/api/docs
OpenAPI JSON
http://localhost:4000/api/docs.json
Build images
docker compose buildStart containers
docker compose up -dStop containers
docker compose downRestart
docker compose restartView logs
docker compose logs -fCheck running containers
docker psOpen backend shell
docker compose exec backend shOpen PostgreSQL
docker compose exec postgres psql -U tanichainTaniChain supports Role-Based Access Control (RBAC) with four different user roles.
| Role | Permissions |
|---|---|
| π¨βπΎ Farmer | Manage products, receive orders, track payments |
| π Buyer | Browse marketplace, purchase products, view transactions |
| π’ Cooperative | Manage cooperative-related activities (future expansion) |
| π Administrator | Full platform management and analytics |
Authentication features include:
- JWT Authentication
- Password Hashing (bcrypt)
- Protected Routes
- Role-Based Authorization (RBAC)
- Secure Session Management
Farmers can publish agricultural products while buyers can browse available commodities in real time.
- Create Products
- Update Products
- Archive Products
- Inventory Management
- Product Categories
- Stock Management
- Browse Marketplace
- Product Detail
- Search Products
- Category Filtering
- Pagination
- Purchase Products
Instead of relying on traditional payment confirmation, TaniChain introduces a transparent payment commitment process backed by Stellar Testnet transactions.
Workflow:
Buyer
β
βΌ
Create Order
β
βΌ
Payment Commitment
β
βΌ
Record Metadata to Stellar
Testnet Blockchain
β
βΌ
Farmer Confirmation
β
βΌ
Payment Released
This provides:
- Transparent payments
- Immutable transaction records
- Verifiable blockchain history
- Escrow-inspired settlement workflow
TaniChain integrates with the Stellar Testnet to provide secure and transparent payment verification.
Features include:
- Automatic Wallet Creation
- Friendbot Funding
- Stellar SDK Integration
- Horizon API
- Transaction Explorer Links
- Blockchain Transaction History
- Wallet Balance Tracking
Every registered user automatically receives:
- Stellar Wallet
- Public Key
- Encrypted Secret Key
- Initial Testnet Balance
Each user owns a blockchain wallet.
Features include:
- Wallet Address
- Current Balance
- QR Code Generation
- Transaction History
- Payment QR
- Blockchain Explorer Link
Complete order lifecycle management.
Supported order states include:
- Pending
- Payment Committed
- Paid
- Processing
- Delivered
- Completed
- Cancelled
Users can:
- View Orders
- Track Status
- Search Orders
- Filter Orders
- Download Invoice
Every completed order can generate a professional invoice.
Invoice includes:
- Buyer Information
- Farmer Information
- Product Details
- Quantity
- Total Price
- Payment Status
- Blockchain Transaction Hash
- Order Date
Users can export data into CSV format.
Supported exports:
- Transactions
- Products
- Orders
Administrator exports:
- Users
- Products
- Orders
- Transactions
Interactive dashboards provide valuable insights into platform activities.
Dashboard Features
- Revenue Summary
- Monthly Revenue
- Wallet Balance
- Pending Orders
- Completed Orders
- Transaction Statistics
- Charts & Graphs
Built using:
- Recharts
- React
- TypeScript
Administrators have complete visibility over the platform.
Features include:
- User Management
- Product Management
- Order Management
- Transaction Management
- Wallet Monitoring
- Activity Logs
- Platform Analytics
Real-time notifications are generated for important events.
Notifications include:
- New Order
- Payment Committed
- Payment Released
- Delivery Confirmation
- Transaction Updates
Every important action is recorded.
Examples:
- User Login
- Registration
- Product Creation
- Product Update
- Order Creation
- Payment Commitment
- Transaction Completion
Administrators can monitor all platform activities.
β Production-ready deployment
β Live production deployment on AWS EC2
β Custom domain with HTTPS
β Let's Encrypt SSL Certificate
β Cloudflare DNS & CDN integration
β Dockerized infrastructure
β Docker Compose deployment
β Nginx Reverse Proxy
β RESTful API architecture
β PostgreSQL database
β Swagger OpenAPI Documentation
β Role-Based Access Control (RBAC)
β Blockchain-powered payment verification
β Stellar Testnet integration
β Modern UI built with Next.js 15
β TypeScript across frontend and backend
β Responsive web application
β Interactive analytics dashboard
Below are screenshots of the current TaniChain application.
TaniChain integrates with the Stellar Testnet using the Stellar SDK and Horizon API. Every registered user automatically receives a funded Stellar wallet, and payment transactions can be publicly verified through Stellar Expert.
View the wallet on Stellar Expert:
View the transaction on Stellar Expert:
| Module | Description |
|---|---|
| Authentication | User registration & login |
| Products | Marketplace product management |
| Orders | Buyer & farmer order workflow |
| Transactions | Payment history |
| Wallet | Stellar wallet management |
| Analytics | Dashboard statistics |
| Notifications | User notifications |
| Activity | Audit logs |
| Administration | Platform management |
TaniChain integrates directly with the Stellar Testnet using the Stellar SDK and Horizon API.
Current implementation includes:
- Automatic Stellar wallet creation
- Friendbot wallet funding
- Payment commitment recording
- Transaction verification
- Explorer transaction links
This project currently does not deploy a Soroban Smart Contract.
Instead, payment commitments are implemented through Stellar accounts and blockchain transaction verification.
Future releases will extend the payment workflow using Soroban Smart Contracts.
Additional project documentation is available inside the docs/ directory.
| Document | Description |
|---|---|
| API.md | REST API Reference |
| DEPLOYMENT.md | Production Deployment Guide |
| SECURITY.md | Security Review |
| PROGRESS.md | Development Progress |
Verify that all services are running correctly after deployment.
docker compose up --build -ddocker psExpected containers:
- tanichain-nginx
- tanichain-frontend
- tanichain-backend
- tanichain-postgres
curl https://tanichain.arvinlabs.tech/api/healthExpected response:
{
"success": true,
"message": "TaniChain API is healthy"
}Open:
https://tanichain.arvinlabs.tech/api/docs
Future improvements planned for TaniChain.
- Soroban Smart Contract Escrow
- Multi-Signature Wallet
- Stellar Mainnet Deployment
- Cross-border Payments
- Product Images
- Product Reviews
- Wishlist
- Shopping Cart
- Farmer Verification Badge
- QR Payment
- Automatic Escrow
- Partial Payments
- Payment History Export
- CI/CD Pipeline
- Kubernetes Deployment
- Redis Cache
- Prometheus Monitoring
- Grafana Dashboard
- Android Application
- iOS Application
- Push Notifications
Contributions are welcome!
-
Fork this repository
-
Create a new branch
git checkout -b feature/my-feature- Commit your changes
git commit -m "feat: add amazing feature"- Push your branch
git push origin feature/my-feature- Open a Pull Request
This project is released under the MIT License.
See the LICENSE file for more information.
This project would not have been possible without these amazing technologies and communities.
- Stellar Development Foundation
- Stellar SDK
- Horizon API
- Next.js
- Express.js
- PostgreSQL
- Prisma ORM
- Docker
- Nginx
- Tailwind CSS
- TypeScript
- Swagger OpenAPI
- Cloudflare
- Let's Encrypt
Track
Local Finance & Real World Access
Project
TaniChain
Core Idea
TaniChain leverages Stellar to create a transparent agricultural payment network where payment commitments are securely recorded on-chain, enabling trusted transactions, reducing payment disputes, and improving financial accessibility for farmers and buyers.
Arvin Farrel Pramuditya
Backend Engineer β’ Blockchain Developer β’ Open Source Contributor
GitHub https://github.com/ArvinFarrelP
LinkedIn https://linkedin.com/in/ArvinFarrelP
For questions, feedback, partnerships, or collaboration:
Email hello.tanichain@gmail.com
Project Repository https://github.com/ArvinFarrelP/tanichain










