Skip to content

polyjuicelab/polyjuice

Repository files navigation

Polyjuice

Polyjuice Logo

Discover & Chat with Farcaster Users

Deploy Status Live Demo Built with Rust WebAssembly

🎯 Overview

Polyjuice is a beautiful, modern web application that provides a search engine-like interface for discovering and interacting with Farcaster users. Built with Rust and WebAssembly, it offers lightning-fast performance and a seamless user experience.

✨ Key Features

  • πŸ” Smart Search: Search users by FID or username with instant results
  • πŸ’¬ AI Chat: Interactive chat sessions with users powered by SnapRAG
  • πŸ“Š Social Analytics: Deep insights into user behavior and social circles
  • πŸ’³ Web3 Payments: Integrated x402 payment system for premium features
  • πŸ“± Responsive Design: Perfect experience on desktop and mobile
  • ⚑ Lightning Fast: Built with Rust WebAssembly for optimal performance
  • 🎨 Modern UI: Clean, Google-inspired interface with smooth animations

πŸš€ Live Demo

Visit polyjuice.0xbase.ai to try Polyjuice right now!

πŸ› οΈ Technology Stack

  • Frontend: Yew (Rust WebAssembly framework)
  • Build Tool: Trunk
  • Styling: Pure CSS with modern design principles
  • API: RESTful integration with SnapRAG backend
  • Payments: x402 protocol for Web3 payments
  • Deployment: GitHub Pages with GitHub Actions

πŸ“– How to Use

Basic Search

  1. Enter a FID: Type any Farcaster ID (e.g., 1, 2, 3, 100, 1000) in the search box
  2. Search: Click the search button or press Enter
  3. View Results: See detailed user information including:
    • Profile picture and display name
    • Username and FID
    • Bio/description
    • Social analytics and influence scores
    • Social circles and interaction patterns

AI Chat

  1. Search for a user to load their profile
  2. Click the chat button πŸ’­ to start an AI-powered conversation
  3. Ask questions about the user's activity, interests, or opinions
  4. Get contextual responses based on their Farcaster history

Web3 Payments

  1. Connect MetaMask wallet for premium features
  2. Automatic payment prompts for paid API calls
  3. Secure EIP-712 signatures for payment authorization
  4. Transparent pricing with x402 protocol

πŸ—οΈ Development

Prerequisites

  • Rust (nightly toolchain)
  • Trunk (Rust WASM build tool)
  • Node.js (for JavaScript wallet integration)

Quick Start

  1. Clone the repository:
git clone https://github.com/RyanKung/polyjuice.git
cd polyjuice
  1. Install Trunk:
cargo install trunk
  1. Start development server:
make serve
  1. Open your browser to http://localhost:8080

Available Commands

# Development
make serve          # Start dev server on port 8080
make serve-dev      # Start dev server on port 8081
make watch          # Watch for changes and rebuild

# Building
make build          # Build WebAssembly application
make build-prod     # Build for production
make build-deploy   # Build for deployment (uses snaprag.0xbase.ai)

# Code Quality
make check          # Check code without building
make fmt            # Format code
make clippy         # Run clippy linter

# Deployment
make deploy         # Deploy to GitHub Pages
make clean          # Clean build artifacts
make help           # Show all commands

Environment Configuration

Configure the API server URL using one of two methods:

Method 1: Build-Time Environment Variable

Set environment variable during build:

# Development with custom API URL
SNAPRAG_API_URL=http://192.168.1.100:3000 make serve

# Production build with custom API URL
SNAPRAG_API_URL=https://api.yourdomain.com make build-prod

Method 2: .env File (Build-time)

  1. Create .env file (if it doesn't exist):
touch .env
  1. Edit .env to set your configuration:
SNAPRAG_API_URL=http://127.0.0.1:3000

# Optional: API Authentication
# Generate tokens using: snaprag auth generate --name your_token_name
AUTH_TOKEN=your_token_name
AUTH_SECRET=hex_encoded_secret_key_here
  1. Run:
make serve

Note: The .env file is automatically loaded when running make serve or make build-prod.

API Authentication

If your SnapRAG API server has authentication enabled, you can configure authentication tokens in the .env file:

  1. Generate a token on the server:
snaprag auth generate --name production_client
  1. Add to .env:
AUTH_TOKEN=production_client
AUTH_SECRET=a1b2c3d4e5f6...  # The hex-encoded secret from step 1
  1. Rebuild the application:
make serve  # or make build-prod

All API requests will automatically include authentication headers (X-Token, X-Timestamp, X-Signature) when these environment variables are set.

πŸš€ Deployment

Automatic Deployment

Polyjuice is automatically deployed to GitHub Pages at polyjuice.0xbase.ai when changes are pushed to the master branch.

Manual Deployment

# Deploy to production
make deploy

This will:

  1. Build the application with production API URL (https://snaprag.0xbase.ai/)
  2. Commit changes to git
  3. Push to master branch
  4. Trigger GitHub Actions deployment

GitHub Actions Workflow

The deployment process includes:

  • Rust + Trunk build with WASM optimization
  • Automatic API configuration for production
  • GitHub Pages deployment with custom domain
  • Caching for faster builds

πŸ”Œ API Integration

Polyjuice integrates with the SnapRAG API to fetch user data:

  • Base URL: https://snaprag.0xbase.ai/ (production)
  • Endpoints: Multiple RESTful endpoints for profiles, social data, and chat
  • Authentication: x402 payment protocol for premium features
  • Response Format: JSON with comprehensive user data

Supported Endpoints

  • /api/health - Health check
  • /api/profiles/{fid} - User profile data
  • /api/social/{fid} - Social analytics
  • /api/search/profiles - Semantic profile search
  • /api/search/casts - Semantic cast search
  • /api/rag/query - AI-powered RAG queries
  • /api/chat/create - Create chat sessions
  • /api/chat/message - Send chat messages

🎨 Design Philosophy

Polyjuice embodies modern web design principles:

  • Minimalism: Clean, uncluttered interface focusing on essential elements
  • Performance: Rust WebAssembly for lightning-fast user experience
  • Accessibility: Responsive design that works on all devices
  • User-Centric: Intuitive navigation and clear information hierarchy

πŸ“Š Example Usage

Try searching for these popular Farcaster users:

  • @vitalik.eth - Ethereum founder
  • @jesse.base.eth - Base protocol lead
  • @ryankung.base.eth - Developer and builder
  • FID 1, 2, 3 - Early Farcaster users

🀝 Contributing

We welcome contributions! Please ensure all code follows our standards:

  • Written in Rust with proper error handling
  • Fully documented with clear comments
  • Security-focused with input validation
  • Performance-optimized for WebAssembly

Development Guidelines

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

πŸ“„ License

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

πŸ”— Links

πŸ“ž Support


Built with ❀️ and Rust by the 0xbase.ai team

Part of the SnapRAG ecosystem

About

Front-end of polyjuice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages