Skip to content

polyhub-sol/polyhubai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

187 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PolyHubAI ๐Ÿš€

Who's smarter: the crowd or the model?

PolyHubAI is an AI-powered prediction market explorer that enables you to compare AI-generated probabilities with live Polymarket odds. Discover where artificial intelligence diverges from collective market wisdom in real-time.

Next.js TypeScript Tailwind CSS


โœจ Features

๐Ÿ” Market Intelligence

  • Live Market Data: Real-time market feeds from Polymarket Gamma API
  • AI Probability Analysis: GPT-powered forecasts that sum to 1.0 for every outcome
  • Edge Detection: Instantly spot where AI thinks the market is mispriced
  • Comparative Visualization: Side-by-side probability bars with smooth animations

๐ŸŽจ Polished Experience

  • Dark Trading UI: Professional, crypto-native interface with gradient accents
  • Animated Transitions: Smooth Framer Motion animations on cards and probability bars
  • Fast & Lightweight: Optimized Next.js 14 with server-side rendering

๐Ÿ›ก๏ธ Safe & Secure

  • Read-Only Interface: No wallet connections, no trading capabilities
  • Informational Only: Designed for research and analysis, not financial advice
  • Open Source: Transparent codebase you can audit and fork

๐Ÿš€ Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/polyhub-sol/polyhubai.git
    cd polyhubai
  2. Install dependencies

    npm install
  3. Configure environment variables

    Create a .env.local file in the project root:

    OPENAI_API_KEY=sk-your-openai-api-key-here
    OPENAI_MODEL=gpt-4o-mini

    Note: gpt-4o-mini is recommended for cost efficiency, but you can use gpt-4o for more accurate forecasts.

  4. Run the development server

    npm run dev
  5. Open your browser

    Navigate to http://localhost:3000


๐Ÿ“– Usage

Exploring Markets

  1. Browse Markets: Visit /markets to see live Polymarket questions sorted by volume
  2. Select a Market: Click any market card to view detailed analysis
  3. Compare Probabilities: See AI vs market probabilities side-by-side with animated bars
  4. Read AI Reasoning: Review the AI's explanation and bullet points for its forecast
  5. View on Polymarket: Click "Open on Polymarket" to see the original market

Understanding the Analysis

  • AI Probabilities: Structured forecasts generated by OpenAI that must sum to 1.0
  • Market Probabilities: Current implied probabilities from Polymarket trading activity
  • Edge: The difference (AI - Market) shows where the model sees opportunities
  • Reasoning: Natural language explanation of the AI's forecast logic

๐Ÿ—๏ธ Project Structure

polyhubai/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ””โ”€โ”€ markets/
โ”‚   โ”‚       โ”œโ”€โ”€ route.ts              # Markets list endpoint
โ”‚   โ”‚       โ””โ”€โ”€ [id]/
โ”‚   โ”‚           โ”œโ”€โ”€ route.ts          # Single market endpoint
โ”‚   โ”‚           โ””โ”€โ”€ ai/route.ts       # AI analysis endpoint
โ”‚   โ”œโ”€โ”€ markets/
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx                  # Markets listing page
โ”‚   โ”‚   โ””โ”€โ”€ [id]/
โ”‚   โ”‚       โ”œโ”€โ”€ page.tsx              # Market detail page
โ”‚   โ”‚       โ””โ”€โ”€ view.tsx              # Market detail client component
โ”‚   โ”œโ”€โ”€ agent-manager/
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                  # Agent manager (coming soon)
โ”‚   โ”œโ”€โ”€ layout.tsx                    # Root layout with navbar/footer
โ”‚   โ”œโ”€โ”€ page.tsx                      # Landing page
โ”‚   โ””โ”€โ”€ globals.css                   # Global styles
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ MarketCard.tsx                # Market card component
โ”‚   โ”œโ”€โ”€ AIResultPanel.tsx             # AI analysis display
โ”‚   โ”œโ”€โ”€ ProbabilityBars.tsx           # Animated probability comparison
โ”‚   โ””โ”€โ”€ ReasoningFeed.tsx             # AI reasoning display
โ”œโ”€โ”€ lib/
โ”‚   โ””โ”€โ”€ polymarket.ts                 # Polymarket Gamma API client
โ””โ”€โ”€ package.json

๐Ÿ› ๏ธ Tech Stack

Core Framework

UI & Animations

  • Framer Motion: Smooth animations and transitions
  • Custom dark theme with gradient accents and glow effects

AI & APIs

Development

  • ESLint: Code quality and consistency
  • PostCSS: CSS processing

๐ŸŽฏ How It Works

  1. Market Fetching: Server-side requests to Polymarket Gamma API fetch active markets
  2. Market Selection: User clicks a market to view detailed analysis
  3. AI Analysis: OpenAI receives market context and generates:
    • Probability distribution (must sum to 1.0)
    • Reasoning text
    • Bullet points
    • Optional sources
  4. Comparison Display: UI shows side-by-side comparison with animated probability bars
  5. Edge Calculation: System calculates edge = AI_probability - Market_probability for each outcome

๐Ÿ—บ๏ธ Roadmap

โœ… Phase 1: Current

  • Read-only AI vs market explorer
  • Live Polymarket Gamma integration
  • OpenAI-powered probability forecasts
  • Polished comparison UI

๐Ÿšง Phase 2: Coming Soon

  • Embedded wallets (account abstraction)
  • Basic strategy templates
  • User accounts and watchlists
  • Market alerts and notifications

๐Ÿ”ฎ Phase 3: Future

  • Agent-powered auto trading
  • Configurable trading playbooks
  • Risk controls and position limits
  • Detailed execution logs and P&L tracking

Note: Trading features are not yet live. Final features, jurisdictions, and integrations will depend on compliance and partner constraints.


๐Ÿ“ Environment Variables

Variable Description Required Default
OPENAI_API_KEY Your OpenAI API key โœ… Yes -
OPENAI_MODEL OpenAI model to use โŒ No gpt-4o-mini

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes: Keep commits small and focused
  4. Test thoroughly: Ensure no breaking changes
  5. Submit a pull request: Describe your changes clearly

Development Guidelines

  • Follow the existing code style
  • Add JSDoc comments for new functions
  • Keep components small and focused
  • Use TypeScript types everywhere
  • Test UI changes across screen sizes

๐Ÿ“„ License

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


โš ๏ธ Disclaimer

PolyHubAI is for informational and research purposes only.

  • This tool does not provide financial or betting advice
  • AI-generated probabilities may be inaccurate or outdated
  • Always verify data independently before making decisions
  • Trading on Polymarket is subject to their Terms of Service
  • Respect jurisdictional restrictions and local regulations

Use at your own risk. The authors are not responsible for any losses or damages.


๐Ÿ”— Links


๐Ÿ™ Acknowledgments

  • Polymarket for providing the Gamma API
  • OpenAI for GPT models
  • The open-source community for amazing tools

Built with โค๏ธ by the PolyHubAI team

From research terminal to auto-trading cockpit โ€” one commit at a time.

About

AI vs Market explorer for Polymarket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages