How jeevandhar-mehar/crypto-fund works
markdown
Decentralized Fund Raiser
Overview
The Decentralized Fund Raiser project is a blockchain-backed platform that lets users create, back and manage fundraising campaigns in a fully decentralized, transparent, and immutable way. It combines smart contracts for secure funds management, a relational database for indexing campaign metadata, a Python-based API for business logic, and a Streamlit-powered frontend for an intuitive user experience.
Table of Contents
1. [Features](#features)
2. [Workflow](#workflow)
2.1 [Smart Contract Development](#21-smart-contract-development)
2.2 [Smart Contract Deployment](#22-smart-contract-deployment)
2.3 [Database Initialization](#23-database-initialization)
2.4 [API Server Startup](#24-api-server-startup)
2.5 [Frontend (Streamlit) Launch](#25-frontend-streamlit-launch)
3. [Setup Guide](#setup-guide)
3.1 [Prerequisites](#31-prerequisites)
3.2 [Installation](#32-installation)
3.3 [Environment Setup](#33-environment-setup)
3.4 [Running the Project](#34-running-the-project)
4. [Significance](#significance)
Features
• Decentralized fundraising campaigns on Ethereum-compatible blockchains
• Transparent, immutable transactions powered by smart contracts
• Python/SQLAlchemy-based API for campaign CRUD operations
• Streamlit multipage frontend for dashboard, explore, campaign creation & details
• Migration scripts for versioned database schema management
Workflow
2.1 Smart Contract Development
• contracts/ – directory containing Solidity contracts
• Write campaigns.sol with methods to create campaigns, contribute, withdraw, etc.
2.2 Smart Contract Deployment
• Use Hardhat or Truffle to compile & deploy to local or public testnet
• Scripts live in scripts/ (if you add custom deployment scripts)
• Deployed addresses are recorded in your .env or config for the API/frontend
2.3 Database Initialization
• init_db.py & db_init.py create and seed your relational DB
• Migrations managed via Alembic (alembic.ini, migrations/… )
• Models defined in models.py reflect campaign metadata & user contributions
2.4 API Server Startup
• api/app.py defines Flask/FastAPI endpoints for:
- Campaign listing & details
- Creating a campaign record (after on-chain deployment)
- Querying contribution history
• Utility functions in api/utils.py handle DB sessions & web3 interactions
• Launch via run_api.py
2.5 Frontend (Streamlit) Launch
• app.py + components.py orchestrate Streamlit pages under pages/
- dashboard.py, explore.py, create_campaign.py, campaign_details.py
• Interacts with the API to read/write campaign data and with Web3 for on-chain calls
• Config in .streamlit/config.toml
Setup Guide
3.1 Prerequisites
• Python 3.8+
• Node.js (if using Hardhat/Truffle)
• Yarn or npm
• Ganache or another local Ethereum node (for dev)
• MetaMask (for frontend blockchain interaction)
3.2 Installation
1. Clone the repo
bash
git clone https://github.com/your-repo/DecentralizedFundRaiser.git
cd DecentralizedFundRaiser
2. Install Python dependencies
bash
pip install -r requirements.txt
3. Install Node.js dependencies (for contracts)
bash
cd contracts && npm install && cd ..
3.3 Environment Setup
Create a .env in project root:
ini
INFURA_API_KEY=<your-infura-api-key>
PRIVATE_KEY=<your-wallet-private-key>
NETWORK=<network-name> # e.g., rinkeby, localhost
DATABASE_URL=postgresql://user:pw@localhost:5432/fundraiser
API_HOST=127.0.0.1
API_PORT=8000
3.4 Running the Project
1. Compile & Deploy Contracts
bash
cd contracts
npx hardhat compile
npx hardhat run scripts/deploy.js --network $NETWORK
cd ..
2. Initialize Database & Run Migrations
bash
python init_db.py
alembic upgrade head
3. Start API Server
bash
python run_api.py
4. Launch Frontend
bash
streamlit run app.py
5. Open your browser at http://localhost:8501
Significance
By combining smart contracts, a robust API layer, and a user-friendly frontend, the Decentralized Fund Raiser ensures that all transactions are immutably recorded on-chain while providing performant querying and management off-chain. This design fosters trust, transparency, and accessibility for both campaign creators and contributors.