All projects

BetBat — Real-Time Social Prediction Market

A real-time prediction-market app (Next.js 16 / React 19 / TypeScript / Firestore) built over a 6-week Agile project, with transaction-safe coin economics, an LLM (OpenAI gpt-4o-mini) that structures free-form bets into verifiable yes/no markets, and a market-resolution state machine.

Next.jsReactTypeScriptFirestoreOpenAICI/CD

A real-time social prediction market co-built with a team of five for CS 130 over a 6-week Agile project (live demo deployed on Vercel).

I implemented transaction-safe coin economics and a market-resolution state machine: all wagers and payouts run in Firestore atomic transactions, with 2/3-supermajority voting and server-only writes locked by security rules. The project shipped with unit, security-rules, and end-to-end test suites gated by GitHub Actions CI. I also drove software-engineering rigor across the team — INVEST user stories, a design document, and UML diagrams (class, sequence, state-machine, use-case), applying Gang-of-Four design patterns throughout.

AI-structured bets

BetBat uses an LLM to turn a free-form idea into a clean, wagerable market. A user types a plain-English description and a server endpoint calls OpenAI gpt-4o-mini through its function-calling API: a structure_bet tool returns a strict, validated shape — a clear yes/no question, explicit win and lose conditions, a close deadline, and an isFair flag for whether the bet is objectively verifiable. The route is production-hardened rather than a demo call: it’s authentication-gated, caps input length to bound token cost, rate-limits to 10 structurings per user per day, caches results by a deterministic description hash to avoid paying for repeat calls, wraps the model in a 15-second timeout, and degrades gracefully to manual entry whenever the model is unavailable.

Scaffolding AI bet resolution

That same structuring step is what scaffolds automated resolution. By forcing every bet into a machine-checkable form — explicit win/lose conditions plus the isFair “objectively verifiable” signal — bets are authored up front in a shape an adjudicator (human or model) can settle deterministically. Resolution then flows through an explicit state machine (VOTING → RESOLVED / DISPUTED) backed by a 48-hour cron safety net that refunds and flags stalled markets. The shipped resolution path is the 2/3-supermajority human vote; the AI structuring lays the groundwork for automatically adjudicating the objectively-verifiable markets it flags.