Skip to content

Latest commit

Β 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TaniChain Logo

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.


Next.js Express TypeScript PostgreSQL Docker Nginx AWS EC2 Cloudflare HTTPS Stellar License Stars Forks Issues


🌐 Live Demo

Website

API Documentation

GitHub Repository


πŸ“– Overview

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.


✨ Key Features

  • 🌱 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

πŸ›  Tech Stack

Frontend

  • Next.js 15
  • React
  • TypeScript
  • Tailwind CSS
  • Axios

Backend

  • Express.js
  • TypeScript
  • Prisma ORM
  • JWT Authentication
  • Swagger OpenAPI
  • Helmet
  • Rate Limiter

Database

  • PostgreSQL 16

Blockchain

  • Stellar SDK
  • Stellar Testnet
  • Horizon API

Infrastructure

  • Docker
  • Docker Compose
  • Nginx Reverse Proxy
  • Let's Encrypt SSL
  • Cloudflare DNS & CDN
  • Ubuntu Server

πŸ“‚ Project Structure

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

πŸ— System Architecture

                              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


🌍 Production Deployment

                           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

πŸ”„ Application Flow

                         Buyer / Farmer
                               β”‚
                               β–Ό
                      Frontend (Next.js)
                               β”‚
                       REST API Request
                               β”‚
                               β–Ό
                      Express.js Backend
                               β”‚
                      JWT Authentication
                               β”‚
                         Business Logic
                               β”‚
                           Prisma ORM
                               β”‚
                               β–Ό
                           PostgreSQL
                               β”‚
                               β–Ό
                            Response
                               β”‚
                               β–Ό
                     Frontend UI Update

β›“ Blockchain Payment Flow

                             Buyer
                               β”‚
                        Creates Order
                               β”‚
                               β–Ό
                    Payment Commitment
                               β”‚
                               β–Ό
                     Backend Validation
                               β”‚
                               β–Ό
                 Record Metadata to
                    Stellar Testnet
                               β”‚
                               β–Ό
               Transaction Hash Stored
                      in Database
                               β”‚
                               β–Ό
                   Farmer Verification
                               β”‚
                               β–Ό
                     Payment Released

🐳 Docker Architecture

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

πŸ” Security Features

TaniChain is designed with security-first principles and includes multiple layers of protection.

Authentication

  • JWT Authentication
  • Secure password hashing
  • Role-Based Access Control (RBAC)
  • Protected API endpoints

API Security

  • Helmet Security Headers
  • Rate Limiting
  • Input Validation
  • Centralized Error Handling
  • CORS Protection

Infrastructure Security

  • HTTPS via Let's Encrypt
  • Cloudflare DNS & CDN
  • Nginx Reverse Proxy
  • Secure Docker Network
  • Environment Variable Management

πŸš€ Getting Started

Prerequisites

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)

πŸ“₯ Clone Repository

git clone https://github.com/ArvinFarrelP/tanichain.git

cd tanichain

βš™ Environment Variables

Copy the example environment file.

cp .env.example .env

Edit 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/api

🐳 Docker Deployment (Recommended)

Build every container.

docker compose build

Run all services.

docker compose up -d

Check running containers.

docker ps

Expected containers:

tanichain-nginx
tanichain-frontend
tanichain-backend
tanichain-postgres

πŸ“Š Check Container Health

docker ps

Expected output:

STATUS

tanichain-nginx        healthy
tanichain-frontend     healthy
tanichain-backend      healthy
tanichain-postgres     healthy

πŸ§ͺ Health Check API

Backend Health Endpoint

curl https://tanichain.arvinlabs.tech/api/health

Response

{
  "success": true,
  "message": "TaniChain API is healthy"
}

🌐 Production Deployment

TaniChain is deployed using Docker Compose on Ubuntu Server with Nginx Reverse Proxy and HTTPS.

Production URLs

Website

https://tanichain.arvinlabs.tech

Swagger Documentation

https://tanichain.arvinlabs.tech/api/docs

API Endpoint

https://tanichain.arvinlabs.tech/api

πŸ”’ HTTPS Configuration

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

πŸ’» Local Development

Backend

cd backend

npm install

npx prisma generate

npx prisma migrate dev

npm run dev

Backend runs on

http://localhost:4000

Frontend

cd frontend

npm install

npm run dev

Frontend runs on

http://localhost:3000

πŸ“– API Documentation

Swagger UI

Production

https://tanichain.arvinlabs.tech/api/docs

Development

http://localhost:4000/api/docs

OpenAPI JSON

http://localhost:4000/api/docs.json

πŸ›  Useful Docker Commands

Build images

docker compose build

Start containers

docker compose up -d

Stop containers

docker compose down

Restart

docker compose restart

View logs

docker compose logs -f

Check running containers

docker ps

Open backend shell

docker compose exec backend sh

Open PostgreSQL

docker compose exec postgres psql -U tanichain

πŸš€ Detailed Features

πŸ‘₯ Multi-Role Authentication

TaniChain 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

🌱 Marketplace

Farmers can publish agricultural products while buyers can browse available commodities in real time.

Farmer Features

  • Create Products
  • Update Products
  • Archive Products
  • Inventory Management
  • Product Categories
  • Stock Management

Buyer Features

  • Browse Marketplace
  • Product Detail
  • Search Products
  • Category Filtering
  • Pagination
  • Purchase Products

πŸ’³ Payment Commitment Workflow

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

⛓️ Blockchain Integration

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

πŸ’Ό Wallet Management

Each user owns a blockchain wallet.

Features include:

  • Wallet Address
  • Current Balance
  • QR Code Generation
  • Transaction History
  • Payment QR
  • Blockchain Explorer Link

πŸ“¦ Order Management

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

πŸ“‘ PDF 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

πŸ“€ CSV Export

Users can export data into CSV format.

Supported exports:

  • Transactions
  • Products
  • Orders

Administrator exports:

  • Users
  • Products
  • Orders
  • Transactions

πŸ“Š Analytics Dashboard

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

πŸ‘‘ Administrator Features

Administrators have complete visibility over the platform.

Features include:

  • User Management
  • Product Management
  • Order Management
  • Transaction Management
  • Wallet Monitoring
  • Activity Logs
  • Platform Analytics

πŸ”” Notification System

Real-time notifications are generated for important events.

Notifications include:

  • New Order
  • Payment Committed
  • Payment Released
  • Delivery Confirmation
  • Transaction Updates

πŸ“œ Activity Logs

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.


⭐ Project Highlights

βœ” 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


πŸ“Έ Screenshots

Below are screenshots of the current TaniChain application.

🌐 Landing Page

Landing Page


πŸ›’ Marketplace

Marketplace


πŸ“Š User Dashboard

User Dashboard


πŸ’° Payment Commitment

Payment Commitment


🌌 Stellar Testnet Explorer

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.

Wallet Explorer

Stellar Testnet Wallet

View the wallet on Stellar Expert:

https://stellar.expert/explorer/testnet/account/GD7ID4IKVS3ZYCBYMDZ2VWAB7YAINYF3BAIRGVUBEQX2Q4TBG535YVOV


Transaction History

Stellar Transaction History


Sample Transaction

Stellar Transaction Details

View the transaction on Stellar Expert:

https://stellar.expert/explorer/testnet/tx/8df5a31782b1b3c244048519cb7aaa22faa1f6a6b3f348e5376ca3f349ad7e77


πŸ“– Swagger API Documentation

Swagger Overview


Authentication Endpoints


Marketplace Endpoints


Admin Endpoints


πŸ“š API Overview

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

⛓️ Stellar Integration

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.


πŸ“‚ Documentation

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

πŸ§ͺ Testing

Verify that all services are running correctly after deployment.

Start the Application

docker compose up --build -d

Check Running Containers

docker ps

Expected containers:

  • tanichain-nginx
  • tanichain-frontend
  • tanichain-backend
  • tanichain-postgres

Health Check

curl https://tanichain.arvinlabs.tech/api/health

Expected response:

{
  "success": true,
  "message": "TaniChain API is healthy"
}

Swagger Documentation

Open:

https://tanichain.arvinlabs.tech/api/docs

πŸ›£οΈ Roadmap

Future improvements planned for TaniChain.

Blockchain

  • Soroban Smart Contract Escrow
  • Multi-Signature Wallet
  • Stellar Mainnet Deployment
  • Cross-border Payments

Marketplace

  • Product Images
  • Product Reviews
  • Wishlist
  • Shopping Cart
  • Farmer Verification Badge

Payments

  • QR Payment
  • Automatic Escrow
  • Partial Payments
  • Payment History Export

Infrastructure

  • CI/CD Pipeline
  • Kubernetes Deployment
  • Redis Cache
  • Prometheus Monitoring
  • Grafana Dashboard

Mobile

  • Android Application
  • iOS Application
  • Push Notifications

🀝 Contributing

Contributions are welcome!

  1. Fork this repository

  2. Create a new branch

git checkout -b feature/my-feature
  1. Commit your changes
git commit -m "feat: add amazing feature"
  1. Push your branch
git push origin feature/my-feature
  1. Open a Pull Request

πŸ“„ License

This project is released under the MIT License.

See the LICENSE file for more information.


πŸ™ Acknowledgements

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

πŸ† APAC Stellar Hackathon 2026

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.


πŸ‘¨β€πŸ’» Author

Arvin Farrel Pramuditya

Backend Engineer β€’ Blockchain Developer β€’ Open Source Contributor

GitHub https://github.com/ArvinFarrelP

LinkedIn https://linkedin.com/in/ArvinFarrelP


πŸ“¬ Project Contact

For questions, feedback, partnerships, or collaboration:

Email hello.tanichain@gmail.com

Project Repository https://github.com/ArvinFarrelP/tanichain


🌾 TaniChain

Transparent Agricultural Payment Network powered by Stellar

Built with ❀️ using

Next.js β€’ Express.js β€’ PostgreSQL β€’ Docker β€’ Nginx β€’ Stellar Testnet

⭐ If you found this project interesting, consider giving it a star!

Releases

Packages

Contributors

Languages