This project is a decentralized application (dApp) for micro loans. It allows users to request and fund loans using a blockchain-based smart contract. The risk score of each loan is calculated using a machine learning model trained on a public dataset.
- Users can request loans by providing details such as loan amount, interest rate, duration, and personal information.
- Loans can be funded by other users.
- Risk scores are calculated for each loan request to help lenders make informed decisions.
- Risk scores are displayed as a visual bar in the UI.
- Frontend: React, Material-UI
- Backend: Flask, Flask-CORS
- Blockchain: Web3.js, Solidity, Ganache
- Machine Learning: Scikit-learn
- Public Dataset: Kaggle Credit Risk Dataset
- Node.js and npm
- Python and pip
- Ganache CLI (for local Ethereum blockchain)
-
Install Node (if not installed):
brew install node
-
Clone the repository:
git clone https://github.com/your-username/micro-loan-dapp.git cd micro-loan-dapp
-
Install backend dependencies:
cd flash-backend python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` pip install -r requirements.txt
-
Install frontend dependencies:
cd ../micro-loan-dapp npm install
-
Install Ganache CLI:
npm install -g ganache-cli
-
Start Ganache CLI:
ganache-cli
-
Deploy Smart Contract:
truffle migrate
-
Start the backend server:
cd flash-backend source venv/bin/activate flask run
-
Start the frontend development server:
cd ../micro-loan-dapp npm start
-
Interact with the application:
- Open your web browser and navigate to
http://localhost:3000
.
- Open your web browser and navigate to
The machine learning model was trained using a public dataset from Kaggle. You can find the dataset here.
The RandomForestClassifier
from the Scikit-learn library was used to train the risk assessment model. The model predicts the probability of loan default based on several input features.
-
Download the dataset from Kaggle and place it in the
flash-backend
directory. -
Run the training script to train the model:
cd flash-backend source venv/bin/activate python train_model.py
This script will:
- Load and preprocess the dataset.
- Encode categorical variables.
- Train a
RandomForestClassifier
. - Save the trained model and encoders as
.pkl
files.
- Log in to the application.
- Fill in the loan request form with the required details.
- Submit the request to create a loan.
- Browse the list of available loans.
- Select a loan to fund and click the "Fund Loan" button.
- Browse the list of your outstanding loans.
- Select a loan to repay and click the "Repay Loan" button.
Contributions are welcome! Please create a pull request or open an issue to discuss your changes.
This project is licensed under the MIT License.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Third-Party Packages Used:
-
Flask
- License: BSD-3-Clause
- URL: https://palletsprojects.com/p/flask/
-
Flask-CORS
- License: MIT
- URL: https://github.com/corydolphin/flask-cors
-
scikit-learn
- License: BSD-3-Clause
- URL: https://scikit-learn.org/stable/about.html#license
-
React
- License: MIT
- URL: https://reactjs.org/
-
axios
- License: MIT
- URL: https://github.com/axios/axios
-
Web3.js
- License: MIT
- URL: https://github.com/ChainSafe/web3.js
Dataset Used:
- Credit Risk Dataset
- Source: Kaggle
- URL: https://www.kaggle.com/datasets/laotse/credit-risk-dataset