Skip to content

mrbrightsides/chainedbrain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ChainedBrain ๐Ÿ”—๐Ÿง 

An AI-powered multiplayer quiz platform with Web3 theming where brains connect through the chain.

ChainedBrain Next.js SpacetimeDB Groq


๐ŸŒŸ Features

๐ŸŽฎ Dual Quiz Creation Modes

  • ๐Ÿค– AI Generation: Auto-generate quiz questions using Groq's Llama 3.3 70B model
  • โœ๏ธ Manual Creation: Craft custom questions from scratch with full control

๐Ÿ† Live Multiplayer Sessions

  • Real-time Kahoot-style quiz gameplay
  • Room code system for easy joining
  • Live leaderboards with podium rankings
  • Host controls for quiz flow management
  • Instant feedback with answer explanations

๐Ÿ–ผ๏ธ Public Quiz Gallery

  • Browse community-created quizzes
  • Advanced search and filtering
  • Sort by popularity, trending, newest
  • Play solo anytime at your own pace
  • Daily featured challenges

๐Ÿ“Š Rich Analytics & Tracking

  • Detailed Quiz Summary: Question-by-question breakdown with performance stats
  • Quiz History: Track all your attempts with dates and scores
  • Creator Analytics: Insights into quiz performance and question difficulty
  • Personal Stats: Accuracy percentages, total attempts, best times

๐Ÿ… Gamification

  • Achievement System: 6 unlockable badges
    • ๐ŸŽฏ First Steps - Complete your first quiz
    • โญ Perfect Score - Get 100% accuracy
    • โšก Speed Demon - Complete quiz in under 60 seconds
    • ๐Ÿ† Quiz Creator - Create your first quiz
    • ๐Ÿ‘ฅ Social Butterfly - Take 10 different quizzes
    • ๐Ÿ”ฅ Streak Master - 5 perfect scores in a row

๐Ÿ‘ค Profile Customization

  • Custom display names and avatars
  • Personal bio section
  • Profile statistics display

๐Ÿ”— Social Features

  • Share results to Twitter/X and Farcaster
  • Copy results to clipboard
  • Public leaderboards for each quiz

๐Ÿ› ๏ธ Tech Stack

  • Frontend: Next.js 15 + React 19
  • Styling: Tailwind CSS + shadcn/ui
  • Real-time Database: SpacetimeDB (multiplayer sync + persistent storage)
  • AI Generation: Groq API (Llama 3.3 70B)
  • Language: TypeScript
  • Deployment: Vercel-ready

๐Ÿš€ Getting Started

Prerequisites

Installation

  1. Clone the repository
git clone https://github.com/mrbrightsides/chainedbrain.git
cd chainedbrain
  1. Install dependencies
npm install
  1. Set up environment variables

Create a .env.local file in the root directory:

NEXT_PUBLIC_GROQ_API_KEY=your_groq_api_key_here
  1. Run the development server
npm run dev
  1. Open in browser
http://localhost:3000

๐Ÿ“ฆ Project Structure

chainedbrain/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx                 # Main application page
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx               # Root layout
โ”‚   โ”‚   โ””โ”€โ”€ api/
โ”‚   โ”‚       โ””โ”€โ”€ proxy/               # API proxy endpoint
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ ui/                      # shadcn/ui components
โ”‚   โ”‚   โ”œโ”€โ”€ CreateQuiz.tsx           # Quiz creation interface
โ”‚   โ”‚   โ”œโ”€โ”€ LiveSession.tsx          # Multiplayer session UI
โ”‚   โ”‚   โ”œโ”€โ”€ EnhancedGallery.tsx      # Quiz gallery with search/filters
โ”‚   โ”‚   โ”œโ”€โ”€ QuizHistory.tsx          # User quiz history
โ”‚   โ”‚   โ”œโ”€โ”€ Achievements.tsx         # Achievement tracking
โ”‚   โ”‚   โ”œโ”€โ”€ CreatorAnalytics.tsx     # Analytics dashboard
โ”‚   โ”‚   โ”œโ”€โ”€ ProfileEditor.tsx        # Profile customization
โ”‚   โ”‚   โ””โ”€โ”€ About.tsx                # About page
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ””โ”€โ”€ groq/
โ”‚   โ”‚       โ””โ”€โ”€ groqService.ts       # Groq API integration
โ”‚   โ”œโ”€โ”€ spacetime/                   # SpacetimeDB client setup
โ”‚   โ””โ”€โ”€ spacetime_module_bindings/   # Auto-generated DB bindings
โ”œโ”€โ”€ spacetime-server/
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ””โ”€โ”€ lib.rs                   # SpacetimeDB schema & reducers
โ”œโ”€โ”€ public/                          # Static assets
โ””โ”€โ”€ README.md                        # This file

๐ŸŽฎ How to Use

Creating a Quiz

  1. Click "Create Quiz" tab
  2. Choose your mode:
    • AI Mode: Enter topic, difficulty, and question count โ†’ AI generates instantly
    • Manual Mode: Add questions one by one with custom options
  3. Review & Start: Preview questions, then start a live session or save to gallery

Hosting a Live Session

  1. Create or select a quiz
  2. Click "Start Live Session"
  3. Share the 6-digit room code with players
  4. Control quiz flow: start questions, show answers, view live rankings
  5. See final leaderboard with podium

Joining a Live Session

  1. Click "Join Live" tab
  2. Enter room code and your nickname
  3. Wait in lobby for host to start
  4. Answer questions in real-time
  5. Compete for top rankings!

Playing from Gallery

  1. Browse quizzes in "Gallery" tab
  2. Use search/filters to find topics
  3. Click "Play Solo" to start
  4. Complete at your own pace
  5. Submit score to public leaderboard

๐Ÿ—„๏ธ Database Schema (SpacetimeDB)

Core Tables

  • quiz: Quiz metadata, questions, settings
  • live_session: Active multiplayer sessions
  • participant: Session players and scores
  • quiz_attempt: Historical quiz attempts
  • user_achievement: Earned badges
  • user_stats: Aggregate user statistics
  • user_profile: Profile customization
  • question_analytics: Question performance data
  • daily_challenge: Featured daily quizzes

Key Reducers

  • create_quiz: Save new quiz
  • start_live_session: Initialize multiplayer session
  • join_session: Add player to session
  • submit_answer: Record player answer
  • record_quiz_attempt: Save quiz history
  • award_achievement: Grant badges
  • update_user_stats: Update statistics
  • set_daily_challenge: Set featured quiz

๐ŸŽจ Design Philosophy

ChainedBrain embraces Web3 aesthetics with:

  • Purple/blue/teal gradient themes
  • Chain link motifs throughout the UI
  • Smooth animations and transitions
  • Responsive design for mobile and desktop
  • Clean, modern component architecture

๐Ÿ” Environment Variables

Variable Description Required
NEXT_PUBLIC_GROQ_API_KEY Groq API key for AI generation Yes

๐Ÿ“ Development Phases

Phase 1 โœ…

  • Core quiz creation (AI + Manual)
  • Live multiplayer sessions
  • Public gallery with solo play
  • Detailed quiz summaries
  • Quiz history tracking
  • Achievement system
  • Social sharing

Phase 2 โœ…

  • Advanced gallery (search, filters, sorting)
  • Creator analytics dashboard
  • Profile customization
  • Daily challenges
  • Enhanced social features

Future Phases ๐Ÿšง

  • Team mode (2v2, 3v3)
  • Question types (true/false, fill-in-blank)
  • Image-based questions
  • Leaderboard seasons
  • Mobile app
  • NFT badges (Web3 integration)

๐Ÿค Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest new features
  • Submit pull requests
  • Improve documentation

๐Ÿ“„ License

MIT License - feel free to use this project for your own purposes.


๐Ÿ‘จโ€๐Ÿ’ป Credits

Created by mrbrightsides

Website: rantai.elpeef.com


๐Ÿ™ Acknowledgments

  • Groq for blazing-fast AI inference
  • SpacetimeDB for real-time multiplayer capabilities
  • shadcn/ui for beautiful UI components
  • Vercel for seamless deployment
  • The open-source community

Built with ๐Ÿง  and โ›“๏ธ

GitHub โ€ข Website

About

ChainedBrain is an AI-powered multiplayer quiz platform where brains connect through the chain.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages