Skip to content

πŸ† ETHGlobal Cannes Finalist πŸ† A real-time πŸ“ˆ prediction market πŸ’° & livestream dashboard engagement πŸŽ₯ for hackathons. View live project demos, place on-chain predictions, & earn crypto rewards for accurate forecasts. All interactions are powered by smart contracts & decentralized video infrastructure. Created by Molly Beach, Ziz Khu, Joao Santos

Notifications You must be signed in to change notification settings

mollybeach/livestakes

Repository files navigation

LiveStakes πŸŽ₯πŸ’°

Real-time prediction markets for hackathon projects

🌐 www.livestakes.fun


πŸ‘€ Created by Molly Beach, Ziz Khu, and Joao Santos


1. Overview πŸ”

πŸ† ETHGlobal Cannes Finalist πŸ† A real-time πŸ“ˆ prediction market πŸ’° & livestream dashboard engagement πŸŽ₯ for hackathons. View live project demos, place on-chain predictions, & earn crypto rewards for accurate forecasts. All interactions are powered by smart contracts & decentralized video infrastructure. Created by Molly Beach, Ziz Khu, Joao Santos. LiveStakes is an open source platform that lets viewers watch every ETHGlobal hackathon project in real time and place on-chain predictions on which ones will win prizes. Teams broadcast live demos through WebRTC while the Hedera Agent Kit analyzes livestream environment and voice data to automatically create betting markets and predict winners using an automated market maker. When the AI makes final decisions, the Flow blockchain contracts settle and payout bettors instantly.

It contains the Next.js frontend, Flow smart contracts, Hedera Agent Kit integration, WebRTC streaming server, and infrastructure as code required to deploy the complete system.


2. Feature Highlights ✨

  • πŸŽ₯ Live project video streaming powered by WebRTC and Express server
  • πŸ€– AI-powered betting market creation using Hedera Agent Kit analysis
  • πŸŽ™οΈ Voice and environment data processing for automated winner prediction
  • πŸ“ˆ Dynamic prediction markets with CPMM pricing on Flow blockchain
  • πŸ’Ή Real-time odds adjustment based on AI insights
  • πŸ” Re-allocation of positions before AI makes final decisions
  • πŸ” Privy wallet authentication for seamless Web3 onboarding
  • πŸ“Š Real-time stats (bet volume, price movement, AI confidence scores) via PostgreSQL

3. Tech Stack πŸ› οΈ

Layer Technology
πŸ’» Frontend Next.js 14, React 18, TailwindCSS, shadcn/ui, Flow Client Library
πŸ“œ Smart contracts Cadence (Flow), Flow CLI, Flow Emulator
πŸ€– AI Decision Engine Hedera Agent Kit, Voice Analysis, Environment Processing
πŸŽ₯ Live Streaming WebRTC, Express.js, Socket.io
πŸ—‚οΈ Database PostgreSQL, Prisma ORM
🌐 Off-chain API Node 18 (Express), WebRTC signaling server
πŸ” Auth Privy (Wallet Connection), GitHub OAuth
πŸš€ DevOps Turborepo, GitHub Actions, Vercel, Flow Testnet

4. Architecture 🧠

flowchart TD
  FE[Next.js Frontend] <--> API[Express API]
  FE <--> WS[WebRTC Streaming]
  FE --> PV[Privy Auth]
  API --> DB[(PostgreSQL)]
  API --> FC[Flow Contracts]
  HAK[Hedera Agent Kit] --> API
  HAK --> WS
  WS --> VA[Voice Analysis]
  WS --> ED[Environment Detection]
  VA --> HAK
  ED --> HAK
  HAK --> BM[Bet Market Creation]
  HAK --> WP[Winner Prediction]
Loading

5. Repository Directory Structure πŸ“

livestakes/
β”œβ”€ apps/
β”‚  β”œβ”€ web/                 # Next.js frontend (App Router)
β”‚  └─ streaming-server/    # Express WebRTC signaling server
β”œβ”€ packages/
β”‚  β”œβ”€ contracts/           # Flow Cadence contracts and tests
β”‚  β”œβ”€ hedera-agent/        # Hedera Agent Kit integration and AI logic
β”‚  └─ ui/                  # Shared React component library (shadcn/ui wrappers)
β”œβ”€ infra/
β”‚  β”œβ”€ terraform/           # Vercel, PostgreSQL, Flow network resources
β”‚  └─ gh-actions/          # Reusable workflow templates
β”œβ”€ scripts/                # Helper scripts (deploy, seed, data-export)
β”œβ”€ docs/                   # Additional specs, diagrams, decision logs
β”œβ”€ .github/
β”‚  └─ workflows/           # CI pipelines: lint, test, contract size, AI model validation
β”œβ”€ turbo.json              # Turborepo pipeline config
β”œβ”€ flow.json               # Flow network configuration
└─ README.md               # You are here

Directory Details πŸ“¦

Path Purpose
apps/web 🌐 Public site and dashboard. Contains pages, components, hooks, and Flow blockchain integration.
apps/streaming-server πŸ“‘ Express server handling WebRTC signaling, Socket.io connections, and livestream management.
packages/contracts πŸ” Flow Cadence smart contracts, Flow CLI tests, and deployment scripts for prediction markets.
packages/hedera-agent πŸ€– Hedera Agent Kit integration for AI analysis, voice processing, and automated betting decisions.
packages/ui 🎨 Design-system primitives wrapped around shadcn/ui for consistent styling.
infra/terraform πŸ—οΈ Infrastructure definitions for Vercel projects, PostgreSQL database, and Flow network endpoints.
scripts βš™οΈ Type-scripted CLI utilities for project onboarding, market creation, and database seeding.

6. Getting Started πŸš€

6.1 Prerequisites βœ…

  • Node β‰₯ 18
  • pnpm β‰₯ 9
  • Flow CLI
  • Docker (for PostgreSQL)
  • PostgreSQL β‰₯ 14

6.2 Installation πŸ’Ύ

Standard installation process for Node.js monorepo with workspace dependencies, environment configuration, and Flow blockchain setup.

6.3 Makefile Commands πŸ› οΈ

The project includes a comprehensive Makefile with colored output and organized commands for all development tasks.

Quick Start Commands

make setup          # Install dependencies and start database
make dev           # Start all services in development mode
make help          # Show all available commands

Frontend Commands

make frontend-install    # Install frontend dependencies
make frontend-dev        # Start Next.js development server
make frontend-build      # Build frontend for production
make frontend-start      # Start frontend production server
make frontend-lint       # Lint frontend code

Blockchain Commands

make blockchain-compile           # Compile smart contracts
make blockchain-test             # Run blockchain tests
make blockchain-test-coverage    # Run tests with coverage
make blockchain-node             # Start local Hardhat node
make blockchain-clean            # Clean blockchain artifacts

# Deployment Commands
make deploy-local               # Deploy to local network
make deploy-sepolia            # Deploy to Sepolia testnet
make deploy-mainnet            # Deploy to Ethereum mainnet
make deploy-flow-testnet       # Deploy to Flow testnet
make deploy-flow-mainnet       # Deploy to Flow mainnet

Server Commands

make server-install     # Install server dependencies
make server-dev         # Start server in development mode
make server-dev-debug   # Start server in debug mode
make server-build       # Build server for production
make server-start       # Start server in production mode
make server-migrate     # Run database migrations

Docker Commands

make docker-dev         # Start development environment with Docker
make docker-prod        # Start production environment with Docker
make docker-build       # Build Docker images
make docker-clean       # Clean Docker containers and images

Database Commands

make db-start          # Start database container
make db-stop           # Stop database container
make db-reset          # Reset database (stop, remove volumes, start)

Testing Commands

make test              # Run all tests
make test-frontend     # Run frontend tests
make test-server       # Run server tests

Cleanup Commands

make clean             # Clean all build artifacts
make clean-all         # Clean everything including Docker

Combined Development Commands

make all-dev           # Start all services in development mode
make all-build         # Build all services for production
make all-start         # Start all services in production mode

6.4 Start All Services πŸ”§

Development environment includes PostgreSQL database, Flow emulator, Hedera Agent Kit AI service, WebRTC streaming server, and Next.js frontend all running concurrently through Turborepo.

Navigate to http://localhost:3000 to see LiveStakes in action.


7. Deployment 🚒

  • Frontend β€” pushed to main automatically deploys to Vercel preview. production branch triggers production promotion.
  • Streaming Server β€” deployed to Vercel as serverless functions with WebRTC support.
  • Contracts β€” tagged releases deploy against Flow Testnet, then Mainnet on manual approval.
  • Hedera Agent β€” AI service deployed to cloud infrastructure with voice processing capabilities.

8. Testing πŸ§ͺ

  • Unit β€” Flow testing for Cadence contracts, Vitest for TypeScript.
  • Integration β€” WebRTC streaming tests and AI prediction accuracy validation.
  • End-to-end β€” Playwright scripts simulating complete bettor and streaming flow.

Comprehensive testing suite covers all components from smart contracts to AI models.


9. Contributing 🀝

  1. Create a feature branch
  2. Commit using Conventional Commits (feat(ui): add project card)
  3. Open a PR; templates auto-label scope
  4. CI must pass lint, tests, and contract size

10. License πŸ“„

MIT Β© 2025 LiveStakes Contributors

Project Structure

livestakes/
β”œβ”€β”€ .git/
β”œβ”€β”€ common/
β”‚   β”œβ”€β”€ ecosystem.config.js
β”‚   β”œβ”€β”€ nginx.conf
β”‚   β”œβ”€β”€ supervisord.conf
β”‚   β”œβ”€β”€ supervisord.conf.dev
β”‚   β”œβ”€β”€ uwsgi_params
β”‚   └── wsgi.ini
β”œβ”€β”€ pipeline/
β”‚   β”œβ”€β”€ .dockerignore
β”‚   β”œβ”€β”€ ansible.cfg
β”‚   β”œβ”€β”€ check.sh
β”‚   β”œβ”€β”€ deploy_buildx.sh
β”‚   β”œβ”€β”€ deploy_home.sh
β”‚   β”œβ”€β”€ deploy_ubuntu.sh
β”‚   β”œβ”€β”€ deploy.sh
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ main.yaml
β”‚   └── stack.yml
β”œβ”€β”€ scripts/
β”‚   └── generate-flow-json.js
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ .next/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ about/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ livestreams/
β”‚   β”‚   β”‚   β”‚   └── route.ts
β”‚   β”‚   β”‚   └── markets/
β”‚   β”‚   β”‚   β”‚   └── route.ts
β”‚   β”‚   β”œβ”€β”€ chart/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ chat/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ clientwrapper/
β”‚   β”‚   β”‚   β”‚   └── index.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”‚   β”‚   └── card.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ BettingIndicator.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ BettingModal.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CardContent.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Chat.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ConnectWallet.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CTA.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ DashboardHeader.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ FeatureCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Features.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Hero.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ HowItWorks.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Leaderboard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ LiveBadge.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ LivestreamCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ LivestreamSection.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MarketAssociationModal.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MarketCreationModal.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MarketFilter.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MarketHeader.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Markets.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Marquee.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navigation.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ NavItem.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ OutcomeTable.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PageLayout.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PixelWindow.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PredictionGraph.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PWAProvider.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ SearchBar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ SideNav.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ SocialIcon.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ StreamCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Support.tsx
β”‚   β”‚   β”‚   └── TradePanel.tsx
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.tsx
β”‚   β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”‚   β”œβ”€β”€ features.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ howItWorks.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ livestreams.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ markets.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ marquee.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.ts
β”‚   β”‚   β”‚   └── support.ts
β”‚   β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ howitworks/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ leaderboard/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”‚   β”œβ”€β”€ cloudinary.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ contractsApi.ts
β”‚   β”‚   β”‚   └── livestreamsApi.ts
β”‚   β”‚   β”œβ”€β”€ livestreams/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ markets/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ profile/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ support/
β”‚   β”‚   β”‚   └── page.tsx
β”‚   β”‚   β”œβ”€β”€ globals.css
β”‚   β”‚   β”œβ”€β”€ layout.tsx
β”‚   β”‚   β”œβ”€β”€ not-found.tsx
β”‚   β”‚   └── page.tsx
β”‚   β”œβ”€β”€ blockchain/
β”‚   β”‚   β”œβ”€β”€ artifacts/
β”‚   β”‚   β”‚   β”œβ”€β”€ build-info/
β”‚   β”‚   β”‚   β”‚   └── e7b1899348a83502b2f4db86ca36448e.json
β”‚   β”‚   β”‚   └── contracts/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ MarketFactory.sol/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ MarketFactory.dbg.json
β”‚   β”‚   β”‚   β”‚   β”‚   └── MarketFactory.json
β”‚   β”‚   β”‚   β”‚   └── PredictionMarket.sol/
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ IMarketFactory.dbg.json
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ IMarketFactory.json
β”‚   β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ PredictionMarket.dbg.json
β”‚   β”‚   β”‚   β”‚   β”‚   └── PredictionMarket.json
β”‚   β”‚   β”œβ”€β”€ cache/
β”‚   β”‚   β”‚   └── solidity-files-cache.json
β”‚   β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   β”‚   β”œβ”€β”€ .DS_Store
β”‚   β”‚   β”‚   β”œβ”€β”€ MarketFactory.sol
β”‚   β”‚   β”‚   └── PredictionMarket.sol
β”‚   β”‚   β”œβ”€β”€ node_modules/
β”‚   β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”‚   β”œβ”€β”€ deploy-testnet.js
β”‚   β”‚   β”‚   β”œβ”€β”€ deploy.js
β”‚   β”‚   β”‚   β”œβ”€β”€ getMarket.js
β”‚   β”‚   β”‚   β”œβ”€β”€ getProject.js
β”‚   β”‚   β”‚   └── setup-testnet.js
β”‚   β”‚   β”œβ”€β”€ test/
β”‚   β”‚   β”‚   β”œβ”€β”€ MarketFactory.test.js
β”‚   β”‚   β”‚   └── PredictionMarket.test.js
β”‚   β”‚   β”œβ”€β”€ transactions/
β”‚   β”‚   β”‚   β”œβ”€β”€ claimPayout.js
β”‚   β”‚   β”‚   β”œβ”€β”€ createMarket.js
β”‚   β”‚   β”‚   β”œβ”€β”€ placeBet.js
β”‚   β”‚   β”‚   └── resolveMarket.js
β”‚   β”‚   β”œβ”€β”€ .DS_Store
β”‚   β”‚   β”œβ”€β”€ .env
β”‚   β”‚   β”œβ”€β”€ .gitignore
β”‚   β”‚   β”œβ”€β”€ deployment-flow-testnet.json
β”‚   β”‚   β”œβ”€β”€ deployment-localhost.json
β”‚   β”‚   β”œβ”€β”€ FLOW_EVM_SETUP.md
β”‚   β”‚   β”œβ”€β”€ hardhat.config.js
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   β”œβ”€β”€ pnpm-lock.yaml
β”‚   β”‚   └── README.md
β”‚   β”œβ”€β”€ howitworks/
β”‚   β”‚   └── page.tsx
β”‚   β”œβ”€β”€ node_modules/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ server/
β”‚   β”‚   β”œβ”€β”€ node_modules/
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ db.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ dbInitialization.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ migrations.ts
β”‚   β”‚   β”‚   β”‚   └── transactions.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ markets.ts
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ marketsMetadata.ts
β”‚   β”‚   β”‚   β”‚   └── videoUpload.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ cleanBucket.ts
β”‚   β”‚   β”‚   β”‚   └── importVideos.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”‚   └── videoAnalysis.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts
β”‚   β”‚   β”‚   └── migrate.ts
β”‚   β”‚   β”œβ”€β”€ temp/
β”‚   β”‚   β”œβ”€β”€ .env
β”‚   β”‚   β”œβ”€β”€ EXAMPLE_USAGE.md
β”‚   β”‚   β”œβ”€β”€ LIVESTREAMS_API.md
β”‚   β”‚   β”œβ”€β”€ MIGRATION.md
β”‚   β”‚   β”œβ”€β”€ package-lock.json
β”‚   β”‚   β”œβ”€β”€ package.json
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”‚   └── VIDEO_IMPORT_SETUP.md
β”‚   β”œβ”€β”€ .DS_Store
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ .env.example
β”‚   β”œβ”€β”€ .gitignore
β”‚   β”œβ”€β”€ eslint.config.mjs
β”‚   β”œβ”€β”€ next-env.d.ts
β”‚   β”œβ”€β”€ next.config.js
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ pnpm-lock.yaml
β”‚   β”œβ”€β”€ postcss.config.js
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   └── tsconfig.json
β”œβ”€β”€ .dockerignore
β”œβ”€β”€ DATA_REQUIREMENTS.md
β”œβ”€β”€ deploy.sh
β”œβ”€β”€ docker-compose-local.yml
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ docker-entrypoint.sh
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ Dockerfile.dev
β”œβ”€β”€ dump-livestakes.sql
β”œβ”€β”€ Makefile
└── README.md

About

πŸ† ETHGlobal Cannes Finalist πŸ† A real-time πŸ“ˆ prediction market πŸ’° & livestream dashboard engagement πŸŽ₯ for hackathons. View live project demos, place on-chain predictions, & earn crypto rewards for accurate forecasts. All interactions are powered by smart contracts & decentralized video infrastructure. Created by Molly Beach, Ziz Khu, Joao Santos

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published