Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EcoPlay β€” Recycling Incentive Network

A blockchain-powered recycling coordination system that uses Stellar micro-payments to incentivize real-world environmental action, connecting collectors, agents, and recycling companies in a transparent and scalable ecosystem.


What Is EcoPlay?

EcoPlay is a 3-sided platform that sits between people who collect recyclable waste, agents who verify and aggregate it, and recycling companies who buy it. Instead of recycling being a thankless act, EcoPlay turns it into an income stream β€” every verified drop-off triggers an instant Stellar payment split between the collector and the agent, with a small platform fee retained.

This model works because Stellar transactions are:

  • Near-instant (3–5 seconds)
  • Extremely low cost (fractions of a cent)
  • Transparent and auditable on-chain

Traditional banking cannot support this kind of high-frequency, low-value payout model. Stellar can.


The Three Actors

πŸ‘€ Collectors

Individuals who gather recyclable materials (plastic, metal, glass, paper, electronics) and bring them to a registered collection point. They earn a direct cut of the material's market value, paid instantly to their Stellar wallet.

🏒 Collection Agents

Verified operators who run physical collection points. They weigh incoming materials, log submissions into the EcoPlay system, and earn a commission on every submission they process. Agents are the trust layer β€” only verified agents can create submissions.

🏭 Recycling Companies

Companies that purchase aggregated recyclable materials from the platform. Their bulk payments fund the reward pool that gets distributed to collectors and agents.


End-to-End Flow

1. Collector brings recyclables to a collection point

2. Agent weighs the materials and logs a submission:
      - Collector ID
      - Material type (plastic / metal / glass / paper / electronics)
      - Weight (kg)
      - Optional proof photo

3. Backend calculates reward split based on:
      - Material base price (per kg)
      - Configured split percentages

4. Single Stellar transaction is built with 2 payment operations:
      β†’ 60% to collector's Stellar wallet
      β†’ 30% to agent's Stellar wallet
      β†’ 10% retained by platform wallet

5. Submission is marked Paid, collector and agent stats are updated

6. Collector sees earnings update in real time on their dashboard

Payment Logic

Recipient Default Split
Collector 60%
Agent 30%
Platform 10%

Splits are configurable via environment variables. All percentages must sum to 100.

Material base prices (USD/kg):

Material Price/kg
Plastic $0.15
Metal $0.45
Glass $0.08
Paper $0.06
Electronics $1.20

Example: Agent logs 10kg of metal for a collector.

  • Total value: 10 Γ— $0.45 = $4.50
  • Collector receives: $2.70
  • Agent receives: $1.35
  • Platform retains: $0.45

Gamification Layer

Engagement is sustained through a lightweight gamification system built on top of the economic core:

  • Leaderboards β€” top collectors ranked by total earnings and weight recycled
  • Weekly challenges β€” bonus rewards for hitting weight targets
  • Badges β€” Eco Hero, Top Agent, First Drop-off, and more
  • Progress tracking β€” lifetime stats visible on every collector's profile

Gamification is secondary. The economic incentive is the primary driver.


Trust & Verification

Fraud prevention is built into the system architecture:

  • Only verified agents can log submissions β€” collectors cannot self-report
  • Every submission, payment, and status change is recorded with a full audit trail
  • Optional proof photo upload per submission
  • All Stellar transactions are publicly verifiable on-chain
  • Future: GPS tagging of collection points, AI-assisted weight verification

Tech Stack

Layer Technology
Backend Rust (Axum, SQLx, Tokio)
Database PostgreSQL
Payments Stellar (Horizon REST API)
Collector App Next.js 14, Tailwind CSS
Agent Dashboard Next.js 14, Tailwind CSS
Auth JWT (bcrypt + jsonwebtoken)
Infrastructure Docker Compose

Project Structure

EcoPlay/
β”‚
β”œβ”€β”€ backend/                          # Rust API server
β”‚   β”œβ”€β”€ Cargo.toml                    # Dependencies: axum, sqlx, tokio, bcrypt, jwt, reqwest
β”‚   └── src/
β”‚       β”œβ”€β”€ main.rs                   # Entry point β€” boots Axum server, connects DB
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   └── mod.rs                # Typed config loaded from environment variables
β”‚       β”œβ”€β”€ errors/
β”‚       β”‚   └── mod.rs                # AppError enum β†’ HTTP response mapping
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   β”œβ”€β”€ mod.rs
β”‚       β”‚   β”œβ”€β”€ user.rs               # User struct (collector) β€” maps to users table
β”‚       β”‚   β”œβ”€β”€ agent.rs              # Agent struct β€” maps to agents table
β”‚       β”‚   β”œβ”€β”€ submission.rs         # Submission struct + MaterialType + SubmissionStatus enums
β”‚       β”‚   └── transaction.rs        # Transaction struct + TransactionType enum
β”‚       β”œβ”€β”€ db/
β”‚       β”‚   β”œβ”€β”€ mod.rs                # create_pool() β†’ PgPool
β”‚       β”‚   β”œβ”€β”€ migrations/
β”‚       β”‚   β”‚   β”œβ”€β”€ 001_create_users.sql
β”‚       β”‚   β”‚   β”œβ”€β”€ 002_create_agents.sql
β”‚       β”‚   β”‚   β”œβ”€β”€ 003_create_submissions.sql
β”‚       β”‚   β”‚   └── 004_create_transactions.sql
β”‚       β”‚   └── queries/
β”‚       β”‚       β”œβ”€β”€ mod.rs
β”‚       β”‚       β”œβ”€β”€ users.rs          # find_by_id, find_by_email, insert, increment_stats, update_wallet
β”‚       β”‚       β”œβ”€β”€ agents.rs         # find_by_id, find_by_email, insert, increment_commission
β”‚       β”‚       β”œβ”€β”€ submissions.rs    # insert, find_by_id, find_by_collector, find_by_agent, update_status
β”‚       β”‚       β”œβ”€β”€ transactions.rs   # insert, find_by_submission
β”‚       β”‚       └── leaderboard.rs    # top_collectors(limit) ORDER BY total_earned DESC
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   β”œβ”€β”€ mod.rs
β”‚       β”‚   β”œβ”€β”€ auth/
β”‚       β”‚   β”‚   └── mod.rs            # register_collector, login_collector, login_agent β†’ JWT
β”‚       β”‚   β”œβ”€β”€ rewards/
β”‚       β”‚   β”‚   └── mod.rs            # calculate(material, weight_kg) β†’ RewardSplit
β”‚       β”‚   β”œβ”€β”€ payments/
β”‚       β”‚   β”‚   └── mod.rs            # send_payouts(recipients) β†’ builds + submits Stellar tx
β”‚       β”‚   β”œβ”€β”€ submissions/
β”‚       β”‚   β”‚   └── mod.rs            # create() β€” full orchestration: validate β†’ calculate β†’ pay β†’ record
β”‚       β”‚   └── leaderboard/
β”‚       β”‚       └── mod.rs            # top_collectors(limit) β†’ Vec<LeaderboardEntry>
β”‚       β”œβ”€β”€ stellar/
β”‚       β”‚   └── mod.rs                # Low-level Horizon HTTP client: load_account, build_tx, submit_tx
β”‚       └── api/
β”‚           β”œβ”€β”€ mod.rs                # router() β€” mounts all route groups under /api/v1
β”‚           β”œβ”€β”€ middleware/
β”‚           β”‚   └── mod.rs            # JWT extractor β†’ injects Claims { sub, email, role }
β”‚           β”œβ”€β”€ routes/
β”‚           β”‚   └── mod.rs            # All route definitions with method + path + handler mapping
β”‚           └── handlers/
β”‚               β”œβ”€β”€ mod.rs
β”‚               β”œβ”€β”€ auth.rs           # POST /auth/register, /auth/login, /auth/agent/login
β”‚               β”œβ”€β”€ users.rs          # GET /users/me, PATCH /users/me/wallet
β”‚               β”œβ”€β”€ submissions.rs    # POST /submissions, GET /submissions, GET /submissions/my
β”‚               β”œβ”€β”€ leaderboard.rs    # GET /leaderboard
β”‚               └── payments.rs       # GET /payments/history
β”‚
β”œβ”€β”€ apps/
β”‚   β”‚
β”‚   β”œβ”€β”€ web/                          # Collector-facing app (port 3000)
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   β”œβ”€β”€ next.config.ts
β”‚   β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”‚   β”œβ”€β”€ tailwind.config.ts
β”‚   β”‚   β”œβ”€β”€ postcss.config.js
β”‚   β”‚   β”œβ”€β”€ .env.local
β”‚   β”‚   └── src/
β”‚   β”‚       β”œβ”€β”€ app/
β”‚   β”‚       β”‚   β”œβ”€β”€ layout.tsx        # Root layout β€” fonts, providers, global styles
β”‚   β”‚       β”‚   β”œβ”€β”€ page.tsx          # Landing / redirect to dashboard or login
β”‚   β”‚       β”‚   β”œβ”€β”€ globals.css
β”‚   β”‚       β”‚   β”œβ”€β”€ auth/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ login/page.tsx
β”‚   β”‚       β”‚   β”‚   └── register/page.tsx
β”‚   β”‚       β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ layout.tsx    # Dashboard shell with Navbar
β”‚   β”‚       β”‚   β”‚   └── page.tsx      # Earnings summary, recent submissions
β”‚   β”‚       β”‚   β”œβ”€β”€ leaderboard/
β”‚   β”‚       β”‚   β”‚   └── page.tsx      # Top collectors ranked by earnings
β”‚   β”‚       β”‚   └── profile/
β”‚   β”‚       β”‚       └── page.tsx      # Wallet linking, lifetime stats, badges
β”‚   β”‚       β”œβ”€β”€ components/
β”‚   β”‚       β”‚   β”œβ”€β”€ ui/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ Card.tsx
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ Badge.tsx
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ Input.tsx
β”‚   β”‚       β”‚   β”‚   └── Spinner.tsx
β”‚   β”‚       β”‚   β”œβ”€β”€ shared/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ Layout.tsx
β”‚   β”‚       β”‚   β”‚   └── ProtectedRoute.tsx
β”‚   β”‚       β”‚   └── forms/
β”‚   β”‚       β”‚       β”œβ”€β”€ LoginForm.tsx
β”‚   β”‚       β”‚       └── RegisterForm.tsx
β”‚   β”‚       β”œβ”€β”€ lib/
β”‚   β”‚       β”‚   β”œβ”€β”€ api/
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ client.ts     # Axios instance with base URL + auth header injection
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ auth.ts       # register(), login()
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ submissions.ts # getMySubmissions()
β”‚   β”‚       β”‚   β”‚   β”œβ”€β”€ leaderboard.ts # getLeaderboard()
β”‚   β”‚       β”‚   β”‚   └── users.ts      # getMe(), linkWallet()
β”‚   β”‚       β”‚   β”œβ”€β”€ stellar/
β”‚   β”‚       β”‚   β”‚   └── wallet.ts     # Stellar wallet helpers (keypair generation, validation)
β”‚   β”‚       β”‚   └── utils/
β”‚   β”‚       β”‚       └── format.ts     # Currency, weight, date formatters
β”‚   β”‚       β”œβ”€β”€ hooks/
β”‚   β”‚       β”‚   β”œβ”€β”€ useAuth.ts        # Login, register, logout, current user
β”‚   β”‚       β”‚   β”œβ”€β”€ useSubmissions.ts # Fetch collector's submission history
β”‚   β”‚       β”‚   β”œβ”€β”€ useLeaderboard.ts # Fetch leaderboard data
β”‚   β”‚       β”‚   └── useProfile.ts     # Fetch + update profile, link wallet
β”‚   β”‚       β”œβ”€β”€ store/
β”‚   β”‚       β”‚   └── authStore.ts      # Zustand β€” stores JWT token + user object
β”‚   β”‚       └── types/
β”‚   β”‚           β”œβ”€β”€ index.ts          # Re-exports all types
β”‚   β”‚           └── api.ts            # User, Submission, Transaction, LeaderboardEntry types
β”‚   β”‚
β”‚   └── agent-dashboard/              # Agent-facing app (port 3001)
β”‚       β”œβ”€β”€ package.json
β”‚       β”œβ”€β”€ next.config.ts
β”‚       β”œβ”€β”€ tsconfig.json
β”‚       β”œβ”€β”€ tailwind.config.ts
β”‚       β”œβ”€β”€ postcss.config.js
β”‚       β”œβ”€β”€ .env.local
β”‚       └── src/
β”‚           β”œβ”€β”€ app/
β”‚           β”‚   β”œβ”€β”€ layout.tsx        # Root layout
β”‚           β”‚   β”œβ”€β”€ page.tsx          # Redirect to dashboard or login
β”‚           β”‚   β”œβ”€β”€ globals.css
β”‚           β”‚   β”œβ”€β”€ auth/
β”‚           β”‚   β”‚   └── login/page.tsx
β”‚           β”‚   β”œβ”€β”€ dashboard/
β”‚           β”‚   β”‚   β”œβ”€β”€ layout.tsx    # Dashboard shell with Navbar
β”‚           β”‚   β”‚   └── page.tsx      # Stats: total submissions, total commission earned
β”‚           β”‚   β”œβ”€β”€ submissions/
β”‚           β”‚   β”‚   β”œβ”€β”€ page.tsx      # List of agent's submissions
β”‚           β”‚   β”‚   └── new/page.tsx  # New submission form (weigh + assign to collector)
β”‚           β”‚   └── history/
β”‚           β”‚       └── page.tsx      # Full submission history with filters
β”‚           β”œβ”€β”€ components/
β”‚           β”‚   β”œβ”€β”€ ui/
β”‚           β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚           β”‚   β”‚   β”œβ”€β”€ Card.tsx
β”‚           β”‚   β”‚   β”œβ”€β”€ Input.tsx
β”‚           β”‚   β”‚   β”œβ”€β”€ Badge.tsx
β”‚           β”‚   β”‚   └── Spinner.tsx
β”‚           β”‚   β”œβ”€β”€ shared/
β”‚           β”‚   β”‚   β”œβ”€β”€ Navbar.tsx
β”‚           β”‚   β”‚   β”œβ”€β”€ Layout.tsx
β”‚           β”‚   β”‚   └── ProtectedRoute.tsx
β”‚           β”‚   └── forms/
β”‚           β”‚       β”œβ”€β”€ SubmissionForm.tsx  # Core form: collector ID, material, weight, photo
β”‚           β”‚       └── LoginForm.tsx
β”‚           β”œβ”€β”€ lib/
β”‚           β”‚   β”œβ”€β”€ api/
β”‚           β”‚   β”‚   β”œβ”€β”€ client.ts     # Axios instance
β”‚           β”‚   β”‚   β”œβ”€β”€ auth.ts       # agentLogin()
β”‚           β”‚   β”‚   └── submissions.ts # createSubmission(), getAgentSubmissions()
β”‚           β”‚   └── utils/
β”‚           β”‚       └── format.ts     # Formatters
β”‚           β”œβ”€β”€ hooks/
β”‚           β”‚   β”œβ”€β”€ useAuth.ts        # Agent login, logout, session
β”‚           β”‚   └── useSubmissions.ts # Create + fetch submissions
β”‚           β”œβ”€β”€ store/
β”‚           β”‚   └── authStore.ts      # Zustand β€” agent JWT + agent object
β”‚           └── types/
β”‚               β”œβ”€β”€ index.ts
β”‚               └── api.ts            # Agent, Submission, Transaction types
β”‚
β”œβ”€β”€ infrastructure/
β”‚   β”œβ”€β”€ docker/
β”‚   β”‚   β”œβ”€β”€ docker-compose.yml        # Full local stack: postgres + backend + web + agent-dashboard
β”‚   β”‚   β”œβ”€β”€ Dockerfile.backend        # Multi-stage Rust build β†’ minimal debian image
β”‚   β”‚   └── Dockerfile.web            # Next.js build β†’ production image
β”‚   β”œβ”€β”€ nginx/                        # Reverse proxy config for production
β”‚   └── scripts/                      # DB seed scripts, deploy helpers
β”‚
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ api/                          # API endpoint documentation
β”‚   β”œβ”€β”€ architecture/                 # System design diagrams
β”‚   └── flows/                        # End-to-end flow diagrams
β”‚
β”œβ”€β”€ .env.example                      # All required environment variables documented
β”œβ”€β”€ .gitignore
└── README.md

API Endpoints

Method Path Auth Description
POST /api/v1/auth/register β€” Register a new collector
POST /api/v1/auth/login β€” Collector login β†’ JWT
POST /api/v1/auth/agent/login β€” Agent login β†’ JWT
GET /api/v1/users/me JWT Get current collector profile
PATCH /api/v1/users/me/wallet JWT Link Stellar wallet
POST /api/v1/submissions JWT (agent) Log a new submission + trigger payout
GET /api/v1/submissions JWT (agent) Agent's own submission history
GET /api/v1/submissions/my JWT (collector) Collector's own submission history
GET /api/v1/leaderboard β€” Top collectors by earnings
GET /api/v1/payments/history JWT Payment transaction history

Database Schema

users β€” collectors registered on the platform agents β€” verified collection point operators submissions β€” every material drop-off event, linked to a collector and agent transactions β€” every Stellar payment attempt, success or failure, linked to a submission


Getting Started

# 1. Copy and fill environment variables
cp .env.example .env

# 2. Start Postgres
docker compose -f infrastructure/docker/docker-compose.yml up postgres -d

# 3. Run the Rust backend
cd backend && cargo run

# 4. Run the collector app
cd apps/web && npm install && npm run dev

# 5. Run the agent dashboard
cd apps/agent-dashboard && npm install && npm run dev

MVP Scope

  • Project structure
  • Rust backend β€” auth, submissions, rewards, Stellar payouts
  • Collector app β€” register, dashboard, leaderboard, profile
  • Agent dashboard β€” submission form, history
  • Docker Compose full stack

Economic Model

Revenue sources:

  • 10% platform fee on every submission payout
  • Future: recycling company partnership fees, NGO grants, sponsor integrations

Why this is fundable:

  • Directly addresses waste management in underserved regions
  • Creates income for low-income collectors
  • Fully transparent payment trail on Stellar blockchain
  • Measurable environmental impact (kg recycled, COβ‚‚ offset)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages