# s4n1dhy4/defi-based-emi-collection-system architecture

> Architecture diagram of the GitHub repository s4n1dhy4/defi-based-emi-collection-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/s4n1dhy4/defi-based-emi-collection-system
- Repository: https://github.com/s4n1dhy4/defi-based-emi-collection-system

## Overview

This is a browser-based DeFi EMI lending application: borrowers submit loan proposals with due dates and mortgage details, lenders review proposals and accept terms, and borrowers receive loans and repay them. The frontend uses Web3 and a connected wallet to interact with the lending contract; proposal details can display mortgage documents through an IPFS gateway. The README describes these capabilities, while the sampled frontend files show several contract calls. Contract internals and page wiring were not sampled, so the graph limits links to documented or excerpted relationships.

Main entry points: [`contracts/Lending.sol`](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/contracts/Lending.sol) (Lending contract), [`frontend/collector.js`](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/collector.js) (Proposal marketplace), [`frontend/details.js`](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/details.js) (Proposal details), [`frontend/app.js`](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/app.js) (Submit proposals)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_borrower["Borrower flows"]
  node_proposal["Submit proposals<br/>[app.js]"]
  node_repayment["Loan repayment<br/>[app.js]"]
end

subgraph group_lender["Lender flows"]
  node_market["Proposal marketplace<br/>[collector.js]"]
  node_details["Proposal details<br/>[details.js]"]
  node_offer["Make loan offer<br/>[lend.js]"]
end

subgraph group_chain["Blockchain layer"]
  node_lending[("Lending contract<br/>[Lending.sol]")]
  node_mortgage["Mortgage contract<br/>[Mortgage.sol]"]
end

subgraph group_support["Integration"]
  node_web3config["Web3 ABI config<br/>[config.js]"]
  node_wallet["Ethereum wallet"]
  node_ipfs["IPFS gateway"]
end

node_borrower(("Borrower"))
node_lender(("Lender"))

node_borrower -->|"submits request"| node_proposal
node_borrower -->|"repays loan"| node_repayment
node_lender -->|"reviews requests"| node_market
node_lender -->|"accepts terms"| node_offer
node_proposal -->|"creates proposal"| node_lending
node_repayment -->|"marks loan paid"| node_lending
node_market -->|"reads proposals and loans"| node_lending
node_market -->|"sends loan funds"| node_lending
node_details -->|"reads proposals"| node_lending
node_details -->|"loads mortgage document"| node_ipfs
node_offer -->|"accepts proposal"| node_lending
node_proposal -->|"requests account"| node_wallet
node_market -->|"requests account"| node_wallet
node_details -->|"requests account"| node_wallet
node_offer -->|"requests account"| node_wallet

click node_proposal "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/app.js"
click node_repayment "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/app.js"
click node_market "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/collector.js"
click node_details "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/details.js"
click node_offer "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/lend.js"
click node_lending "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/contracts/Lending.sol"
click node_mortgage "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/contracts/Mortgage.sol"
click node_web3config "https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/config.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_proposal,node_repayment toneBlue
class node_market,node_details,node_offer toneAmber
class node_lending,node_mortgage toneMint
class node_web3config,node_wallet,node_ipfs toneRose
class node_borrower,node_lender toneIndigo
```

## Components

### Borrower flows

- [Submit proposals](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/app.js): `frontend/app.js`
- [Loan repayment](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/app.js): `frontend/app.js`

### Lender flows

- [Proposal marketplace](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/collector.js): `frontend/collector.js`
- [Proposal details](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/details.js): `frontend/details.js`
- [Make loan offer](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/lend.js): `frontend/lend.js`

### Blockchain layer

- [Lending contract](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/contracts/Lending.sol): `contracts/Lending.sol`
- [Mortgage contract](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/contracts/Mortgage.sol): `contracts/Mortgage.sol`

### Integration

- [Web3 ABI config](https://github.com/s4n1dhy4/defi-based-emi-collection-system/blob/main/frontend/config.js): `frontend/config.js`
- **Ethereum wallet**
- **IPFS gateway**

### Other components

- **Borrower**
- **Lender**

## Connections

- Borrower → Submit proposals: submits request (evidence: `README.md`)
- Borrower → Loan repayment: repays loan (evidence: `README.md`)
- Lender → Proposal marketplace: reviews requests (evidence: `README.md`)
- Lender → Make loan offer: accepts terms (evidence: `README.md`)
- Submit proposals → Lending contract: creates proposal (evidence: `frontend/app.js`)
- Loan repayment → Lending contract: marks loan paid (evidence: `frontend/app.js`)
- Proposal marketplace → Lending contract: reads proposals and loans (evidence: `frontend/collector.js`)
- Proposal marketplace → Lending contract: sends loan funds (evidence: `frontend/collector.js`)
- Proposal details → Lending contract: reads proposals (evidence: `frontend/details.js`)
- Proposal details → IPFS gateway: loads mortgage document (evidence: `frontend/details.js`)
- Make loan offer → Lending contract: accepts proposal (evidence: `frontend/lend.js`)
- Submit proposals → Ethereum wallet: requests account (evidence: `frontend/app.js`)
- Proposal marketplace → Ethereum wallet: requests account (evidence: `frontend/collector.js`)
- Proposal details → Ethereum wallet: requests account (evidence: `frontend/details.js`)
- Make loan offer → Ethereum wallet: requests account (evidence: `frontend/lend.js`)
