# bhanuprasadchesetti/land-registration-system-with-blockchain architecture

> Architecture diagram of the GitHub repository bhanuprasadchesetti/land-registration-system-with-blockchain, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhanuprasadchesetti/land-registration-system-with-blockchain
- Repository: https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain

## Overview

##### Project type and purpose
- This is a full-stack decentralized application (DApp) for land registration and transfer, combining:
- Two Flask-based web servers (one for government/revenue officers, one for end-users)
- A suite of Solidity smart contracts deployed on an Ethereum test network (Ganache)
- A MongoDB database for off-chain storage of user and document metadata
- Front-end UI assets (HTML/CSS/JS) served by Flask and Web3.js/MetaMask for transaction signing

##### File structure
- Top-level directories:
- Server_For_Revenue_Dept – Flask app for government officers
- Server_For_Users – Flask app for public users
- Smart_contracts – Truffle project containing Solidity contracts, migrations and build artifacts
- python_package_requirements.txt – Python dependencies
- Server_For_Revenue_Dept:
- app.py – main Flask entry point for the revenue portal
- config.json – runtime configuration (Ganache RPC URL, MongoDB URL, secret keys)
- /static + /templates – MVC web layers (HTML templates + CSS/JS)
- /utility – Python helper modules for mapping revenue data
- Server_For_Users:
- app.py – main Flask entry point for user portal
- /web/static + /web/templates – user-facing UI assets
- Property_Docs – folder to hold uploaded PDF proofs
- Smart_contracts:
- contracts/ – Solidity files defining LandRegistry, Property, TransferOwnership, Users
- migrations/ – deployment scripts
- build/contracts – compiled contract JSON (ABI + bytecode)
- truffle-config.js – specifies Ganache network for migrations

##### README for additional insights
- Two main workflows:
A. Decentralizing land registry data via user upload, government verification, then on-chain storage
B. Ownership transfer via listing, offer, payment in Ether, and on-chain transfer
- Tech stack: Flask, MongoDB, Solidity, Truffle, Ganache, MetaMask
- No complex microservices—just two monolithic Flask apps plus a blockchain network

a. Main components
1. User Browser + MetaMask extension
2. User Portal (Flask server)
3. Revenue Portal (Flask server)
4. Ethereum Test Network (Ganache) hosting Smart Contracts
5. MongoDB database
6. File storage for property documents (on-disk in Server_For_Users/Property_Docs)
b. Relationships and data flows
- Browser ↔ User Portal: HTTP(S) requests for page rendering, Web3.js calls for read/write operations
- Browser ↔ Ganache/Ethereum: direct RPC calls via MetaMask for transaction signing (add land, buy/sell)
- User Portal ↔ MongoDB: store user profiles, property metadata, purchase requests
- User Portal ↔ Ganache/Ethereum: JSON-RPC calls via Web3.py to deploy/read/write contracts
- Revenue Portal ↔ MongoDB: store verification status, admin logs
- Revenue Portal ↔ Ganache/Ethereum: call `grantOwnership` or `rejectOwnership` contract functions
- Smart Contracts ↔ Ethereum Ledger: on-chain state for property ownership, transfers
c. Architectural patterns and principles
- MVC pattern in both Flask apps (templates, static assets, controllers in app.py)
- Dual-portal separation of concerns (administration vs. public user flows)
- On-chain/off-chain hybrid: critical ownership logic resides on blockchain, bulky docs and metadata off-chain
- Event-driven updates (optional): Flask servers could listen for contract events to update MongoDB
d. Key technologies
- Python Flask (app servers)
- Web3.py / Web3.js (blockchain interaction)
- MongoDB (NoSQL database)
- Solidity + Truffle (smart contract development and migration)
- Ganache (local Ethereum blockchain)
- MetaMask (user wallet for transaction signing)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interaction
    Browser["User Browser + MetaMask"]:::frontend

    %% User Portal
    subgraph "User Portal (Flask)"
        UP_app["app.py"]:::backend
        UP_templates["UI templates"]:::frontend
        UP_static["Static assets"]:::frontend
        UP_storage["Property_Docs"]:::storage
    end

    %% Revenue Portal
    subgraph "Revenue Portal (Flask)"
        RP_app["app.py"]:::backend
        RP_config["config.json"]:::backend
        RP_utility["mapRevenueDeptToEmployee.py"]:::backend
        RP_templates["UI templates"]:::frontend
        RP_static["Static assets"]:::frontend
    end

    %% On-Chain Layer
    subgraph "On-Chain Layer"
        SC_contracts["Solidity contracts"]:::blockchain
        SC_build["Compiled ABIs"]:::blockchain
        SC_migrations["Migrations scripts"]:::blockchain
        SC_config["truffle-config.js"]:::blockchain
        Ganache["Ethereum Test Network (Ganache)"]:::blockchain
    end

    %% Storage
    MongoDB["MongoDB Database"]:::storage

    %% Dependencies
    Requirements["python_package_requirements.txt"]:::backend

    %% Connections
    Browser -->|"HTTP(S)"| UP_app
    Browser -->|"Web3.js RPC via MetaMask"| Ganache

    UP_app -->|"serves pages"| UP_templates
    UP_app -->|"serves assets"| UP_static
    UP_app -->|"access file storage"| UP_storage
    UP_app -->|"reads/writes"| MongoDB
    UP_app -->|"Web3.py JSON-RPC"| Ganache

    Browser -->|"HTTP(S)"| RP_app
    RP_app -->|"serves pages"| RP_templates
    RP_app -->|"serves assets"| RP_static
    RP_app -->|"uses helper"| RP_utility
    RP_app -->|"reads/writes"| MongoDB
    RP_app -->|"Web3.py JSON-RPC"| Ganache

    SC_migrations -->|"deploy via"| Ganache
    Ganache -->|"deploys & executes"| SC_contracts
    SC_build -->|"used by"| UP_app
    SC_build -->|"used by"| RP_app

    %% Click Events
    click UP_app "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/blob/main/Server_For_Users/app.py"
    click UP_templates "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Server_For_Users/web/templates"
    click UP_static "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Server_For_Users/web/static"
    click UP_storage "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Server_For_Users/Property_Docs"
    click RP_app "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/blob/main/Server_For_Revenue_Dept/app.py"
    click RP_config "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/blob/main/Server_For_Revenue_Dept/config.json"
    click RP_utility "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/blob/main/Server_For_Revenue_Dept/utility/mapRevenueDeptToEmployee.py"
    click RP_templates "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Server_For_Revenue_Dept/templates"
    click RP_static "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Server_For_Revenue_Dept/static"
    click SC_contracts "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Smart_contracts/contracts"
    click SC_build "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Smart_contracts/build/contracts"
    click SC_migrations "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/tree/main/Smart_contracts/migrations"
    click SC_config "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/blob/main/Smart_contracts/truffle-config.js"
    click Requirements "https://github.com/bhanuprasadchesetti/land-registration-system-with-blockchain/blob/main/python_package_requirements.txt"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#0366D6,color:#0366D6
    classDef backend fill:#D4F5D4,stroke:#2F8F2F,color:#2F8F2F
    classDef blockchain fill:#FFE5B4,stroke:#E69500,color:#E69500
    classDef storage fill:#E0E0E0,stroke:#6E6E6E,color:#6E6E6E
```
