Skip to content

A decentralized app where users can upload thumbnails, and the community determines the 'most clickable' thumbnail. Workers can click on thumbnails to earn rewards, creating an incentivized system.Powered by blockchain, the app ensures transparency, community-driven content ranking, and user rewards

Notifications You must be signed in to change notification settings

JrGkOG/DexAdofm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DexAdofm - Decentralized Task Distribution Platform

A decentralized platform built on Solana blockchain for distributing and completing tasks with secure payment processing using Shamir's Secret Sharing (SSS) for private key management.

πŸš€ Project Overview

DexAdofm is a full-stack decentralized application that enables users to create tasks (like thumbnail selection) and workers to complete them for cryptocurrency rewards. The platform features:

  • Decentralized Architecture: Built on Solana blockchain
  • Secure Payment Processing: Uses Shamir's Secret Sharing for private key management
  • Dual Interface: Separate user and worker frontends
  • Distributed Infrastructure: Multi-server distribution system
  • Real-time Task Management: PostgreSQL database with Prisma ORM

πŸ—οΈ Architecture

Backend Services

  • Main Backend (backend/): Express.js API with TypeScript
  • Distribution Servers (distribution/): 5-node distributed system for load balancing
  • Database: PostgreSQL with Prisma ORM
  • Blockchain Integration: Solana Web3.js for wallet operations

Frontend Applications

  • User Frontend (user-frontend/): Next.js app for task creators (Port 3001)
  • Worker Frontend (worker-frontend/): Next.js app for task workers (Port 3002)

Key Technologies

  • Blockchain: Solana
  • Backend: Node.js, Express.js, TypeScript
  • Frontend: Next.js 14, React 18, Tailwind CSS
  • Database: PostgreSQL, Prisma
  • Security: Shamir's Secret Sharing, JWT
  • Infrastructure: Docker, Docker Compose

πŸ“ Project Structure

DexAdofm/
β”œβ”€β”€ backend/                 # Main API server
β”‚   β”œβ”€β”€ prisma/             # Database schema and migrations
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routers/        # API routes
β”‚   β”‚   β”œβ”€β”€ sss/           # Shamir's Secret Sharing implementation
β”‚   β”‚   └── types.ts       # TypeScript definitions
β”‚   └── package.json
β”œβ”€β”€ distribution/           # Distributed server infrastructure
β”‚   β”œβ”€β”€ server-1/          # Distribution node 1 (Port 8080)
β”‚   β”œβ”€β”€ server-2/          # Distribution node 2 (Port 7070)
β”‚   β”œβ”€β”€ server-3/          # Distribution node 3 (Port 6060)
β”‚   β”œβ”€β”€ server-4/          # Distribution node 4 (Port 5050)
β”‚   β”œβ”€β”€ server-5/          # Distribution node 5 (Port 4040)
β”‚   └── docker-compose.yml
β”œβ”€β”€ user-frontend/         # Task creator interface
β”‚   β”œβ”€β”€ app/              # Next.js app router
β”‚   β”œβ”€β”€ components/       # React components
β”‚   └── package.json
└── worker-frontend/      # Task worker interface
    β”œβ”€β”€ app/              # Next.js app router
    β”œβ”€β”€ components/       # React components
    └── package.json

πŸ› οΈ Setup Instructions

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Docker and Docker Compose
  • Solana CLI tools
  • Yarn or npm

1. Backend Setup

cd backend

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env with your database URL and other configurations

# Set up database
npx prisma generate
npx prisma db push

# Generate Shamir's Secret Sharing shares
npm run generate:shares

# Start the server
npm start

2. User Frontend Setup

cd user-frontend

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env with your backend API URL

# Start development server
npm run dev

3. Worker Frontend Setup

cd worker-frontend

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env with your backend API URL

# Start development server
npm run dev

4. Distribution Infrastructure

cd distribution

# Start all distribution servers
docker-compose up -d

# Check server status
docker-compose ps

πŸ”§ Environment Variables

Backend (.env)

DATABASE_URL="postgresql://username:password@localhost:5432/dexadofm"
JWT_SECRET="your-jwt-secret"
SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"
AWS_ACCESS_KEY_ID="your-aws-key"
AWS_SECRET_ACCESS_KEY="your-aws-secret"
AWS_REGION="us-east-1"
S3_BUCKET="your-s3-bucket"

Frontend (.env)

NEXT_PUBLIC_API_URL="http://localhost:3000"
NEXT_PUBLIC_SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"

πŸš€ Usage

For Task Creators (Users)

  1. Connect your Solana wallet to the user frontend
  2. Upload images for your task (e.g., thumbnail options)
  3. Set the reward amount in SOL
  4. Submit the task to the blockchain
  5. Monitor task completion and payouts

For Task Workers

  1. Connect your Solana wallet to the worker frontend
  2. Browse available tasks
  3. Complete tasks by selecting the best option
  4. Receive automatic payments upon task completion

πŸ” Security Features

  • Shamir's Secret Sharing: Private keys are split across multiple distribution servers
  • JWT Authentication: Secure API access
  • Blockchain Verification: All transactions verified on Solana
  • Rate Limiting: Protection against spam and abuse

πŸ“Š Database Schema

The application uses the following main entities:

  • User: Task creators with Solana addresses
  • Worker: Task completers with pending/locked amounts
  • Task: Tasks with options and reward amounts
  • Option: Individual choices for each task
  • Submission: Worker responses to tasks
  • Payouts: Payment transaction records

🐳 Docker Deployment

Production Deployment

# Build and start all services
docker-compose -f docker-compose.prod.yml up -d

# Monitor logs
docker-compose logs -f

Development with Docker

# Start development environment
docker-compose -f docker-compose.dev.yml up -d

πŸ” API Endpoints

User Endpoints (/v1/user)

  • POST /tasks - Create new task
  • GET /tasks/:id - Get task details
  • GET /tasks - List user's tasks

Worker Endpoints (/v1/worker)

  • GET /tasks - Get available tasks
  • POST /submit - Submit task completion
  • GET /balance - Get worker balance
  • POST /payout - Request payout

🀝 Contributing

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

πŸ”„ Development Workflow

  1. Local Development: Use npm run dev for hot reloading
  2. Testing: Run tests with npm test
  3. Database Migrations: Use npx prisma migrate dev
  4. Production Build: Use npm run build

πŸ“ˆ Monitoring

  • Application Logs: Check Docker logs for each service
  • Database Health: Monitor PostgreSQL connection and performance
  • Blockchain Transactions: Track Solana transaction status
  • API Performance: Monitor response times and error rates

Built with ❀️ using Solana, Next.js, and TypeScript

About

A decentralized app where users can upload thumbnails, and the community determines the 'most clickable' thumbnail. Workers can click on thumbnails to earn rewards, creating an incentivized system.Powered by blockchain, the app ensures transparency, community-driven content ranking, and user rewards

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published