Blockchain-Powered Grant Management & Milestone Tracking Platform
Features • Tech Stack • Getting Started • Architecture • API • Deployment
- Overview
- Features
- Tech Stack
- Architecture
- Getting Started
- Project Structure
- Environment Variables
- User Roles & Workflows
- API Documentation
- Blockchain Integration
- Development
- SEO & Performance
- Deployment
- Contributing
- License
TrustFundX is a decentralized grant management platform that brings transparency and accountability to student project funding. Built on the Algorand blockchain, it enables milestone-based fund disbursement with DAO-style governance, ensuring that funds are released only when project milestones are achieved and approved by voters.
- ✅ Transparent Funding: All transactions recorded on Algorand blockchain
- ✅ Milestone-Based Payments: Funds released incrementally based on progress
- ✅ Democratic Governance: Community voting for milestone approvals
- ✅ Immutable Records: Blockchain-backed proof of fund allocation
- ✅ Multi-Role System: Students, Sponsors, and Voters with distinct workflows
- Pera Wallet Integration: Secure Web3 authentication via QR code scanning
- Role-Based Access Control: Student, Sponsor, and Voter roles with custom dashboards
- Wallet-Based Identity: No passwords, cryptographically secure authentication
- Grant Creation: Sponsors can create grants with customizable milestone counts
- Automated Fund Distribution: Smart contract-based milestone payments
- Real-Time Tracking: Monitor grant status, milestones, and fund allocation
- Grant Funding Dashboard: View total funded amounts and transaction history
- Detailed Milestone Pages: View all milestone information including approvals, payment status, and submissions
- File Upload Support: Students can submit proof of work via Filestack integration
- Approval Tracking: Real-time voting count and approval status
- Submission History: Track when milestones were submitted and approved
- DAO-Style Governance: Voters review and approve milestone completions
- Blockchain-Verified Votes: All votes recorded on Algorand
- Pending Approvals Queue: Organized dashboard for voters to review submissions
- Historical Voting Records: Track recent approvals and voting history
- Modern UI/UX: Gradient designs, smooth animations with Framer Motion
- Responsive Design: Mobile-first approach with Tailwind CSS
- Real-Time Updates: Live milestone status and approval counts
- Interactive Dashboards: Role-specific interfaces optimized for each user type
- Comprehensive SEO: Metadata, OpenGraph, Twitter Cards, structured data
- Dynamic Sitemap: Auto-generated sitemap for search engines
- PWA Support: Progressive Web App with manifest.json
- Social Media Ready: Dynamic OG image generation for link previews
- Next.js 16.1.6 - React framework with App Router and Turbopack
- React 19 - UI library with latest features
- TypeScript 5 - Type-safe JavaScript
- Tailwind CSS 4 - Utility-first CSS framework
- Framer Motion 12 - Animation library
- Lucide React - Modern icon library
- Algorand - Layer-1 blockchain (Testnet)
- Pera Wallet - Web3 wallet integration
- algosdk 3.5.2 - Algorand JavaScript SDK
- Smart Contracts: TEAL-based contracts for grant management
- MongoDB 6.3.0 - NoSQL database
- Next.js API Routes - Serverless API endpoints
- QR Code React - QR code generation
- Filestack - File upload and storage
- Algorand Node API - Blockchain interaction via AlgoNode
┌─────────────────────────────────────────────────────────────┐
│ Client Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Login │ │ Signup │ │ Students │ │ Voters │ │
│ │ Page │ │ Page │ │Dashboard │ │Dashboard │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │ │ │
│ └──────────────┴──────────────┴────────────┘ │
│ │ │
│ WalletContext │
└────────────────────────┬────────────────────────────────────┘
│
┌────────────────────────┴────────────────────────────────────┐
│ API Layer (Next.js) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Auth │ │ Grants │ │Milestones│ │ Upload │ │
│ │ APIs │ │ APIs │ │ APIs │ │ API │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
└─────────┬────────────────────────┬─────────────────┬────────┘
│ │ │
┌─────────┴────────┐ ┌─────────┴────────┐ ┌─────┴──────┐
│ MongoDB │ │ Algorand │ │ Filestack │
│ Database │ │ Blockchain │ │ Storage │
│ │ │ │ │ │
│ • Users │ │ • Smart Contract │ │ • Files │
│ • Grants │ │ • Transactions │ │ • PDFs │
│ • Milestones │ │ • Voting Records │ │ • Images │
└──────────────────┘ └──────────────────┘ └────────────┘
-
Authentication Flow
User → Pera Wallet (QR) → WalletContext → Auth API → MongoDB -
Grant Creation Flow
Sponsor → Create Grant → Smart Contract → Algorand → Grant API → MongoDB -
Milestone Submission Flow
Student → Upload File → Filestack → Submit Milestone → Milestone API → MongoDB -
Voting Flow
Voter → Approve → Smart Contract → Algorand → Sync API → MongoDB
-
Clone the repository
git clone https://github.com/yourusername/trustfundx.git cd trustfundx/web -
Install dependencies
npm install
-
Set up MongoDB
Start MongoDB locally:
# Windows mongod # macOS (via Homebrew) brew services start mongodb-community # Linux sudo systemctl start mongod
-
Configure environment variables
Create
.env.localin the root directory:# MongoDB Configuration MONGODB_URI=mongodb://localhost:27017/grant-tracking # Filestack (Optional - for file uploads) NEXT_PUBLIC_FILESTACK_API_KEY=your_filestack_api_key_here
To get Filestack API key:
- Sign up at filestack.com
- Get your API key from dashboard
- Add to
.env.local
-
Run the development server
npm run dev
-
Open the application
Navigate to http://localhost:3000
-
Create User Account
- Go to
/signup - Fill in your details
- Select your role (Student/Sponsor/Voter)
- Scan QR code with Pera Wallet to connect
- Go to
-
Fund Test Wallet (for Sponsors)
- Visit Algorand Testnet Dispenser
- Enter your wallet address
- Get test ALGO tokens
-
Start Using TrustFundX
- Sponsors: Create grants
- Students: Track milestones
- Voters: Review and approve submissions
TrustFundX/web/
├── app/ # Next.js App Router
│ ├── layout.tsx # Root layout with SEO metadata
│ ├── page.tsx # Landing page
│ ├── globals.css # Global styles
│ │
│ ├── api/ # API Routes
│ │ ├── auth/
│ │ │ ├── login/
│ │ │ │ └── route.ts # POST /api/auth/login
│ │ │ └── signup/
│ │ │ └── route.ts # POST /api/auth/signup
│ │ ├── grants/
│ │ │ └── route.ts # GET, POST /api/grants
│ │ ├── milestones/
│ │ │ └── route.ts # GET, POST, PUT /api/milestones
│ │ ├── voters/
│ │ │ └── route.ts # GET /api/voters
│ │ ├── upload/
│ │ │ └── route.ts # POST /api/upload
│ │ ├── sync-milestone/
│ │ │ └── route.ts # POST /api/sync-milestone
│ │ └── fix-grant-funding/
│ │ └── route.ts # POST /api/fix-grant-funding
│ │
│ ├── login/
│ │ └── page.tsx # Login page with Pera Wallet
│ ├── signup/
│ │ └── page.tsx # Multi-step signup
│ │
│ ├── students/
│ │ └── page.tsx # Student dashboard
│ ├── sponsors/
│ │ ├── page.tsx # Sponsor dashboard
│ │ └── create/
│ │ └── page.tsx # Create grant page
│ ├── voters/
│ │ └── page.tsx # Voter dashboard
│ │
│ ├── milestone/
│ │ └── [id]/
│ │ └── page.tsx # Milestone detail page
│ │
│ ├── sitemap.ts # Dynamic sitemap generation
│ └── opengraph-image.tsx # Dynamic OG image
│
├── contexts/
│ └── WalletContext.tsx # Pera Wallet provider
│
├── lib/
│ ├── algorand.ts # Algorand client config
│ ├── contract.json # Smart contract ABI
│ ├── contractMethods.ts # Contract interaction methods
│ ├── diagnostics.ts # Error handling utilities
│ ├── mongodb.ts # MongoDB connection
│ ├── syncBlockchain.ts # Blockchain sync utilities
│ └── types.ts # TypeScript type definitions
│
├── public/
│ ├── favicon.ico # Site favicon
│ ├── manifest.json # PWA manifest
│ ├── robots.txt # SEO crawler config
│ ├── humans.txt # Credits file
│ └── Artifacts/ # Smart contract artifacts
│ ├── GetFund.approval.teal
│ ├── GetFund.arc56.json
│ ├── GetFund.clear.teal
│ └── get_fund_client.py
│
├── .env.local # Environment variables (not in git)
├── .gitignore
├── eslint.config.mjs # ESLint configuration
├── next.config.ts # Next.js configuration
├── package.json # Dependencies and scripts
├── postcss.config.mjs # PostCSS configuration
├── tailwind.config.ts # Tailwind CSS configuration
├── tsconfig.json # TypeScript configuration
└── README.md # This file
Create a .env.local file in the project root with the following variables:
| Variable | Required | Default | Description |
|---|---|---|---|
MONGODB_URI |
✅ Yes | - | MongoDB connection string |
NEXT_PUBLIC_APP_ID |
✅ Yes | - | Algorand smart contract application ID |
NEXT_PUBLIC_APP_ADDRESS |
✅ Yes | - | Algorand smart contract address |
NEXT_PUBLIC_FILESTACK_API_KEY |
- | Filestack API key for file uploads |
# Local MongoDB
MONGODB_URI=mongodb://localhost:27017/grant-tracking
# MongoDB Atlas
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/grant-tracking?retryWrites=true&w=majority
# Docker MongoDB
MONGODB_URI=mongodb://host.docker.internal:27017/grant-tracking
Set these environment variables for Algorand smart contract interaction:
# Algorand Testnet App ID (number)
NEXT_PUBLIC_APP_ID=YOUR_DEPLOYED_APP_ID
# Algorand Testnet App Address (contract account address)
NEXT_PUBLIC_APP_ADDRESS=YOUR_DEPLOYED_APP_ADDRESSNote: These variables are public (prefixed with NEXT_PUBLIC_) because they need to be accessible in the browser. The values shown above are for the Algorand Testnet.
Purpose: Receive funding and complete project milestones
Dashboard Features:
- View assigned grants
- Track milestone progress
- Submit milestone completions with proof
- Monitor approval status
- Receive payments upon approval
Workflow:
- Log in with Pera Wallet
- View grants assigned to your wallet
- When milestone is ready, click on it
- Upload submission file (PDF, image, etc.)
- Add submission note
- Wait for voter approvals
- Receive payment when milestone is approved
Purpose: Create and fund grants for student projects
Dashboard Features:
- Create new grants with custom milestones
- Fund grants with ALGO tokens
- Monitor grant progress
- View milestone statuses
- Track total funding amounts
Workflow:
- Log in with Pera Wallet
- Navigate to "Create Grant"
- Enter grant details:
- Student wallet address
- Number of milestones
- Required votes per milestone
- Sign transaction with Pera Wallet
- Fund the grant contract
- Monitor progress on dashboard
Purpose: Review and approve milestone completions
Dashboard Features:
- View pending milestone approvals
- Review submission details and files
- Cast approval votes
- See recent approval history
- Participate in governance
Workflow:
- Log in with Pera Wallet
- Review pending milestones
- Click milestone to view details
- Review submission note and files
- Click "Approve" if satisfied
- Sign transaction with Pera Wallet
- Milestone moves to recent approvals
Create a new user account
Request Body:
{
"name": "John Doe",
"email": "john@example.com",
"organization": "University XYZ",
"role": "student",
"walletAddress": "ABCD..."
}Response:
{
"success": true,
"user": {
"_id": "...",
"name": "John Doe",
"email": "john@example.com",
"role": "student",
"walletAddress": "ABCD..."
}
}Authenticate user with wallet address
Request Body:
{
"walletAddress": "ABCD..."
}Response:
{
"success": true,
"user": {
"role": "student",
"name": "John Doe"
}
}Fetch grants (filtered by query params)
Query Parameters:
sponsorAddress- Filter by sponsor walletteamAddress- Filter by student wallet
Response:
[
{
"_id": "...",
"sponsorAddress": "ABCD...",
"teamAddress": "EFGH...",
"requiredVotes": 3,
"milestoneCount": 5,
"appId": 1234567,
"txId": "XYZ...",
"status": "active",
"totalFunded": 1000,
"createdAt": "2026-03-01T00:00:00.000Z"
}
]Create a new grant
Request Body:
{
"sponsorAddress": "ABCD...",
"teamAddress": "EFGH...",
"requiredVotes": 3,
"milestoneCount": 5,
"appId": 1234567,
"txId": "XYZ..."
}Fetch milestones
Query Parameters:
grantId- Filter by grant IDmilestoneDbId- Fetch specific milestone by database ID
Response:
[
{
"_id": "...",
"grantId": "...",
"milestoneId": 1,
"amount": 200,
"approvals": 2,
"paid": false,
"submissionNote": "Completed Phase 1",
"submissionFileUrl": "https://...",
"submittedAt": "2026-03-02T00:00:00.000Z",
"createdAt": "2026-03-01T00:00:00.000Z"
}
]Create milestones for a grant
Request Body:
{
"grantId": "...",
"milestoneCount": 5,
"amounts": [200, 200, 200, 200, 200]
}Update milestone (submit completion)
Request Body:
{
"milestoneDbId": "...",
"submissionNote": "Phase completed",
"submissionFileUrl": "https://..."
}Fetch all voter users
Response:
[
{
"_id": "...",
"name": "Jane Smith",
"email": "jane@example.com",
"walletAddress": "VOTER123...",
"role": "voter"
}
]Upload file via Filestack
Request Body:
{
"base64": "data:application/pdf;base64,..."
}Response:
{
"url": "https://cdn.filestackcontent.com/..."
}Sync milestone data from blockchain
Request Body:
{
"grantId": "...",
"milestoneId": 1
}Recalculate grant funding amounts
Request Body:
{
"appId": 1234567
}Contract Type: Algorand Smart Contract (TEAL)
Network: Testnet
App ID: 1234567
Contract Address: YOUR_DEPLOYED_APP_ADDRESS
Located in lib/contractMethods.ts:
Creates a new grant fund with milestones
Parameters:
sponsorAddress- Wallet address of sponsorteamAddress- Wallet address of studentrequiredVotes- Number of approvals neededmilestoneCount- Total milestones
Returns: Transaction ID
Adds ALGO tokens to grant contract
Parameters:
appId- Contract application IDamount- ALGO amount to fund
Voter approves a milestone
Parameters:
milestoneId- ID of milestone to approvevoterAddress- Wallet address of voter
Releases payment when milestone approved
Parameters:
milestoneId- ID of milestone
lib/syncBlockchain.ts provides:
fetchMilestoneFromBlockchain()- Get milestone datafetchGrantBalance()- Get grant contract balancesyncAllMilestones()- Sync all milestones with blockchain
# Start development server with hot reload
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Run ESLint
npm run lint-
Start MongoDB
mongod
-
Run Development Server
npm run dev
-
Make Changes
- Edit files in
app/,lib/, orcontexts/ - Changes auto-reload with Turbopack
- Edit files in
-
Test Changes
- Test in browser with Pera Wallet
- Check MongoDB for data persistence
- Verify blockchain transactions on AlgoExplorer Testnet
-
Commit
git add . git commit -m "Description of changes" git push
View MongoDB Collections:
mongosh
use grant-tracking
db.users.find()
db.grants.find()
db.milestones.find()Clear All Data (development only):
mongosh
use grant-tracking
db.dropDatabase()- Install Pera Wallet on mobile device
- Create test account
- Get test ALGO from dispenser
- Scan QR codes from TrustFundX to connect
- Sign transactions in Pera Wallet app
✅ Comprehensive Metadata
- Title templates
- Meta descriptions
- Keywords
- Author information
✅ Social Media Optimization
- OpenGraph tags for Facebook/LinkedIn
- Twitter Card tags
- Dynamic OG image generation
✅ Search Engine Optimization
- Robots.txt configuration
- Dynamic XML sitemap
- Structured data (JSON-LD)
- Canonical URLs
✅ PWA Support
- Web app manifest
- Theme colors
- App icons
✅ Additional
- humans.txt for credits
- Verification tags (Google/Yandex)
- Next.js 16: Latest features and optimizations
- Turbopack: Faster builds and hot reload
- React 19: Improved rendering performance
- Tailwind CSS 4: Optimized CSS output
- Image Optimization: Next.js automatic image optimization
- Code Splitting: Automatic route-based splitting
- Edge Runtime: Fast OG image generation
-
Push to GitHub
git push origin main
-
Import to Vercel
- Go to vercel.com
- Click "Import Project"
- Select your repository
-
Configure Environment Variables
- Add
MONGODB_URI(use MongoDB Atlas) - Add
NEXT_PUBLIC_FILESTACK_API_KEY(optional)
- Add
-
Deploy
- Click "Deploy"
- Wait for build to complete
- Your site is live!
- Create account at mongodb.com/cloud/atlas
- Create free cluster
- Add database user
- Whitelist IP addresses (0.0.0.0/0 for all)
- Get connection string
- Add to Vercel environment variables
- Go to Vercel project settings
- Navigate to "Domains"
- Add your custom domain
- Configure DNS records as instructed
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Commit with descriptive message
git commit -m "Add amazing feature" - Push to your fork
git push origin feature/amazing-feature
- Open a Pull Request
- Use TypeScript for type safety
- Follow ESLint rules
- Use Tailwind CSS for styling
- Write descriptive commit messages
- Comment complex logic
- 🐛 Bug fixes
- ✨ New features
- 📝 Documentation improvements
- 🎨 UI/UX enhancements
- ⚡ Performance optimizations
- 🧪 Test coverage
This project is licensed under the MIT License.
MIT License
Copyright (c) 2026 TrustFundX
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.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@trustfundx.com
- Algorand Foundation - Blockchain infrastructure
- Pera Wallet - Secure wallet integration
- MongoDB - Database solution
- Vercel - Hosting and deployment
- Next.js Team - Amazing framework
- Open Source Community - Various libraries and tools