PredictMarket is a college-safe, virtual-coin prediction market built with Next.js, Supabase, and Tailwind CSS. Users can browse markets, place YES/NO bets, follow live odds, view portfolios, and compete on a leaderboard without using real money or crypto.
- Next.js 16 App Router
- TypeScript 5
- Tailwind CSS 4
- Supabase PostgreSQL and Realtime
- TanStack Query v5
- Zustand
- Framer Motion
- Recharts
- Responsive market browsing and detail views
- Virtual betting with optimistic UI updates
- App-managed login and signup backed by the
userstable - Portfolio dashboard with ROI and transaction history
- Leaderboard rankings sourced from the database
- Admin market resolution flow
- Realtime market odds updates
app/- pages, layouts, and API routescomponents/- reusable UI componentshooks/- data and mutation hookslib/- utilities, API fetchers, and Supabase clientsstores/- client-side statetypes/- shared TypeScript interfacesdatabase/- schema, procedures, and seed SQL
- Node.js 20 or newer
- npm
- A Supabase project
Create a .env.local file from .env.local.example and fill in your Supabase values:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYNEXT_PUBLIC_APP_URLSUPABASE_SERVICE_ROLE_KEYJWT_SECRET
Example:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
NEXT_PUBLIC_APP_URL=http://localhost:3000
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
JWT_SECRET=your-long-random-secret-at-least-32-chars- Create a new Supabase project.
- Open the SQL editor.
- Run the files in this order:
database/schema.sqldatabase/procedures.sqldatabase/seeds.sqlif you want starter data
- Make sure the
userstable, RLS policies, and seed data are imported successfully.
Notes:
- The schema creates users, categories, markets, bets, transactions, comments, leaderboard scores, and admin logs.
- The procedures file contains the probability and payout helpers plus the market resolution logic.
- The current app uses database-driven profiles, so signup creates a user row with a hashed password and a signed app session cookie.
npm installnpm run devThen open:
http://localhost:3000- Push the repository to GitHub.
- Import the project into Vercel.
- Add the following environment variables in the Vercel project settings:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEYNEXT_PUBLIC_APP_URLJWT_SECRET
- Set
NEXT_PUBLIC_APP_URLto your Vercel deployment URL. - Run the SQL schema and seed files in Supabase before testing the deployed app.
- Deploy and verify signup, login, logout, market navigation, and bet placement.
npm run build
npm run startnpm run dev- start the development servernpm run build- create a production buildnpm run start- run the production servernpm run lint- run ESLintnpm run type-check- run TypeScript checksnpm run db:types- generate Supabase TypeScript types
- Install dependencies with
npm install. - Add your Supabase credentials to
.env.local. - Import the SQL schema and procedures into Supabase.
- Start the app with
npm run dev. - Sign up or log in.
- Browse markets, place bets, and view your portfolio.
/- homepage/markets- market list/markets/[id]- market detail and bet panel/portfolio- user portfolio/leaderboard- rankings/admin- admin dashboard/login- login screen/signup- signup screen
- The app is designed for virtual currency only.
- Market odds and portfolio changes are optimistic on the client and then reconciled through the API.
- The codebase uses strict TypeScript, so generated Supabase types or local row casts may be needed when you add new queries.
- The middleware file currently works, but Next.js warns that the convention is deprecated in favor of
proxy.
- If login or signup fails, verify the Supabase URL, anon key, service role key, and
JWT_SECRETin.env.local. - If database queries fail, confirm the SQL schema and procedures were imported successfully.
- If TypeScript complains about Supabase query results, add local row interfaces that match the selected columns.
- If the navbar shows stale wallet data after logout, hard refresh once after updating to the latest code.