CoOp:Anything
Search any game and see how much of it you can play with friends: every co-op mod, its stage, quality and community rating.
1Think 2Win - Test your sports knowledge and win exciting prizes!
GamesTypeScript · PLpgSQLGitHub @AunMohammad254OnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Quiz Game Prediction Based
Translation pending
Taken from the repository README
Loading the full README.
Read the full README ↗About · Latest updates · Features · Architecture · Security · Getting Started · Database · Testing · Deployment · Roadmap
1Think2Win is a Pakistan-based online sports quiz competition. Players pay a small entry fee (2 PKR), answer sports-knowledge questions within a time limit, and randomly selected winners receive real prizes such as motorcycles, smartphones, smartwatches and earbuds. The platform runs 24/7 and includes live-stream quizzes, an AI support assistant, push notifications and a full admin back-office.
| 🧠 Think Smart | 🎮 Play Hard | 🏆 Win Big |
|---|---|---|
| Sports knowledge quizzes | Timed sessions, live leaderboards | Fair random prize draws |
Status as of 5 October 2026: the player app and the full admin back-office are complete, and the production build, type-check, lint and test suite (241 tests) pass. The most recent work:
| Area | What changed |
|---|---|
| Media (Cloudinary) | Prize images, avatars and the auth logo are served from the Cloudinary CDN (next-cloudinary, blur placeholders, face-aware avatar crop). Unused assets are deleted automatically when a prize or avatar is replaced. |
| Admin media library | New Media module to browse Cloudinary usage and assets and delete files; prize form has inline upload (/api/upload). |
| Quiz lifecycle | New Upcoming status, a per-quiz time-up display window (timeUpDuration, 1 to 1440 min), a Push Schedule admin action, and cron-driven activation and auto-pause. Player cards show Upcoming, Unanswered, Answered or Time-up. |
| Live viewing | Mobile-first stream player (mobile header, working settings panel, native fullscreen with landscape lock). Quiz screen has a theater mode, keeps the timer visible in landscape on phones, and drops the stream area when nothing is live. |
| Landing page | Hero is now a server component with small client islands (typewriter, particles, CTA); the headline is no longer gated on a scroll observer. Fixed the hero sport balls rendering at 320px instead of 96px. |
| Navigation speed | Quiz cards prefetch their route on hover or focus. |
| Security and email | Auth-callback open-redirect fix, CSRF hardening, dead session-cookie cleanup, one-click signed newsletter unsubscribe, configurable Brevo sender. |
| Support tooling | Admin support desk: user lookup, points and wallet adjustments, suspend or restore, force-verify email, refunds, notes and tags, GDPR export. |
| Deployment | Hostinger upload ZIP built by scripts/build-hostinger.ps1 (steps in its header). |
| Installable app | public/manifest.json (192 and 512 icons) is wired into the root layout. |
[!NOTE]
experimental.optimizeCssis deliberately not enabled: Next needs thecritterspackage for it, which is not installed, and it previously broke builds.
Protected by a separate admin session (bcrypt-verified credentials, admin-session cookie, validated in the layout and in every Server Action).
| Module | What admins can do |
|---|---|
| Dashboard | KPI cards, recent activity feed, aggregated analytics (server-side SQL aggregates) |
| Analytics | Users, quizzes, revenue and engagement charts; Web Vitals reporting |
| Quizzes | Form builder, create, edit, delete, publish, pause, push live, schedule, push a scheduled quiz; time-up window per quiz; bulk question management |
| Questions | Create, edit and list questions per quiz |
| Quiz evaluation | Step-by-step evaluation: mark correct options, finalize scores, set-based and fast |
| Lucky winner | Fair random winner draw per quiz |
| Prizes & claims | Prize CRUD with Cloudinary images, atomic stock handling, player claims review and approval |
| Wallet | Review deposit requests, bulk processing, reconciliation, wallet feature toggle |
| Live streaming | Manage stream embeds and configuration |
| Newsletter | Subscriber list and send campaigns |
| Notifications | Send and schedule push or in-app notifications (cron-processed) |
| Support desk | Look up users, adjust points or wallet balance, edit profile, reset password, suspend or unsuspend, force-verify email, resend verification, impersonation link, refund attempts, admin notes and tags, GDPR data export |
| Security center | Security events, stats and fraud alerts |
| Media | Cloudinary usage and asset browser with delete |
| DB stats | Database health and size insights |
The wallet gate (2 PKR for 24 h access) can be switched on or off without a deploy.
WALLET_FEATURE_ENABLED | Behaviour |
|---|---|
true (default) | Users pay from their wallet to unlock quizzes; wallet UI and deposits visible |
false | Quizzes are free; wallet UI, navbar links and deposit form hidden; admin wallet APIs return 503 |
It can also be flipped live from the admin panel (AppSettings). The value is cached and propagates within about 60 seconds. No balances or history are ever deleted.
flowchart LR
U[Player / PWA] -->|HTTPS| P[proxy.ts<br/>CSP, auth gate, admin gate]
P --> N[Next.js 16 App Router<br/>Server Components + Server Actions]
N --> API[/50+ API routes/]
N --> SA[Server Actions<br/>quiz, prizes, wallet, support, security]
API --> DB[(Supabase Postgres<br/>RLS + RPC functions)]
SA --> DB
N --> AUTH[Supabase Auth]
N --> CLD[Cloudinary<br/>images and media]
N --> BR[Brevo<br/>transactional email]
N --> GM[Gemini API<br/>support chatbot]
N --> WP[Web Push<br/>VAPID]
CRON[Vercel Cron / pg_cron] --> N
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router, standalone output), React 19, TypeScript 6 |
| Styling & UI | Tailwind CSS 4, Radix UI (dialog, tabs, switch, label), Framer Motion, Lucide, Sonner toasts, CVA |
| Forms & validation | React Hook Form, Zod 4 |
| Backend | Next.js API routes and Server Actions |
| Database & Auth | Supabase (PostgreSQL, Row Level Security, RPC functions, @supabase/ssr) |
| Media | Cloudinary (next-cloudinary, sharp for processing) |
| Brevo (transactional) | |
| AI | Google Gemini (multi-model fallback) |
| Push | web-push (VAPID) |
| Tooling | Bun, ESLint 9, Vitest 4, Testing Library, Playwright, Lighthouse CI |
| DevOps | GitHub Actions, Docker (+ nginx), Vercel / Hostinger |
📦 1think2winsx
├── 📂 src
│ ├── 📄 proxy.ts # Edge proxy: CSP, auth gate, admin cookie gate
│ ├── 📂 app # App Router
│ │ ├── 📂 (pages) # quizzes, quiz/[id], leaderboard, prizes, profile, how-to-play, faq, contact, legal…
│ │ ├── 📂 auth, login, register, forgot-*, update-password
│ │ ├── 📂 admin # (public)/login and (protected)/ 15 admin modules
│ │ └── 📂 api # 50+ route handlers (admin, quizzes, wallet, notifications, cron, chatbot…)
│ ├── 📂 actions # Server Actions (quiz, prizes, wallet, support, security, media, analytics…)
│ ├── 📂 components # admin, analytics, auth, chatbot, hero, landing, navbar, player-claims,
│ │ # prize-redemption, prizes, profile, quiz, quiz-evaluation, wallet, ui
│ ├── 📂 contexts # Auth, Profile, PWA providers
│ ├── 📂 hooks # useLeaderboard, useNotifications, useHasHover
│ ├── 📂 lib # security, rate-limit, csrf, email, cloudinary, wallet service, quiz cache
│ │ └── 📂 supabase # clients, typed DB layer split into db-modules (quiz, wallet, prize, …)
│ ├── 📂 utils, types
│ └── 📂 tests # API, CI-pipeline, streaming and hardening tests
├── 📂 SQL # Schema, functions, RLS, indexes, patches and supabase/migrations
├── 📂 e2e # Playwright specs
├── 📂 deploy # Dockerfile, docker-compose, nginx.conf
├── 📂 scripts # VAPID generator, cleanup, Hostinger build, test runner
├── 📂 presentation # Client deck generator (pptxgenjs), git-ignored
├── 📂 public # Service worker (sw.js), manifest.json, favicons
└── 📂 .github/workflows # tests, coverage, performance
Security is layered across the edge, application and database.
Edge & transport
proxy.ts sets a Content-Security-Policy, gates protected routes (/profile, /quiz, /quizzes) and blocks /admin/* without an admin session cookie.X-Frame-Options: DENY, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, X-XSS-Protection; X-Powered-By removed; HTTP to HTTPS redirect in production.Application
/api/csrf-token) on state-changing requests.assertAdmin()) in every admin Server Action; bcrypt-hashed admin credentials with DB-backed sessions.sanitize-html on inputs; signed newsletter unsubscribe tokens.console.* stripped from production builds.Database (Supabase)
anon and authenticated.private_hardened.submit_quiz_attempt, pay_quiz_access, submit_deposit_request), so prices and one-attempt-per-quiz cannot be tampered with from the client.auth_uid() hardening, security-definer warnings fixed, unused indexes removed, foreign-key indexes added.The 2026-09 migration prepared the system for ~50,000 users:
evaluate_question, finalize_quiz_scores) replacing one UPDATE per attempt.LeaderboardCache, compute_leaderboard, refresh_leaderboard_cache, get_leaderboard), refreshed by pg_cron.get_admin_analytics) without row caps.QuizEvaluationManager), reduced font weights with display: swap, AVIF/WebP images served from Cloudinary, tree-shaken lucide-react/date-fns, Web Vitals reporting, bundle analyzer (bun run analyze).HeroClient), plus lazy-loaded below-the-fold sections.preconnect hint warms the Cloudinary CDN.Overload protection and measurement (Phase 0/1 of the 50k plan):
/api/quizzes, /api/quizzes/[id]) shed load with 503 + Retry-After instead of queueing; browsers retry with jittered backoff (src/lib/load-shed.ts, src/lib/fetch-retry.ts). The quiz list poll is jittered, pauses in hidden tabs and backs off on errors (src/hooks/useJitteredPolling.ts).fetchAllByKeyset)./api/health is a database-free liveness probe; ?stats=1 (with Authorization: Bearer $CRON_SECRET) reports event-loop lag, in-flight requests and memory for load tests..env.example (TRUSTED_PROXY_HOPS, LOAD_SHED_*, SUPABASE_*_TIMEOUT_MS, CHATBOT_MAX_CONCURRENT).load-test/ (k6 scenarios, staging user seeding, a process monitor, and the owner's pre-launch checklist; start with load-test/RUNBOOK.md). The Phase 1 database changes are in SQL/supabase/migrations/20261008120000_phase1_scale_hardening.sql (idempotent).git clone https://github.com/AunMohammad254/1think2winsx.git
cd 1think2winsx
bun install
cp .env.example .env.local
| Variable | Purpose |
|---|---|
NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY | Supabase connection |
AUTH_SECRET | Session and token signing |
ADMIN_EMAILS, ADMIN_PASSWORD | Admin back-office access |
WALLET_FEATURE_ENABLED | true or false: paid vs free quizzes |
CRON_SECRET | Authorises /api/cron/process-scheduled |
NEXT_PUBLIC_SITE_URL | Public site URL (metadata base, links in emails) |
NEWSLETTER_UNSUBSCRIBE_SECRET | Signs unsubscribe links (identical across environments) |
NEXT_PUBLIC_VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, VAPID_SUBJECT | Web push (generate with bun scripts/generate-vapid.ts) |
CLOUDINARY_API_KEY, CLOUDINARY_API_SECRET, NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME | Prize images and media |
BREVO_API_KEY, BREVO_SMTP_USERNAME, BREVO_SMTP_PASSWORD, BREVO_SENDER_EMAIL | Transactional email |
GEMINI_API_KEY | AI support chatbot |
[!NOTE]
.env.examplealso contains some legacy placeholders (Prisma, Stripe, Google OAuth, and others) that the current code does not use. Never commit real secrets.
bun run dev # development server at http://localhost:3000
bun run build # production build
bun run start # serve the production build
All SQL lives in SQL/:
| Folder | Contents |
|---|---|
01_schema | Core tables: quiz module, wallet, prizes and redemptions, notifications, push subscriptions, newsletter, live streams, admin |
02_functions | RPC functions: atomic wallet deduction, atomic prize stock, user increments, leaderboard, admin aggregates |
03_rls_security | RLS policies, RPC grant fixes, security logs, hardening v1 and v2 |
04_indexes_performance | Index additions, removals and performance passes |
05_patches_fixes | App settings, quiz winners, proof images, incremental fixes |
supabase/migrations | Timestamped, authoritative migrations, including the 50k-scale and security hardening migration |
archive | Historical fixes kept for reference |
Apply with the Supabase CLI or paste into the SQL editor (take a backup first):
supabase link --project-ref <your-project-ref>
supabase db push
[!IMPORTANT] Deploy the application code after applying
20260925120000_scale_50k_and_security_hardening.sql; the new code calls the functions it creates. Enable thepg_cronleaderboard refresh and, ideally, asymmetric JWT signing keys in Supabase Auth.
| Command | Description |
|---|---|
bun run test | Vitest in watch mode |
bun run test:ci | Vitest single run with verbose and JUnit reporters |
bun run test:coverage | Coverage report (V8) |
bun run test:ui | Vitest UI |
bun run test:e2e | Playwright E2E (all projects) |
bun run test:e2e:chromium / :firefox / :webkit / :mobile | Per-browser E2E |
bun run test:all | Unit/API tests plus E2E |
bun run test:menu | Interactive test runner |
bun run lint | ESLint |
bun run cleanup:orphaned | Remove orphaned DB records |
| Target | How |
|---|---|
| Docker | docker compose -f deploy/docker-compose.yml up -d --build (Bun Alpine image, nginx config included, Next.js standalone output) |
| Hostinger | powershell -ExecutionPolicy Bypass -File scripts\build-hostinger.ps1 builds hostinger-deploy.zip (committed source only, lockfile pinned to the tested bun.lock versions). hPanel: Deployments → Settings and redeploy → Upload new files → Redeploy. Settings and links to Hostinger's docs are in the script header. |
| Vercel | vercel.json registers a daily cron for /api/cron/process-scheduled (activates scheduled quizzes and sends scheduled notifications) |
Other endpoints: GET /api/health for health checks, and /api/cron/process-scheduled secured by CRON_SECRET.
Engineering is complete; these items need an owner before going live:
pg_cron leaderboard refresh and schedule /api/cron/process-scheduled.public/Favicon/site.webmanifest is now unused.The client status and showcase deck is generated from code in presentation/ (21 slides with speaker notes, real product screenshots).
cd presentation
node capture.cjs # optional: refresh screenshots (needs `bun run dev` running)
node build.cjs # writes 1Think2Win-Showcase.pptx
Figures shown on the slides live in the FACTS block of presentation/build.cjs. The folder is git-ignored; see its own README.
| ✅ Delivered | 🔄 Planned | 🔮 Future |
|---|---|---|
| Quiz system with scheduling | Native mobile app | Multiplayer / head-to-head |
| Wallet and 2 PKR access | Social features and sharing | AI-generated questions |
| Random winner draws and prize claims | Tournaments | Multi-language (Urdu) |
| Live leaderboards (cached) | Achievement badges | Advanced player stats |
| Full admin back-office and support desk | Automated payment gateway integration | Custom user quizzes |
| Live-stream quizzes with theater mode | ||
| Quiz lifecycle (upcoming, time-up window) | ||
| Cloudinary CDN media and admin media library | ||
| Web push and PWA | ||
| AI support chatbot | ||
| Security hardening and 50k scale work | ||
| Vitest and Playwright suites with CI |
git checkout -b feature/AmazingFeature)git commit -m 'Add AmazingFeature')git push origin feature/AmazingFeature)Please run bun run lint and bun run test:ci before submitting.
| [email protected] | |
| 🐛 Issues | Report a bug |
Distributed under the MIT License.
Made with 💚 for sports and quiz fans in Pakistan