# πͺ D.M.T.P β Agentic AI-Verified Micro-Task Platform on Celo Blockchain An **AI-powered decentralized task Platform** built on **Celo Sepolia Testnet**, where requesters post micro-tasks, workers complete them, AI verifies the results, and **payments are automatically released in cUSD** upon approval. --- ## π Table of Contents - [Overview](#-overview) - [Tech Stack](#οΈ-tech-stack) - [AI Integration](#-ai-integration-google-gemini-15-pro) - [Database Schema](#οΈ-database-schema-core-entities) - [Folder Structure](#-folder-structure) - [Setup Guide](#οΈ-setup-guide) - [Smart Contract Deployment](#-smart-contract-deployment) - [Workflow](#-workflow) - [API Examples](#-example-api-calls) - [Architecture](#-architecture-diagram) - [Features](#-features-checklist) - [Testing](#-testing) - [Deployment](#-deployment) - [Future Roadmap](#-future-roadmap) - [License](#-license) --- ## β‘ Overview **D.M.T.P** introduces verifiable trust between micro-task requesters and workers. AI moderation (powered by **Google Gemini**) ensures submissions are **authentic and high-quality**, while the **TaskEscrow smart contract** on **Celo** guarantees transparent, secure on-chain payments. ### Key Features - π€ **AI-Powered Verification** β Automated content moderation using Google Gemini - βοΈ **Blockchain Escrow** β Smart contract-based payment security - π° **Instant Payments** β Automatic cUSD release upon task approval - π **Wallet Authentication** β Secure login via MetaMask or MiniPay - π **Real-Time Updates** β Live task and submission status tracking - π― **Quality Control** β AI prevents spam, fraud, and low-effort submissions --- ## π οΈ Tech Stack ### π₯οΈ Frontend β Next.js (App Router) | Feature | Library/Framework | | ------------------ | --------------------------------------------------- | | UI Components | [shadcn/ui](https://ui.shadcn.com) | | Styling | [TailwindCSS](https://tailwindcss.com) | | State Management | [Zustand](https://zustand-demo.pmnd.rs) | | Data Fetching | [TanStack Query](https://tanstack.com/query/v5) | | Wallet Integration | [wagmi](https://wagmi.sh) + [viem](https://viem.sh) | | Blockchain SDK | [@celo/contractkit](https://docs.celo.org/) | | Wallets Supported | **MiniPay** and **MetaMask** | | AI Moderation | [Google Gemini 1.5](https://ai.google.dev/gemini-api/) | ### βοΈ Backend β Express.js + TypeScript | Feature | Technology | | ----------------- | ------------------------------------------ | | Framework | Express.js | | Database | PostgreSQL + Prisma ORM | | Job Queue | Bull + Redis | | AI Verification | Gemini API | | Blockchain | Celo Sepolia | | Authentication | Wallet Signature (EIP-191) | | File Verification | cUSD Escrow via TaskEscrow.sol | | Notifications | Background service + WebSocket placeholder | ### βοΈ Blockchain β Celo Sepolia Testnet - **Smart Contract:** `TaskEscrow.sol` - Holds task payments in escrow - Releases funds when AI-verified - Refunds requester if submissions are rejected - **Token:** `cUSD` (Stablecoin) - **Network RPC:** https://forno.celo-sepolia.celo-testnet.org - **Explorer:** [CeloScan (Sepolia)](https://sepolia.celoscan.io) --- ## π€ AI Integration (Google Gemini 2.5 Pro) Used for: - β Spam, fraud, and duplicate prevention - β Toxic or low-effort content rejection - β Criteria-based submission scoring Gemini runs asynchronously in a **Bull Queue worker**, sending results via webhook to approve or reject submissions. --- ## ποΈ Database Schema (Core Entities) | Table | Description | | ----------------------- | ---------------------------------------------------------------------------------- | | **users** | Stores wallet addresses, roles (`requester` / `worker`), reputation & earnings | | **tasks** | Contains task metadata, blockchain taskID, payment amount, expiry | | **submissions** | Tracks worker submissions, AI verification results | | **payments** | Logs payment releases (+txHash) | | **notifications** | In-app notifications for verification or payment updates | --- ## π Folder Structure ``` D.M.T.P/ βββ client/ # Next.js frontend β βββ app/ # App Router pages β βββ components/ # shadcn + custom UI β βββ hooks/ # Zustand + wagmi hooks β βββ lib/ # API client + Celo utils β βββ types/ # Shared TypeScript models β βββ server/ # Express backend βββ src/ β βββ routes/ # /api/v1 tasks, submissions, users β βββ controllers/ # Request handlers β βββ services/ # AI, blockchain, queue, moderation β βββ workers/ # Bull verification worker β βββ database/ # Prisma schema + migrations βββ prisma/ ``` --- ## βοΈ Setup Guide ### Prerequisites - β Node.js >= 20 - β npm >= 9 - β Redis (running locally or hosted) - β PostgreSQL database - β Celo wallet with test cUSD ### 1οΈβ£ Environment Variables #### `.env` (Backend) ```env # Server PORT=3001 NODE_ENV=development # Database DATABASE_URL="postgresql://user:password@localhost:5432/D.M.T.P" # Blockchain PRIVATE_KEY=YOUR_PRIVATE_KEY_WITH_CUSD CELO_RPC_URL=https://forno.celo-sepolia.celo-testnet.org CONTRACT_ADDRESS=0xYourTaskEscrowAddress CUSD_SEPOLIA_ADDRESS=0x874069fa1eb16d44d622f2e0ca25eea172369bc1 # AI (Gemini) GEMINI_API_KEY=your_google_gemini_api_key # Redis REDIS_HOST=localhost REDIS_PORT=6379 ``` #### `.env.local` (Frontend) ```env NEXT_PUBLIC_API_URL=http://localhost:3001 NEXT_PUBLIC_CELO_RPC_URL=https://forno.celo-sepolia.celo-testnet.org NEXT_PUBLIC_CUSD_ADDRESS=0x874069fa1eb16d44d622f2e0ca25eea172369bc1 NEXT_PUBLIC_CONTRACT_ADDRESS=0xYourTaskEscrowAddress NEXT_PUBLIC_CHAIN_ID=44787 ``` ### 2οΈβ£ Backend Setup ```bash cd server npm install # Prisma setup + migrate npx prisma generate npx prisma db push # Start Redis (using Docker) docker run -d -p 6379:6379 redis:alpine # Start backend in dev mode npm run dev ``` ### 3οΈβ£ Frontend Setup ```bash cd client npm install npm run dev ``` Visit β [http://localhost:3000](http://localhost:3000) --- ## π° Smart Contract Deployment ### Our Deployed Smart Contract- [0xa520d207c91C0FE0e9cFe8D63AbE02fd18B2254e](https://sepolia.celoscan.io/address/0xa520d207c91c0fe0e9cfe8d63abe02fd18b2254e) Deploy `TaskEscrow.sol` on **Celo Sepolia** using Remix or Hardhat. ### Compile & Deploy ```bash npx hardhat run scripts/deploy.ts --network celo-sepolia ``` ### Verify Contract ```bash npx hardhat verify --network celo-sepolia 0xYourContractAddress "0x874069fa1eb16d44d622f2e0ca25eea172369bc1" ``` --- ## π§ Workflow ### β³οΈ Requester Flow 1. Connect wallet β Create Task 2. Payment locked in smart contract 3. Task visible to workers ### π οΈ Worker Flow 1. Accept Task β Submit Response 2. Gemini AI verifies content 3. If approved β β Payment auto-released (cUSD) 4. If rejected β β Refund to requester --- ## π§Ύ Example API Calls ### Create Task ```http POST /api/v1/tasks/create Content-Type: application/json { "title": "Label Images", "description": "Tag each image with emotion category", "paymentAmount": 3.5, "expiresAt": "2025-11-10T12:00:00Z" } ``` ### Submit Task ```http POST /api/v1/submissions/submit Content-Type: application/json { "taskId": "uuid", "submissionData": { "imageUrls": ["https://ipfs.tech/image1.png"], "metadata": { "label": "happy" } } } ``` **AI Queue β Gemini Verification β Payment Released** --- ## π§± Architecture Diagram ``` ββββββββββββββ β Next.js ββββββ ββββββββββββββ β βΌ βββββββββββββ ββββββββββββββββ βExpress.js ββββ PostgreSQL β βββββββββββββ ββββββββββββββββ β βββββββΌβββββββ βΌ βΌ βΌ Gemini Redis Celo AI /Bull Network (Verify) (Queue) (Escrow) ``` --- ## β Features Checklist - [X] Wallet Signature Login (EIP-191) - [X] Gemini-based Content Moderation - [X] Blockchain-Backed Escrow Payments - [X] Task + Submission CRUD - [X] Bull Queue Worker Verification - [X] Real-Time Status Updates - [X] cUSD Balance Tracking - [X] Transaction Confirmation + CeloScan Link - [X] Admin + Requester Dashboard - [X] Fully Responsive UI --- ## π§ͺ Testing ```bash # Run backend tests cd server npm run test # Database Studio npx prisma studio # Queue dashboard npm run bull:dashboard ``` --- ## π Deployment ### Suggested Setup | Layer | Platform | Notes | | -------- | ------------------------------------------------------- | ------------------------ | | Frontend | [Vercel](https://vercel.com) | Auto-deploy from main | | Backend | [Railway](https://railway.app) / [Render](https://render.com) | Node + Postgres service | | Database | Neon / Supabase | Free Postgres DB | | Redis | Upstash / Redis Cloud | Connection for Bull jobs | --- ## π§ Future Roadmap - πͺ On-chain Gemini verification proofs - π§© Decentralized task reputation scoring - π¬ Worker messaging + chat - πͺΆ File uploads to IPFS / Web3.Storage - βοΈ Multi-network support (Base, Polygon) --- ## πͺ Credits Developed with π on the Celo blockchain. Built using **Next.js**, **Celo ContractKit**, **Gemini AI**, and **Prisma**. --- ## π License This project is licensed under the **MIT License** β feel free to fork and extend π‘ --- ## π₯ Contributing Contributions are welcome! Please feel free to submit a Pull Request. 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/AmazingFeature`) 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request --- ## π§ Contact For questions or support, please open an issue on [GitHub](https://github.com/Rio-awsm/micro-job-ai-agent-web3/issues). ---
Made with β€οΈ for the Celo ecosystem