Skip to content

RozoAI/rozo-rewards-miniapp

Repository files navigation

Rozo Rewards MiniApp

A Base MiniApp for AI promo and cashback platform with ROZO token rewards system

🎯 Overview

The Rozo Rewards MiniApp is a comprehensive AI promo and cashback platform that allows users to:

  • Earn ROZO tokens from purchases at AI services and merchants
  • Use ROZO tokens to reduce payment amounts (1 ROZO = $0.01 USD)
  • Shop with savings through a complete order management system
  • Enjoy tier-based benefits with increasing cashback multipliers

Screenshots

Discovery Lifestyle Profile
image image image

✨ Key Features

πŸͺ™ ROZO Token System

  • 100:1 Conversion: 1 ROZO = $0.01 USD
  • Payment Offset: Use ROZO to reduce actual payment amounts
  • Tier Multipliers: Bronze (1x) β†’ Silver (1.2x) β†’ Gold (1.5x) β†’ Platinum (2x)

πŸ›’ Complete Shopping Experience

  • Shopping Cart: Add multiple products with individual cashback rates
  • Order Management: Full lifecycle from cart to completion
  • ROZO Integration: Apply tokens during checkout for instant savings

πŸͺ Merchant & Product System

  • AI Services: OpenRouter, Civitai, Venice AI, and more
  • Product SKUs: Individual cashback rates per product
  • Dynamic Rates: Product-specific rates override merchant defaults

πŸ’³ Seamless Payments

  • Crypto Payments: Via RozoPayButton integration
  • Multi-Chain Support: Ethereum, Base, Polygon, Optimism, Arbitrum
  • Automatic Cashback: Earn ROZO tokens on every confirmed purchase

πŸš€ Example Use Case

Scenario: User buys $50 worth of AI services

  1. Products: 2 items with different cashback rates (5% and 8%)
  2. ROZO Offset: Use 2000 ROZO ($20) to reduce payment
  3. Final Payment: Pay only $30 instead of $50
  4. Cashback Earned: 340 ROZO ($3.40) from the purchase
  5. Net Result: Saved $16.60 (33.2% effective discount!)

πŸ—οΈ Architecture

Frontend (Next.js 15)

  • Coinbase OnchainKit: Wallet integration
  • TailwindCSS: Modern UI styling
  • TypeScript: Type-safe development
  • React Query: State management and caching

Backend (Supabase)

  • PostgreSQL: Robust database with ACID compliance
  • Edge Functions: Serverless API endpoints (Deno runtime)
  • Row Level Security: Data protection and access control
  • Real-time: Live updates for transactions and balances

Blockchain Integration

  • Multi-chain Support: 5+ supported networks
  • Transaction Verification: On-chain verification for security
  • Gas Optimization: Efficient transaction processing

πŸ“ Project Structure

rozo-rewards-miniapp/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                 # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ ai-services/     # AI services catalog page
β”‚   β”‚   β”œβ”€β”€ restaurant/      # Restaurant/merchant pages
β”‚   β”‚   └── profile/         # User profile management
β”‚   β”œβ”€β”€ components/          # React components
β”‚   β”‚   β”œβ”€β”€ ui/             # Reusable UI components
β”‚   β”‚   └── *-list-view.tsx # Feature-specific components
β”‚   └── providers/          # Context providers
β”œβ”€β”€ supabase/
β”‚   β”œβ”€β”€ migrations/         # Database schema migrations
β”‚   └── functions/          # Edge functions (API)
β”‚       β”œβ”€β”€ auth/           # Authentication endpoints
β”‚       β”œβ”€β”€ cashback/       # ROZO cashback system
β”‚       β”œβ”€β”€ orders/         # Order management
β”‚       β”œβ”€β”€ products/       # Product catalog
β”‚       β”œβ”€β”€ merchants/      # Merchant management
β”‚       └── _shared/        # Shared utilities and types
β”œβ”€β”€ docs/                   # Comprehensive API documentation
β”‚   β”œβ”€β”€ API.md             # Main API documentation
β”‚   β”œβ”€β”€ ROZO_CASHBACK_API.md
β”‚   β”œβ”€β”€ ORDER_MANAGEMENT_API.md
β”‚   β”œβ”€β”€ TECHNICAL_SPEC.md
β”‚   └── openapi.yaml       # OpenAPI specification
└── public/                # Static assets

πŸ› οΈ Tech Stack

Core Technologies

  • Next.js 15 - React framework with App Router
  • TypeScript - Type-safe development
  • Supabase - Backend-as-a-Service with PostgreSQL
  • TailwindCSS - Utility-first CSS framework
  • Viem/Wagmi - Ethereum development framework

Blockchain & Payments

  • Coinbase OnchainKit - Wallet integration
  • RozoPayButton - Custom payment component
  • Multi-chain Support - Ethereum, Base, Polygon, Optimism, Arbitrum

Development Tools

  • ESLint - Code linting
  • Lefthook - Git hooks for quality checks
  • pnpm - Fast package manager

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • pnpm (recommended)
  • Docker (for local Supabase)

Installation

  1. Clone the repository

    git clone https://github.com/your-org/rozo-rewards-miniapp.git
    cd rozo-rewards-miniapp
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    cp example.env .env.local
    # Edit .env.local with your configuration
  4. Start local Supabase (optional)

    supabase start
  5. Run database migrations

    supabase db reset
  6. Start the development server

    pnpm dev
  7. Open your browser Navigate to http://localhost:3000

πŸ“š API Documentation

πŸš€ Getting Started - New Developers Start Here!

πŸ“– Comprehensive Documentation

πŸ§ͺ Testing & Development

Key API Endpoints

ROZO Cashback System

  • GET /cashback/balance - Get ROZO balance
  • POST /cashback/apply-offset - Calculate payment offset
  • POST /cashback/claim - Claim cashback from purchases

Order Management

  • GET /orders/cart - Get shopping cart
  • POST /orders/cart - Add items to cart
  • POST /orders/checkout - Proceed to checkout
  • GET /orders - List user orders

Product Catalog

  • GET /products - List products with cashback rates
  • GET /products/{id} - Get product details
  • GET /merchants - List merchants and services

πŸ”§ Configuration

Environment Variables

# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

# Optional: Intercom Integration
INTERCOM_APP_ID=your-intercom-app-id

Supabase Setup

  1. Create a new Supabase project
  2. Run the provided migrations
  3. Configure authentication providers
  4. Deploy edge functions

πŸ§ͺ Testing

Run Tests

# Unit tests
pnpm test

# E2E tests
pnpm test:e2e

# Lint code
pnpm lint

Test Order Flow

  1. Add products to cart
  2. Apply ROZO offset during checkout
  3. Complete payment with crypto
  4. Verify cashback earning

πŸ“Š Database Schema

The application uses a comprehensive PostgreSQL schema with:

  • Users & Profiles - User management with ROZO balances
  • Merchants & Products - Catalog with individual cashback rates
  • Orders & Order Items - Complete shopping cart system
  • Cashback Records - ROZO token transactions
  • Transactions - Blockchain payment records

Key tables:

  • profiles - User profiles with ROZO balances
  • merchants - AI services and merchant catalog
  • products - SKUs with individual cashback rates
  • orders - Shopping cart and order management
  • order_items - Individual products in orders
  • cashback - ROZO token earning and usage records
  • transactions - Blockchain payment confirmations

πŸ”„ Order Lifecycle

Cart β†’ Pending β†’ Paid β†’ Completed
 ↓       ↓        ↓       ↓
Abandoned  Cancelled  Refunded  Cashback Available

🎯 User Tiers & Benefits

Tier Requirement Multiplier Example Benefit
Bronze $0+ earned 1.0x 5% β†’ 5% cashback
Silver $500+ earned 1.2x 5% β†’ 6% cashback
Gold $2,500+ earned 1.5x 5% β†’ 7.5% cashback
Platinum $10,000+ earned 2.0x 5% β†’ 10% cashback

🚒 Deployment

Vercel (Recommended)

  1. Connect your GitHub repository to Vercel
  2. Configure environment variables
  3. Deploy automatically on push

Manual Deployment

# Build the application
pnpm build

# Start production server
pnpm start

Supabase Edge Functions

# Deploy all functions
supabase functions deploy

# Deploy specific function
supabase functions deploy cashback-balance

🀝 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

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Links

πŸ†˜ Support

For support and questions:


Built with ❀️ by the Rozo AI Team

About

Rozo Rewards - Shop and Earn Cashback

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5