# ronnie-ahmed/blockchain-based-real-estate-marketplace architecture

> Architecture diagram of the GitHub repository ronnie-ahmed/blockchain-based-real-estate-marketplace, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ronnie-ahmed/blockchain-based-real-estate-marketplace
- Repository: https://github.com/ronnie-ahmed/blockchain-based-real-estate-marketplace

## Overview

##### Project Type and Purpose
- BlockEstate is a full-stack decentralized application (“dApp”) that lets users list, buy, and sell real estate as ERC-721 NFTs on the Ethereum blockchain.
- Frontend: React.js + Tailwind CSS + HTML5
- Smart-contract backend: Solidity (ERC-721) via Hardhat + Ethers.js
- Off-chain asset storage: IPFS for property images and metadata

##### File Structure Analysis
- contracts/ – Solidity smart contracts
- scripts/deploy.js – Hardhat script to deploy contracts to a local or public network
- test/Lock.js – Mocha/Chai tests for contract behavior
- hardhat.config.js – Hardhat build & network configuration
- frontend/ – React application directory
- package.json & package-lock.json – Node dependencies
- .gitmodules – (if present) for submodule references

##### Architectural Patterns
- Three-tier architecture:
- Presentation layer (React + Ethers.js + MetaMask)
- Business logic on-chain (Solidity ERC-721 contracts)
- Off-chain storage (IPFS)
- Ethers.js acts as the API/communication layer between browser UI and Ethereum node.
- Hardhat local node simulates an Ethereum network for development & testing.

a. Users & Wallet
- Browser with React UI
- MetaMask (injected provider)
b. Frontend Layer
- React Components (ListProperty, BuyPage, MyListings)
- Ethers.js library
c. Blockchain Layer
- Ethereum Node (Hardhat local node or Infura/mainnet)
- Smart Contract (ERC-721 Lock or Property NFT)
d. Off-Chain Storage
- IPFS cluster for images/metadata
e. DevOps / Tooling
- Hardhat deployment scripts
- Test runner (Mocha/Chai)

##### Relationships & Data Flows
- User → React UI: fills property data or clicks Buy
- React UI → MetaMask prompt → User signs transaction
- MetaMask → Ethereum Node → Smart Contract
- Smart Contract ↔ IPFS: stores/returns token URI pointing to IPFS metadata
- Ethereum Node → React UI: returns transaction receipts & contract events
- Hardhat Script → Ethereum Node: deploys contract bytecode
- Test Suite → Smart Contract (via Hardhat) for unit testing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    User["User"]:::external
    Wallet["MetaMask"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        ReactUI["React UI"]:::frontend
        EthersJS["Ethers.js"]:::frontend
    end

    %% Blockchain Layer
    subgraph "Blockchain Layer"
        EthNode["Ethereum Node<br/>(Hardhat/Infura)"]:::blockchain
        Contract["ERC-721 Smart Contract"]:::blockchain
    end

    %% Off-Chain Storage
    IPFS["IPFS Storage"]:::ipfs

    %% DevOps & Tooling
    Deploy["Deploy Script"]:::tools
    HardhatConfig["hardhat.config.js"]:::tools
    TestSuite["Test Suite"]:::tools
    PackageDef["package.json"]:::tools

    %% Data Flows
    User -->|"interacts"| ReactUI
    ReactUI -->|"invokes"| EthersJS
    ReactUI -->|"requests signature"| Wallet
    Wallet -->|"JSON-RPC"| EthNode
    EthersJS -->|"JSON-RPC"| EthNode
    EthNode -->|"deploys & calls"| Contract
    Contract -->|"store/retrieve URI"| IPFS
    EthNode -->|"events & receipts"| ReactUI

    Deploy -->|"deploy bytecode"| EthNode
    Deploy -->|"reads config"| HardhatConfig
    Deploy -->|"deploys contracts in"| Contract

    TestSuite -->|"runs against"| EthNode
    TestSuite -->|"tests"| Contract

    PackageDef --> ReactUI
    PackageDef --> Deploy
    PackageDef --> TestSuite

    %% Click Events
    click ReactUI "https://github.com/ronnie-ahmed/blockchain-based-real-estate-marketplace/tree/main/frontend/"
    click Contract "https://github.com/ronnie-ahmed/blockchain-based-real-estate-marketplace/tree/main/contracts/"
    click Deploy "https://github.com/ronnie-ahmed/blockchain-based-real-estate-marketplace/blob/main/scripts/deploy.js"
    click HardhatConfig "https://github.com/ronnie-ahmed/blockchain-based-real-estate-marketplace/blob/main/hardhat.config.js"
    click TestSuite "https://github.com/ronnie-ahmed/blockchain-based-real-estate-marketplace/blob/main/test/Lock.js"
    click PackageDef "https://github.com/ronnie-ahmed/blockchain-based-real-estate-marketplace/blob/main/package.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0099FF,stroke-width:2px;
    classDef blockchain fill:#FFE5CC,stroke:#FF8000,stroke-width:2px,shape:hexagon;
    classDef ipfs fill:#E6FFE6,stroke:#33CC33,stroke-width:2px,shape:cylinder;
    classDef external fill:none,stroke:#999,stroke-dasharray:5 5;
    classDef tools fill:#F2F2F2,stroke:#666,stroke-width:1px,shape:ellipse;
```
