Skip to content

Mansi2007275/land-registry-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

??? BhoomiChain - Blockchain Registry & Legal Agreement System

A production-grade blockchain-backed registry system for immutable property records, legal agreements, and court-admissible evidence generation with comprehensive spatial integrity and institutional compliance.

License: MIT Python 3.9+ FastAPI React Ethereum


?? System Overview & Research Impact

BhoomiChain represents a groundbreaking advancement in property registry technology, combining blockchain immutability with legal compliance to create the world's first court-admissible, cryptographically verifiable property management system. Our research addresses critical challenges in property law, spatial data integrity, and institutional transparency.

?? Research Contributions

  • Blockchain-Legal Integration: First system to achieve mathematical certainty in property records with court-admissible evidence generation
  • Spatial Conservation Enforcement: Novel =99% area conservation algorithms ensuring geometric integrity across property subdivisions
  • Vertical Property Hierarchy: Deterministic ownership resolution for complex land?building?flat relationships
  • Fraud Detection Primitives: Machine learning-based anomaly detection for suspicious property activities
  • Institutional Archival: End-of-system guarantees with offline-verifiable data structures for perpetual legal compliance

?? System Correctness & Guarantees

  • Mathematical Certainty: Deterministic canonical hashing with keccak256 ensures identical results across all platforms
  • Cryptographic Integrity: Merkle tree anchoring provides tamper-evident proof of all property records
  • Legal Admissibility: Court-grade affidavits with embedded QR verification meet international legal standards
  • Spatial Accuracy: GIS-validated geometry with coordinate precision monitoring and drift detection
  • Audit Defense: Comprehensive failure categorization with explicit remediation guidance for regulatory compliance

??? Architecture & Technology Stack

Backend Technologies

Core Framework

  • FastAPI 0.104.1: High-performance async web framework with automatic API documentation
  • Python 3.9+: Primary backend language with type safety and modern async support
  • SQLAlchemy: Advanced ORM with connection pooling and hierarchical data support
  • PostgreSQL: Primary database with spatial extensions and JSONB support
  • Alembic: Database migration management with version control

Blockchain Integration

  • Web3.py: Production-grade Ethereum client with retry mechanisms and connection pooling
  • Hardhat: Ethereum development environment with comprehensive testing framework
  • Solidity 0.8+: Smart contract language with OpenZeppelin security libraries
  • IPFS: Distributed content addressing with ipfshttpclient integration

Cryptographic & Security

  • cryptography: Advanced ECDSA signatures and cryptographic operations
  • PyJWT: JSON Web Token implementation with secure authentication
  • bcrypt: Password hashing with salt for credential security
  • merkletools: Merkle tree construction and inclusion proof generation

Geospatial & Analytics

  • Shapely: Geometric operations and spatial analysis with precision validation
  • GeoPandas: Advanced geospatial data analysis and coordinate transformations
  • Folium: Interactive map generation and spatial visualization
  • scikit-learn: Machine learning for fraud detection and pattern analysis

Legal & Compliance

  • ReportLab: Professional PDF generation for court-grade affidavits
  • QRCode: Verification payload encoding for offline validation
  • Jinja2: Legal document template rendering with jurisdiction support

Frontend Technologies

  • React 18+: Modern UI framework with TypeScript integration
  • TypeScript: Type-safe JavaScript with comprehensive error checking
  • Web3.js/Ethers.js: Blockchain interaction with wallet integration
  • Leaflet/MapBox: Interactive spatial mapping and property visualization

Smart Contract Infrastructure

  • RegistryResolver: Core property registry with immutable record management
  • AgreementLedger: Comprehensive legal agreement lifecycle management
  • MerkleAnchor: Cryptographic proof anchoring with blockchain verification

?? API Endpoints & System Capabilities

Core Registry Operations (150+ Endpoints)

Property Management

POST   /registry/create                    # Create new property record
GET    /registry/list                      # List all property records
POST   /registry/transfer                  # Transfer property ownership
GET    /registry/verify/{record_hash}      # Verify property record
POST   /registry/subdivide                 # Create property subdivision

Agreement Management

POST   /agreements                         # Create legal agreement
GET    /agreements/{agreement_hash}        # Get agreement details
POST   /agreements/{id}/activate           # Activate pending agreement
POST   /agreements/{id}/terminate          # Terminate active agreement
GET    /agreements/by-subject/{hash}       # Get subject agreements

Vertical Property Hierarchy

POST   /properties/land                    # Register land parcel
POST   /properties/building                # Register building under land
POST   /properties/flat                    # Register flat under building
GET    /properties/{hash}/hierarchy        # Get complete hierarchy
GET    /flats/{hash}/agreements            # Get flat-specific agreements

Court Evidence & Verification

POST   /court/evidence/bundle/{hash}       # Generate court evidence bundle
GET    /court/judicial/verify/{hash}       # Judicial-grade verification
POST   /court/independent/package/{hash}   # Registry-independent evidence
GET    /verify/merkle/{hash}               # Merkle inclusion verification
POST   /fraud-detection/analyze/{hash}     # Comprehensive fraud analysis

Public Explorer & Transparency

GET    /explorer/entities                  # Public entity discovery
GET    /explorer/search                    # Advanced property search
GET    /explorer/geographic/bounds         # Spatial property queries
GET    /explorer/agreements/active         # Public agreement visibility
GET    /explorer/analytics/summary         # Registry analytics

GIS & Spatial Analytics

GET    /gis/audit/{hash}                   # Complete GIS audit report
POST   /gis/validate                       # Validate geometry before creation
GET    /gis/heatmap/ownership              # Ownership distribution heatmap
GET    /gis/conservation/{parent_hash}     # Area conservation verification
POST   /spatial/drift-detection            # Geometric drift monitoring

Archival & Institutional Compliance

POST   /archival/institutional/freeze      # Prepare institutional freeze
GET    /archival/merkle/final-structure    # Generate final Merkle structure
POST   /archival/offline/package/{hash}    # Create offline-verifiable package
GET    /archival/end-of-system/certificate # Get archival guarantees

??? Local Development Setup

Prerequisites

  • Node.js 18+ with Bun package manager
  • Python 3.9+ with pip
  • PostgreSQL 14+ with PostGIS extension
  • Git for version control
  • Docker (optional, for containerized deployment)

Backend Setup

  1. Clone Repository & Navigate

    git clone https://github.com/your-org/title-vault.git
    cd title-vault/backend
  2. Create Virtual Environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Dependencies

    pip install -r requirements.txt
  4. Environment Configuration Create backend/.env file:

    # Database Configuration
    DATABASE_URL=postgresql://username:password@localhost:5432/BhoomiChain
    
    # Blockchain Configuration
    WEB3_PROVIDER_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY
    PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
    REGISTRY_CONTRACT_ADDRESS=0x742d35Cc6634C0532925a3b8D4C2C4e4C4C4C4C4
    AGREEMENT_CONTRACT_ADDRESS=0x8ba1f109551bD432803012645Hac136c5C1234567
    
    # IPFS Configuration
    IPFS_API_URL=http://localhost:5001
    IPFS_GATEWAY_URL=http://localhost:8080
    
    # Authentication & Security
    JWT_SECRET_KEY=your-super-secret-jwt-key-here-min-32-chars
    JWT_ALGORITHM=HS256
    JWT_ACCESS_TOKEN_EXPIRE_MINUTES=60
    JWT_REFRESH_TOKEN_EXPIRE_DAYS=7
    
    # Rate Limiting
    RATE_LIMIT_ENABLED=true
    REDIS_URL=redis://localhost:6379/0
    
    # GIS & Spatial
    SPATIAL_REFERENCE_SYSTEM=EPSG:4326
    AREA_CONSERVATION_THRESHOLD=0.99
    
    # Legal & Compliance
    DEFAULT_JURISDICTION=INDIA
    REGISTRAR_PRIVATE_KEY=0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
  5. Database Setup

    # Create database
    createdb BhoomiChain
    
    # Run migrations
    alembic upgrade head
    
    # Create test users
    python create_test_users.py
  6. Start Backend Server

    uvicorn app:app --reload --host 0.0.0.0 --port 8000

Frontend Setup

  1. Navigate to Frontend

    cd ../frontend
  2. Install Dependencies

    bun install
  3. Environment Configuration Create frontend/.env file:

    # API Configuration
    VITE_API_BASE_URL=http://localhost:8000
    VITE_WS_URL=ws://localhost:8000/ws
    
    # Blockchain Configuration
    VITE_CHAIN_ID=11155111
    VITE_CHAIN_NAME=Sepolia
    VITE_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY
    VITE_BLOCK_EXPLORER=https://sepolia.etherscan.io
    
    # Contract Addresses
    VITE_REGISTRY_CONTRACT=0x742d35Cc6634C0532925a3b8D4C2C4e4C4C4C4C4
    VITE_AGREEMENT_CONTRACT=0x8ba1f109551bD432803012645Hac136c5C1234567
    
    # Map Configuration
    VITE_MAPBOX_TOKEN=pk.eyJ1IjoieW91ci1tYXBib3gtdXNlcm5hbWUiLCJhIjoiY2xrNXM4...
    VITE_DEFAULT_MAP_CENTER_LAT=40.7128
    VITE_DEFAULT_MAP_CENTER_LNG=-74.0060
    VITE_DEFAULT_MAP_ZOOM=10
    
    # Feature Flags
    VITE_ENABLE_SPATIAL_FEATURES=true
    VITE_ENABLE_COURT_FEATURES=true
    VITE_ENABLE_FRAUD_DETECTION=true
  4. Start Frontend Development Server

    bun dev

Hardhat Smart Contract Setup

  1. Navigate to Hardhat Directory

    cd ../hardhat
  2. Install Dependencies

    npm install
  3. Environment Configuration Create hardhat/.env file:

    # Network Configuration
    SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY
    MAINNET_RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_KEY
    
    # Deployment Keys
    DEPLOYER_PRIVATE_KEY=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
    REGISTRAR_PRIVATE_KEY=0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
    
    # Etherscan Verification
    ETHERSCAN_API_KEY=ABC123DEF456GHI789JKL012MNO345PQR678STU
    
    # Gas Configuration
    GAS_PRICE_GWEI=20
    GAS_LIMIT=8000000
    
    # Contract Configuration
    INITIAL_REGISTRAR=0x742d35Cc6634C0532925a3b8D4C2C4e4C4C4C4C4
    MERKLE_ANCHOR_INTERVAL=3600
  4. Compile Contracts

    npx hardhat compile
  5. Deploy to Local Network

    npx hardhat node  # In separate terminal
    npx hardhat run scripts/deploy.js --network localhost
  6. Deploy to Sepolia Testnet

    npx hardhat run scripts/deploy.js --network sepolia
    npx hardhat verify --network sepolia DEPLOYED_CONTRACT_ADDRESS

?? Testing & Quality Assurance

Backend Testing

cd backend
pytest tests/ -v --cov=. --cov-report=html
python -m pytest tests/test_auth.py -v
python -m pytest tests/test_registry.py -v
python -m pytest tests/test_agreements.py -v

Frontend Testing

cd frontend
bun test
bun test:e2e
bun test:coverage

Smart Contract Testing

cd hardhat
npx hardhat test
npx hardhat test --grep "Registry"
npx hardhat coverage

Integration Testing

# Start all services
docker-compose up -d

# Run integration tests
cd backend
python -m pytest tests/integration/ -v

# Load testing
cd tests/load
python load_test.py

?? Production Deployment

Docker Deployment

# Build and start all services
docker-compose -f docker-compose.prod.yml up -d

# Scale backend services
docker-compose -f docker-compose.prod.yml up -d --scale backend=3

# Monitor logs
docker-compose logs -f backend frontend

Kubernetes Deployment

# Apply configurations
kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/secrets.yaml
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/ingress.yaml

# Monitor deployment
kubectl get pods -n BhoomiChain
kubectl logs -f deployment/BhoomiChain-backend -n BhoomiChain

Environment Variables for Production

Backend Production Environment

# Production Database
DATABASE_URL=postgresql://prod_user:secure_password@db.example.com:5432/BhoomiChain_prod

# Production Blockchain
WEB3_PROVIDER_URL=https://mainnet.infura.io/v3/YOUR_PRODUCTION_INFURA_KEY
REGISTRY_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890

# Security
JWT_SECRET_KEY=your-production-jwt-secret-key-minimum-32-characters-long
CORS_ORIGINS=["https://app.BhoomiChain.com","https://admin.BhoomiChain.com"]

# Performance
REDIS_URL=redis://prod-redis.example.com:6379/0
DATABASE_POOL_SIZE=20
DATABASE_MAX_OVERFLOW=30

# Monitoring
SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id
LOG_LEVEL=INFO
METRICS_ENABLED=true

Frontend Production Environment

VITE_API_BASE_URL=https://api.BhoomiChain.com
VITE_CHAIN_ID=1
VITE_RPC_URL=https://mainnet.infura.io/v3/YOUR_PRODUCTION_INFURA_KEY
VITE_REGISTRY_CONTRACT=0x1234567890123456789012345678901234567890

?? System Monitoring & Analytics

Health Checks

  • Backend: GET /health - System health and database connectivity
  • Blockchain: GET /blockchain/status - Web3 connection and contract status
  • IPFS: GET /ipfs/status - IPFS node connectivity and storage status

Metrics & Monitoring

  • Prometheus: Metrics collection for performance monitoring
  • Grafana: Operational dashboards and alerting
  • Sentry: Error tracking and performance monitoring
  • ELK Stack: Centralized logging and log analysis

Performance Benchmarks

  • API Response Time: <200ms for 95th percentile
  • Blockchain Sync: <5 second lag from chain events
  • Spatial Queries: <500ms for complex geometric operations
  • PDF Generation: <2 seconds for court-grade affidavits

?? Security & Compliance

Authentication & Authorization

  • JWT Tokens: 60-minute access tokens with 7-day refresh tokens
  • Role-Based Access: Admin, user, and registrar role hierarchies
  • Rate Limiting: 10 login attempts/minute, 100 API calls/hour
  • Password Security: bcrypt hashing with salt

Blockchain Security

  • Private Key Management: Hardware Security Module (HSM) integration
  • Multi-Signature: Critical operations require multiple signatures
  • Gas Optimization: Efficient contract interactions with gas estimation
  • Reentrancy Protection: SafeMath and checks-effects-interactions pattern

Data Protection

  • Encryption at Rest: AES-256 encryption for sensitive data
  • Encryption in Transit: TLS 1.3 for all API communications
  • GDPR Compliance: Data anonymization and right-to-deletion support
  • Audit Trails: Comprehensive logging of all system interactions

?? Documentation & Support

API Documentation

  • Interactive Docs: Available at /docs (Swagger UI)
  • ReDoc: Available at /redoc (Alternative API documentation)
  • OpenAPI Spec: Machine-readable API specification

Legal Documentation

  • Court Admissibility Guide: Legal standards and evidence requirements
  • Jurisdiction Compliance: Multi-jurisdictional legal framework support
  • Expert Witness Support: Technical documentation for legal proceedings

Developer Resources

  • SDK Documentation: Python and JavaScript SDK usage guides
  • Integration Examples: Sample code for common integration patterns
  • Troubleshooting Guide: Common issues and resolution procedures

?? Contributing & Development

Code Standards

  • Python: PEP 8 compliance with Black formatting
  • TypeScript: ESLint and Prettier for consistent code style
  • Solidity: Solhint for smart contract best practices
  • Testing: Minimum 90% code coverage requirement

Development Workflow

  1. Fork repository and create feature branch
  2. Implement changes with comprehensive tests
  3. Run full test suite and linting
  4. Submit pull request with detailed description
  5. Code review and automated testing
  6. Merge after approval and CI/CD validation

Issue Reporting

  • Bug Reports: Use GitHub issues with reproduction steps
  • Feature Requests: Detailed use cases and acceptance criteria
  • Security Issues: Private disclosure via security@BhoomiChain.com

?? Roadmap & Future Development

Phase 16: Complete Frontend Application (Current)

  • React application with TypeScript and modern hooks
  • Blockchain-integrated UI with Web3 wallet support
  • Interactive spatial mapping and property visualization
  • Real-time activity monitoring and notifications

Phase 17: Mobile Application

  • React Native mobile app for iOS and Android
  • Offline verification capabilities
  • Mobile-optimized property management
  • Push notifications for agreement updates

Phase 18: Enterprise Integration

  • REST API SDK for enterprise systems
  • Bulk import/export capabilities
  • Custom branding and white-label solutions
  • Enterprise SSO integration

Phase 19: Advanced Analytics

  • Machine learning fraud detection
  • Predictive property valuation
  • Market trend analysis
  • Regulatory compliance automation

?? License & Legal

This project is licensed under the MIT License - see the LICENSE file for details.

Legal Disclaimers

  • This software is provided for educational and research purposes
  • Users are responsible for compliance with local property laws
  • Legal advice should be sought for production deployments
  • Blockchain transactions are irreversible - use with caution

Patent & Intellectual Property

  • Novel algorithms and methods may be subject to patent protection
  • Open source license does not grant patent rights
  • Commercial use may require additional licensing agreements

?? Acknowledgments

Special thanks to:

  • Ethereum Foundation for blockchain infrastructure
  • OpenZeppelin for security-audited smart contract libraries
  • FastAPI community for excellent web framework
  • React team for modern frontend development tools
  • PostGIS for advanced spatial database capabilities

demo project url - https://youtu.be/mbiOKDtx69s

?? Made with Love by Team Zodiac Z408

?? Do more of what you love! ??

Building the future of property management, one block at a time.

  

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors