Skip to content

PayTaskdz/PayTask

Repository files navigation

PayTask - Decentralized Task Marketplace

Kết nối người giao việc và người nhận việc, thanh toán tức thì bằng USDC trên Solana blockchain.

TypeScript Fastify PostgreSQL Solana Next.js


🎯 PayTask Là Gì?

PayTask là nền tảng marketplace phi tập trung giúp:

  • 👔 Clients đăng công việc và tìm worker có kỹ năng
  • 👷 Workers tìm việc phù hợp và kiếm USDC
  • 💰 Thanh toán tự động sau khi hoàn thành công việc
  • 🔐 Bảo mật với blockchain và smart escrow

✨ Điểm Khác Biệt

Tính năng PayTask Freelance truyền thống
Thanh toán ⚡ Tức thì (USDC) 🐌 3-14 ngày
Phí giao dịch 🎯 Thấp (~1-2%) 💸 Cao (20-30%)
Bảo mật 🔐 Blockchain ⚠️ Trung gian
Tranh chấp 🤖 Tự động 📧 Email support
QA kiểm tra ✅ Tự động 👀 Thủ công

🚀 Bắt Đầu Nhanh (5 phút)

1️⃣ Clone & Install

git clone https://github.com/PayTaskdz/PayTask.git
cd PayTask
npm install

2️⃣ Setup Database

# Copy environment
cp .env.example .env

# Run migrations
npx prisma migrate dev

# Seed test data
npx prisma db seed

3️⃣ Start Services

Backend (Terminal 1):

npm run dev

✅ API: http://localhost:3000

Frontend (Terminal 2):

cd frontend/frontendpaytask
npm install
npm run dev

✅ Web: http://localhost:3001

4️⃣ Test


� Tài Liệu Chi Tiết

🎓 Cho User

  • QUICK_START.md ⭐ Bắt đầu ngay!
    • Hướng dẫn cho Client (người giao việc)
    • Hướng dẫn cho Worker (người nhận việc)
    • Setup & troubleshooting

� Cho Developer


🏗️ Kiến Trúc Hệ Thống

┌─────────────────────────────────────────────────────────────┐
│                     PAYTASK ARCHITECTURE                     │
└─────────────────────────────────────────────────────────────┘

┌─────────────┐      ┌──────────────┐      ┌─────────────┐
│   Frontend  │──────│   Backend    │──────│  Blockchain │
│  (Next.js)  │ HTTP │  (Fastify)   │ RPC  │   (Solana)  │
└─────────────┘      └──────────────┘      └─────────────┘
       │                    │                      │
       │                    ├──────┐               │
       │                    │      │               │
       │              ┌─────▼───┐  │         ┌────▼────┐
       │              │  Cache  │  │         │  USDC   │
       │              │ (Redis) │  │         │ Wallet  │
       │              └─────────┘  │         └─────────┘
       │                    │      │
       │              ┌─────▼───┐  │
       └──────────────│Database │◄─┘
                      │(Postgres)│
                      └──────────┘

Tech Stack

Backend:

  • ⚡ Fastify - Fast web framework
  • 🗃️ Prisma - Type-safe ORM
  • 🐘 PostgreSQL - Main database
  • 🔴 Redis - Caching & sessions
  • 🟣 Solana Web3.js - Blockchain integration
  • 📦 Bull - Job queue

Frontend:

  • ⚛️ Next.js 14 - React framework
  • 🎨 TailwindCSS - Styling
  • 🧩 shadcn/ui - UI components
  • 🔄 React Query - Data fetching
  • 📡 Axios - HTTP client

Blockchain:

  • 💰 Solana - Layer 1 blockchain
  • 🪙 USDC - Stablecoin payment
  • 🔐 Solana wallet adapter

� Demo Flow

Client Journey

1. Đăng nhập → client1@paytask.com
2. Tạo task: "Nhập liệu 100 sản phẩm" - Reward: 50 USDC
3. Publish task → Hiển thị trên marketplace
4. Đợi worker submit
5. Review & Accept
6. 💰 Tự động chuyển 50 USDC cho worker

Worker Journey

1. Đăng nhập → worker1@paytask.com
2. Browse tasks → Filter theo category, reward
3. Accept task → Bắt đầu làm việc
4. Upload file kết quả
5. Submit → Chờ review
6. 🎉 Nhận 50 USDC vào wallet

🔑 Features

✅ Core Features

  • Task discovery với advanced filters
  • Assignment system với optimistic locking
  • File upload & validation
  • QA checks tự động
  • Review & rating system
  • USDC payment integration
  • Real-time notifications
  • Wallet management

🚧 Coming Soon

  • Multi-language support
  • Mobile app
  • Escrow smart contracts
  • Dispute resolution system
  • Advanced analytics dashboard
  • Reputation-based rewards

� API Endpoints

Authentication

  • POST /api/auth/register - Đăng ký
  • POST /api/auth/login - Đăng nhập
  • POST /api/auth/logout - Đăng xuất

Tasks

  • GET /api/tasks/discover - Tìm tasks
  • POST /api/tasks - Tạo task (Client)
  • POST /api/tasks/publish/:id - Publish task
  • GET /api/tasks/:id - Chi tiết task

Assignments

  • POST /api/assignments/accept - Accept task (Worker)
  • GET /api/assignments/user/:userId - My assignments

Submissions

  • POST /api/uploads/files - Upload file
  • POST /api/submissions - Submit work
  • GET /api/submissions/:id - Submission details

Reviews

  • POST /api/reviews/accept - Accept & pay (Client)
  • POST /api/reviews/reject - Reject submission

Wallet

  • GET /api/users/me - Profile & wallet balance
  • GET /api/wallet/transactions - Transaction history

📚 Full API docs: http://localhost:3000/api-docs


🧪 Testing

Postman Collection

Import 2 files:

  • PayTask-API-Fixed.postman_collection.json
  • PayTask-Development.postman_environment.json

Test Accounts

Clients:

Email Password Role
client1@paytask.com password123 Client
client2@paytask.com password123 Client

Workers:

Email Password Reputation
worker1@paytask.com password123 ⭐⭐⭐⭐
worker2@paytask.com password123 ⭐⭐⭐

Run Tests

# Backend tests
npm test

# E2E tests
npm run test:e2e

# API tests (Postman)
./run-api-tests.sh   # Unix/Mac
run-api-tests.bat    # Windows

� Security

Authentication

  • ✅ JWT tokens với refresh mechanism
  • ✅ Password hashing (bcrypt)
  • ✅ Session management (Redis)
  • ✅ Rate limiting

Payment Security

  • ✅ Solana wallet encryption
  • ✅ Transaction timeout protection
  • ✅ Payment verification
  • ✅ Signature validation

Data Protection

  • ✅ SQL injection prevention (Prisma)
  • ✅ XSS protection
  • ✅ CORS configuration
  • ✅ File upload validation

🛠️ Development

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+
  • Redis 7+
  • Solana CLI (optional)

Environment Variables

# Database
DATABASE_URL="postgresql://user:pass@localhost:5432/paytask"

# Redis
REDIS_HOST="localhost"
REDIS_PORT=6379

# JWT
JWT_SECRET="your-secret-key"
JWT_EXPIRES_IN="7d"

# Solana
SOLANA_NETWORK="devnet"
SETTLEMENT_WALLET_PRIVATE_KEY="your-private-key"

# Frontend
NEXT_PUBLIC_API_URL="http://localhost:3000"

Scripts

# Development
npm run dev              # Start backend
npm run dev:frontend     # Start frontend

# Database
npm run db:migrate       # Run migrations
npm run db:seed          # Seed data
npm run db:studio        # Open Prisma Studio

# Build
npm run build            # Build backend
npm run build:frontend   # Build frontend

# Production
npm start                # Start backend
npm run start:frontend   # Start frontend

📈 Monitoring

Health Checks

curl http://localhost:3000/health

Response:

{
  "status": "ok",
  "uptime": 123.45,
  "checks": {
    "database": "connected",
    "redis": "connected",
    "blockchain": "connected"
  }
}

Logs

# Backend logs
tail -f logs/app.log

# Error logs
tail -f logs/error.log

# Payment logs
tail -f logs/payment.log

🤝 Contributing

Chúng tôi hoan nghênh mọi đóng góp!

  1. Fork repo
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

Code Style

# Format code
npm run format

# Lint
npm run lint

# Type check
npm run type-check

� License

MIT License - see LICENSE


📞 Support

Documentation

Contact

Issues

Found a bug? Open an issue


🙏 Acknowledgments

Built with ❤️ using:


🎯 Roadmap

Q4 2025

  • MVP Launch
  • Basic task flow
  • USDC payments
  • Mobile app beta

Q1 2026

  • Escrow smart contracts
  • Multi-chain support
  • Advanced analytics
  • DAO governance

Q2 2026

  • Enterprise features
  • API marketplace
  • White-label solution

⭐ Nếu thấy hữu ích, hãy cho repo một star!

Last Updated: October 31, 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •