A comprehensive blockchain-based land registry system built with React frontend, Ballerina microservices backend, Go blockchain service, and MySQL database.
This project consists of multiple interconnected services:
- Frontend: React + TypeScript + Vite application
- Backend: Ballerina microservices architecture
- Blockchain: Go-based blockchain service
- Proxy: Ballerina proxy service
- SLUDI Service: Separate Ballerina service for SLUDI verification
- Database: MySQL with Redis for caching
Before setting up the project, ensure you have the following installed:
- Node.js (v18 or higher)
- npm or yarn
- Ballerina (Distribution 2201.12.4 or higher)
- Go (v1.24.5 or higher)
- MySQL (v8.0 or higher)
- Redis server
- RabbitMQ server
- Docker and Docker Compose (optional, for containerized MySQL)
git clone https://github.com/iamvirul/land-chain.git
cd land-chaincd backend
docker-compose up -dThis will start MySQL on port 3000 with the following configuration:
- Host: localhost
- Port: 3000
- Database: land_chain
- Username: landchain_app
- Password: CONTAINER_MYSQL_PASSWORD
- Root Password: SYSTEM_MYSQL_PASSWORD
Install and start Redis server:
# On macOS
brew install redis
brew services start redis
# On Ubuntu/Debian
sudo apt-get install redis-server
sudo systemctl start redis-server
# On Windows
# Download and install Redis from https://redis.io/downloadHere's a similar setup guide for RabbitMQ:
Install and start RabbitMQ server:
# On macOS
brew install rabbitmq
brew services start rabbitmq
# On Ubuntu/Debian
sudo apt-get install rabbitmq-server
sudo systemctl start rabbitmq-server
# On Windows
# Download and install RabbitMQ from https://www.rabbitmq.com/download.html
# Make sure to install Erlang first (required dependency)Additional useful commands:
# Enable management plugin (for web UI)
rabbitmq-plugins enable rabbitmq_management
# Default credentials for web UI (after enabling management plugin):
# http://localhost:15672
# Username: guest
# Password: guest
# Create a new user
rabbitmqctl add_user username password
# Set user permissions
rabbitmqctl set_user_tags username administrator
rabbitmqctl set_permissions -p / username ".*" ".*" ".*"Note: RabbitMQ requires Erlang to be installed. The package managers (brew/apt) will typically handle this dependency automatically. For manual installations, you may need to install Erlang separately.
The frontend is configured to proxy API requests to different backend services:
server: {
proxy: {
"/api/auth": "http://localhost:9091/",
"/api/lands": "http://localhost:9085/",
"/api/legal_officer": "http://localhost:9080",
"/api/land_officer": "http://localhost:9070",
"/api/land_owner": "http://localhost:9098"
}
}[package]
org = "virulnirmala"
name = "backend"
version = "0.1.0"
distribution = "2201.12.4"
[build-options]
observabilityIncluded = true
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "persist.sql-native"
version = "1.6.0"Service Ports:
- Auth Service: 9091
- Land Service: 9085
- Legal Officer Service: 9080
- Land Officer Service: 9070
- Land Owner Service: 9098
[package]
org = "virulnirmala"
name = "proxy"
version = "0.1.0"
distribution = "2201.12.4"
[build-options]
observabilityIncluded = true[package]
org = "hiranyasemindi"
name = "sludi_service"
version = "0.1.0"
distribution = "2201.12.7"
[build-options]
observabilityIncluded = trueService Port: 9096
module landchain
go 1.24.5
require (
filippo.io/edwards25519 v1.1.0
github.com/go-sql-driver/mysql v1.9.3
github.com/joho/godotenv v1.5.1
)Service Port: 8080
Create backend/blockchain/.env:
API_KEY=API_KEY_FOR_BLOCKCHAIN_SERVICE
DB_DSN=root:MYSQL_PASSWORD@@@tcp(127.0.0.1:3000)/land_chain?parseTime=trueCreate sludi-service/Config.toml:
[SLUDIDatabase]
host = "localhost"
port = 3306
user = "MYSQL_USERNAME"
password = "MYSQL_PASSWORD"
database = "DB_NAME"Create backend/Config.toml:
[backend.db]
host = "127.0.0.1"
port = 3306
user = "USERNAME"
password = "PASSWORD"
database = "land_chain"
[backend]
blockchain_url = "http://localhost:8080/api/v1"
blockchain_api_key = "BLOCKCHAIN_API_KEY"
merchant_id = "1231449"
merchant_secret = "PAYHERE_SECRET"
sms_lenz_user_id = "SMS_LENZ_USER_ID"
sms_lenz_api_key = "SMS_LENZ_API_KEY"
sms_lenz_sender_id = "SMS_LENZ_SENDER_ID"
[backend.rabbitmq]
username = "guest"
password = "guest"
sms_lenz_user_id = "SMS_LENZ_USER_ID"
sms_lenz_api_key = "SMS_LENZ_API_KEY"
sms_lenz_sender_id = "SMS_LENZ_SENDER_ID"
[backend.gcs]
clientId = "CLIENT_ID"
clientSecret = "CLIENT_SECRET_HERE"
refreshToken = "REFREESH_TOKEN_HERE"
bucket = "BUCKET_NAME"
access_token = "ACCESS_TOKEN_HERE"| Step | Action |
|---|---|
| 1 | Open OAuth 2.0 Playground and click the gear icon (⚙️) |
| 2 | Check Use your own OAuth credentials and enter your Client ID and Client Secret |
| 3 | In Step 1, enter this scope: https://www.googleapis.com/auth/devstorage.read_write |
| 4 | Click Authorize APIs and complete the consent flow |
| 5 | Click Exchange authorization code for tokens, then copy the refresh token |
| 6 | Make sure your OAuth consent screen is set to Production in Google Cloud Console to avoid token expiry issues |
# Install dependencies
npm install
# Start development server
npm run devThe frontend will be available at: http://localhost:5173
cd backend
bal runThis starts multiple services on different ports:
- Auth Service: http://localhost:9091
- Land Service: http://localhost:9085
- Legal Officer Service: http://localhost:9080
- Land Officer Service: http://localhost:9070
- Land Owner Service: http://localhost:9098
cd proxy
bal runcd sludi-service
bal runService available at: http://localhost:9096
cd backend/blockchain
go mod tidy
go run main.goService available at: http://localhost:8080
The services must be started in the following order:
- Database (MySQL + Redis)
- SLUDI Service (Port 9096)
- Blockchain Service (Port 8080)
- Backend Services (Ports 9070, 9080, 9085, 9091, 9098)
- Proxy Service
- Frontend (Port 5173)
The database schema is automatically initialized from:
backend/modules/db/script.sql
Key tables include:
users- User authentication and profile datalands- Land registry informationlegal_officers- Legal officer detailsland_officers- Land officer detailsuser_types- User role definitionsusers_has_user_types- User role assignments
The project includes SSL certificate configuration in:
backend/resources/certificates/proxy/resources/certificates/
JWT tokens are used for authentication with:
- Service tokens for API access
- Socket tokens for WebSocket connections
- Redis-based session management
Use the provided HTTP files for testing:
backend/land_chain.http- Backend API endpointsbackend/blockchain/blockchain.http- Blockchain API endpoints
# Frontend tests
npm run lint
# Backend tests
cd backend
bal test
# Blockchain tests
cd backend/blockchain
go test ./...npm run buildcd backend
bal build
cd ../proxy
bal build
cd ../sludi-service
bal buildcd backend/blockchain
go build -o blockchain-service main.goThe project includes Docker configuration for MySQL:
cd backend
docker-compose up -dFor full containerization, create additional Dockerfiles for each service.
- Port Conflicts: Ensure all required ports are available
- Database Connection: Verify MySQL is running and credentials are correct
- Redis Connection: Ensure Redis server is running on localhost:6379
- SLUDI Service: Must be running before backend services start
- Environment Variables: Ensure all .env files are properly configured
- Frontend: http://localhost:5173
- Auth Service: http://localhost:9091/auth
- SLUDI Service: http://localhost:9096/sludi_service
- Blockchain Service: http://localhost:8080/api/v1/transfer
