Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔮 Polymarket Clone - Solana Web3 Prediction Market

A high-performance, decentralized prediction market platform built using a modern TypeScript monorepo architecture. Users can connect their Solana wallet (Solflare), onramp mock USD, split/merge positions, and trade on live prediction markets with automated orderbook matching.


📷 Application Preview

1. Welcome & Wallet Sign In

Users are greeted with a premium dark-mode interface prompting them to sign in using their Solana wallet. Landing Page

2. Secure Web3 Authentication

Authentication is handled via a secure cryptographic message signature using the Solflare wallet. Solflare Authentication

3. Active Prediction Markets

Once authenticated, users can browse and trade live prediction markets. This page displays active order count and quick action buttons for YES/NO positions. Prediction Markets

4. Mock USD Onramp & Offramp

Simulate deposition and withdrawal of funds to trade inside the markets. Balance Management


🛠️ Architecture & Monorepo Structure

This project is structured as a Turborepo monorepo using Bun workspaces for blazing-fast builds and dependency management.

├── apps/
│   ├── frontend/      # Vite + React (TypeScript) SPA Client
│   └── backend/       # Express server handling matching engine logic & endpoints
├── packages/
│   ├── db/            # Database package containing Prisma Client & Schema
│   ├── ui/            # Shared React UI components
│   ├── eslint-config/ # Global ESLint rules
│   └── typescript-config/ # Global tsconfig rules

💻 Tech Stack

  • Frontend: React 19, Vite, TypeScript, Vanilla CSS (Premium Dark Mode)
  • Backend: Express, TypeScript, Bun runtime
  • Database: PostgreSQL, Prisma ORM, @prisma/adapter-pg
  • Authentication: Solana Web3 Auth via Supabase Custom Claims
  • Build System: Turborepo, Bun Workspaces

🚀 Getting Started

📋 Prerequisites

⚙️ Local Setup Instructions

  1. Clone the repository:

    git clone <your-repo-url>
    cd prediction-market-yt
  2. Install Dependencies:

    bun install
  3. Start the Local Database: Make sure Docker Desktop is open, then start your local PostgreSQL container (or configure your own postgres connection string in packages/db/.env and apps/backend/.env).

  4. Sync Schema and Seed Data: Migrate the database schema to your local Postgres instance:

    # In packages/db
    bun x prisma db push
    bun x prisma generate

    Seed the database with sample prediction markets:

    bun run seed.ts
  5. Start the Development Servers: From the project root, start both the frontend and backend servers simultaneously:

    bun run dev
    • Frontend Application: http://localhost:5173
    • Backend API: http://localhost:3000

🌐 Production Deployment Guide

💾 1. Hosted Database

Extract your PostgreSQL connection string from your hosted provider (e.g., Supabase or Neon). Use the Transaction Pooler connection string (usually port 6543) for production services.

Run migrations and seed the live database:

DATABASE_URL="your-production-connection-string" bun --filter=db exec prisma db push
DATABASE_URL="your-production-connection-string" bun --filter=db run seed.ts

🧠 2. Express Backend

Deploy apps/backend to Railway, Render, or Fly.io:

  • Build Command: bun install
  • Start Command: bun run index.ts
  • Environment Variables:
    • DATABASE_URL: (Your production database connection string)
    • SUPABASE_SECRET_KEY: (Your Supabase service key)

🎨 3. Vite Frontend

Deploy apps/frontend to Vercel or Netlify:

  • Root Directory: apps/frontend
  • Build Command: npm run build (or bun run build)
  • Output Directory: dist
  • Environment Variables:
    • VITE_API_URL: (Your hosted backend URL)

About

A decentralized prediction market platform inspired by Polymarket. Built with Bun, TurboRepo, TypeScript, React, Node.js, and modern Web3 technologies

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages