How sagarshivalingappaathani/public-fund-management works
Project type and purpose
• This is a full‑stack decentralized application (DApp) for public fund management.
• Core purpose: allow authorities and citizens to propose, vote on, and release government funds in stages using Ethereum smart contracts, with AI‑powered verification of utilization reports.
File structure
• Top level:
• backend/ – Django REST API for AI‑powered document analysis
• frontend/ – Next.js application with React components and Web3 integration
• smart‑contracts/ – Hardhat‑based Solidity contracts and deployment scripts
• files/ – sample output PDF
• backend directory follows a typical Django MVC layout (APIs app, settings, migrations, middleware).
• frontend uses Next.js “app” router, custom hooks, component library (ui/) and Web3 contract libraries in lib/.
• smart‑contracts holds Solidity code, tests, deployment scripts, Hardhat config.
README for additional insights
• Workflow:
a. Authorities create/vote on proposals on-chain
b. Public votes with soulbound tokens (SBT)
c. Funds released in 3 stages; each stage release conditioned on report upload (to IPFS)
d. Django backend analyzes reports via RAG + LangChain + vector DB + LLM
• Technologies:
• Smart contracts on Ethereum + IPFS for off‑chain storage
• Next.js + Web3.js
• Django REST + Groq API + HuggingFace embeddings + FAISS
Main components & interactions
a. Frontend (Next.js)
– React pages and components
– Web3 provider / Wallet connector
– Calls smart‑contract functions and listens to events
– Calls Django API for report analysis
b. Backend API (Django)
– /analyze/ endpoint
– Document loader → text‑chunker → embeddings → FAISS vector store → LangChain RAG → decision logic
– Returns analysis and CID back to frontend or triggers contract call
c. Smart contracts (Solidity)
– PublicFundManagement.sol (proposal, voting, staged disbursement)
– SoulboundToken.sol (SBT issuance for public voters)
– Deploy scripts and tests
d. Blockchain network
– Ethereum (e.g., testnet/mainnet) for contract state and events
– IPFS for storing report documents, smart contract stores CIDs
e. External services
– GROQ API / LLM
– HuggingFace embeddings
– IPFS gateway
– FAISS vector store (could be self‑hosted or cloud)
Architectural patterns & design principles
• Layered architecture:
• Presentation layer (frontend)
• API layer (Django REST)
• Smart‑contract layer (on‑chain business logic)
• Data / storage layer (Ethereum state + IPFS + vector store)
• Event‑driven interactions: frontend listens to on‑chain events to reflect state changes
• RAG microservice: decoupled AI pipeline behind REST API
• Separation of concerns: UI, blockchain logic, AI logic are separate components that communicate via well‑defined interfaces
Essential details to capture
• Multi-stage funding workflow: initial proposal → authority vote → public vote → stage‑wise disbursement
• AI verification loop: report upload → RAG analysis → automated fund release or review trigger
• Off‑chain storage vs. on‑chain state differentiation
• Extensibility: where to plug in additional standard questions or new LLM models