Skip to content

Latest commit

ย 

History

History
656 lines (510 loc) ยท 26.2 KB

File metadata and controls

656 lines (510 loc) ยท 26.2 KB

๐ŸŽฏ AnswerHub

The Intelligent Community Q&A Platform


React Vite Supabase Tailwind CSS Framer Motion License


A production-grade, community-driven Q&A and FAQ platform engineered for institutional portals, university hubs, and knowledge-sharing communities. Featuring a moderated answer pipeline, reputation & badge gamification, AI-powered summaries, multi-language translation, voice-enabled search, text-to-speech accessibility, real-time leaderboards, and a cinematic dark/light developer aesthetic.


๐Ÿš€ Getting Started ยท โœจ Features ยท ๐Ÿ† Gamification ยท ๐Ÿ—๏ธ Architecture ยท ๐Ÿ“„ License



โœจ Feature Highlights

๐Ÿ” Role-Based Access Control

Fine-grained RBAC with three permission tiers:

  • Guest โ€” Browse verified answers, search, view FAQs
  • User โ€” Ask questions, submit answers, upvote, track notifications
  • Admin โ€” Full moderation dashboard with bulk operations, metrics, flagging review, and content management

๐Ÿ›ก๏ธ Moderated Answer Pipeline

Enterprise-grade content quality assurance:

  • Submitted answers are private by default until admin verification
  • Four-state workflow: pending โ†’ verified / rejected / spam
  • Authors receive real-time notifications with admin feedback notes
  • โœ… Accepted Answer โ€” Question owners can mark the best answer

๐Ÿ† Reputation & Badge System

Full gamification engine to drive engagement:

  • Reputation Points โ€” Earn points for asking, answering, upvotes, accepted answers, and daily logins
  • ๐Ÿฅ‰๐Ÿฅˆ๐Ÿฅ‡ Tiered Badges โ€” Bronze, Silver, Gold, and Special badges
  • ๐Ÿ“ˆ Progress Tracker โ€” Visual progress bar toward next badge
  • ๐Ÿ”ฅ Leaderboard โ€” Live rankings of top contributors

๐ŸŽ™๏ธ Voice Search (Voice Chat)

Hands-free voice input powered by the Web Speech API:

  • Search bar โ€” Tap the microphone to speak your query
  • Ask Question โ€” Dictate both title and description fields
  • FAQ search โ€” Voice-enabled FAQ filtering
  • Real-time interim transcription with automatic finalization
  • Graceful fallback for unsupported browsers

๐Ÿ”Š Text-to-Speech (TTS)

Built-in accessibility for content consumption:

  • Listen to any question โ€” One-tap playback on question cards
  • FAQ answers read aloud โ€” Audio playback for every FAQ entry
  • Visual speaking indicator with stop/play toggle
  • Uses native SpeechSynthesis API โ€” zero external dependencies

๐ŸŒ Multi-Language Translation

Break language barriers with real-time translation:

  • Translate questions and answers into multiple languages
  • Seamless inline translation UI
  • Supports global user communities
  • Powered by translation API integration

๐Ÿ” Type-Ahead Autocomplete

Instant search suggestions as you type:

  • Real-time query predictions from existing questions
  • Reduces search time and improves discoverability
  • Keyboard-navigable suggestion dropdown
  • Powered by fuzzy matching with Fuse.js

๐Ÿšฉ Content Flagging

Community-driven content moderation:

  • Flag inappropriate questions or answers for admin review
  • Flag reasons include: spam, offensive, off-topic, duplicate
  • Flagged content enters the admin moderation queue
  • Keeps the community safe and professional

๐Ÿง  Smart Duplicate Detection

AI-powered question deduplication:

  • Fuse.js fuzzy matching scans existing questions in real-time as you type
  • Displays similarity scores and matching questions before submission
  • Users can "View Existing Answers" or choose to "Ask Anyway"

๐Ÿšซ Heuristic Spam Detector

Automatic content quality filtering:

  • Scans for repeated characters, excessive URLs, promotional keywords, and ALL-CAPS
  • Flagged answers are auto-redirected to admin moderation queue as spam
  • Zero false positive tolerance with multi-signal heuristic scoring

๐Ÿ”ฎ Client-Side AI Summarizer

100% free, privacy-first NLP summaries:

  • Extractive NLP algorithm runs entirely in-browser in under 5ms
  • Sentence frequency scoring with stop-word filtering
  • Extracts top 2 key insights from long answers (350+ characters)
  • Rendered in a collapsible โœจ AI Sparkle Summary glassmorphic drawer

๐Ÿ“ Track Your Questions

Never lose sight of your submissions:

  • Real-time status tracking for all your questions
  • See answer count, views, upvotes, and verification status
  • Get notified when answers are posted or verified
  • Full activity history on your profile dashboard

๐Ÿ”‘ Authentication System

Flexible, secure authentication:

  • Email/Password sign-up and login
  • Forgot Password โ€” Email-based password reset flow
  • Session persistence across page refreshes
  • Automatic session recovery with watchdog timer

๐ŸŽจ Obsidian & Paper Theme System

Cinematic dual-theme experience:

  • Obsidian Dark โ€” Deep dark mode with cosmic particle backdrops
  • Paper Light โ€” Pristine light mode with subtle gradients
  • localStorage-persisted theme preference
  • Spring-physics page transitions via Framer Motion
  • Self-drawing SVG toast notifications

๐Ÿ† Reputation & Badge System

Point System

Action Points
Ask a Question +5
Post an Answer +10
Answer Gets Upvoted +10
Question Gets Upvoted +5
Accepted Answer +30
Daily Login +2
Downvote Received -2

Badge Tiers

๐Ÿฅ‰ Bronze Badges

Beginner Contributor โ€” 10 pts
First Question โ€” Ask your first question
First Answer โ€” Post your first answer

๐Ÿฅˆ Silver Badges

Knowledge Sharer โ€” 100 pts
10 Accepted Answers
Helpful Member

๐Ÿฅ‡ Gold Badges

Expert Contributor โ€” 500 pts
50 Upvotes Received
Problem Solver

๐ŸŒŸ Special Badges

Badge Criteria
๐Ÿ‘‘ Community Leader Top reputation holder in the community
๐Ÿ”ฅ Top Contributor of the Month Most active contributor in the current month
๐Ÿš€ Fast Responder Consistently answers within minutes
๐Ÿ’ก Innovation Guru Answers with highest quality ratings

๐ŸŽฏ Progress Tracker

Visual progress bars show users how close they are to their next badge:

Knowledge Sharer Badge
โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 80/100 Points

Expert Contributor Badge
โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 120/500 Points

๐Ÿ”ฅ Leaderboard

Live rankings of top contributors displayed platform-wide:

๐Ÿ… 1. Vishal Soni     1,250 pts   ๐Ÿ‘‘๐Ÿฅ‡๐Ÿ”ฅ
๐Ÿ… 2. Arnav             980 pts   ๐Ÿฅ‡๐Ÿฅˆ
๐Ÿ… 3. Aryan             870 pts   ๐Ÿฅˆ๐Ÿฅˆ
๐Ÿ… 4. Priya             650 pts   ๐Ÿฅˆ
๐Ÿ… 5. Rahul             420 pts   ๐Ÿฅ‰

โœ… Accepted Answer System

  • Question owners can mark one answer as the accepted answer
  • โœ… Green checkmark appears on the accepted answer
  • Accepted answer is pinned to the top of the answer list
  • The answerer receives +30 reputation points
  • Improves content discoverability for future visitors

๐Ÿ“ˆ User Profile Dashboard

Every registered user gets a comprehensive profile showcasing:

Metric Description
๐Ÿ† Total Reputation Cumulative reputation points earned
๐ŸŽ–๏ธ Badges Earned All bronze, silver, gold, and special badges
โ“ Questions Asked Total questions submitted
๐Ÿ’ฌ Answers Posted Total answers contributed
โœ… Accepted Answers Number of answers marked as accepted
๐Ÿ“Š Ranking Position Current leaderboard position

| ๐ŸŽฏ Progress to Next Badge | Visual progress bar |


๐Ÿ—๏ธ Architecture

System Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         CLIENT (SPA)                             โ”‚
โ”‚   React 19 ยท Vite 8 ยท Tailwind CSS v4 ยท Framer Motion 12        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Auth  โ”‚Questionโ”‚ Answer โ”‚ Search โ”‚ Voice  โ”‚Translationโ”‚
โ”‚Context โ”‚  Hook  โ”‚  Hook  โ”‚  Hook  โ”‚STT/TTS โ”‚  Engine   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Reputation Engine ยท Badge System ยท Leaderboard                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚               Supabase JS Client (v2.106+)                       โ”‚
โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚
โ”‚              โ”‚   Auth   โ”‚ Database โ”‚ Storage  โ”‚                  โ”‚
โ”‚              โ”‚  (JWT)   โ”‚ (REST)   โ”‚ (S3-API) โ”‚                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      SUPABASE BACKEND                            โ”‚
โ”‚   PostgreSQL ยท Row-Level Security ยท Edge Functions ยท Realtime    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   8+ Tables ยท 5+ RPC Functions ยท 16+ RLS Policies ยท 9+ Indexes  โ”‚
โ”‚   Cascade Deletes ยท Composite Constraints ยท Auto Triggers        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Project Structure

Answerhub/
โ”œโ”€โ”€ public/                        # Static assets
โ”œโ”€โ”€ supabase/
โ”‚   โ””โ”€โ”€ schema.sql                 # Full database schema, triggers, RLS policies
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ admin/                 # Moderation dashboard, flagging review
โ”‚   โ”‚   โ”œโ”€โ”€ answers/               # Answer cards, forms, accepted answer UI
โ”‚   โ”‚   โ”œโ”€โ”€ auth/                  # ProtectedRoute, GuestRoute guards
โ”‚   โ”‚   โ”œโ”€โ”€ layout/                # Navbar, Sidebar, Footer, Layout shell
โ”‚   โ”‚   โ”œโ”€โ”€ notifications/         # Real-time notification bell & dropdown
โ”‚   โ”‚   โ”œโ”€โ”€ questions/             # QuestionCard, QuestionForm, QuestionFeed
โ”‚   โ”‚   โ”œโ”€โ”€ search/                # SearchBar with voice input & type-ahead
โ”‚   โ”‚   โ””โ”€โ”€ ui/                    # Design system: Button, Modal, Toast,
โ”‚   โ”‚                              #   Card, Input, Avatar, Badge, Skeleton,
โ”‚   โ”‚                              #   Tooltip, ThemeToggle, BackToTop
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ supabase.js            # Supabase client initialization
โ”‚   โ”œโ”€โ”€ contexts/
โ”‚   โ”‚   โ””โ”€โ”€ AuthContext.jsx        # Global auth state with session persistence
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ”œโ”€โ”€ useAdmin.js            # Admin moderation & flagging operations
โ”‚   โ”‚   โ”œโ”€โ”€ useAnswers.js          # Answer CRUD + verification + accepted answers
โ”‚   โ”‚   โ”œโ”€โ”€ useAuth.js             # Auth context consumer
โ”‚   โ”‚   โ”œโ”€โ”€ useCategories.js       # Category fetching
โ”‚   โ”‚   โ”œโ”€โ”€ useFileUpload.js       # Supabase Storage file uploads
โ”‚   โ”‚   โ”œโ”€โ”€ useNotifications.js    # Notification state management
โ”‚   โ”‚   โ”œโ”€โ”€ useQuestions.js        # Question CRUD + upvoting + deletion
โ”‚   โ”‚   โ”œโ”€โ”€ useSearch.js           # Fuzzy search + type-ahead + analytics
โ”‚   โ”‚   โ”œโ”€โ”€ useSpeechToText.js     # ๐ŸŽ™๏ธ Web Speech API (STT) hook
โ”‚   โ”‚   โ”œโ”€โ”€ useTextToSpeech.js     # ๐Ÿ”Š SpeechSynthesis (TTS) hook
โ”‚   โ”‚   โ””โ”€โ”€ useUpvote.js           # Optimistic upvote toggling
โ”‚   โ”œโ”€โ”€ lib/                       # Utility functions
โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”œโ”€โ”€ AdminDashboard.jsx     # Metrics, bulk moderation, flag queue
โ”‚   โ”‚   โ”œโ”€โ”€ AskQuestionPage.jsx    # Question form with voice dictation
โ”‚   โ”‚   โ”œโ”€โ”€ FaqPage.jsx            # FAQ browser with STT & TTS
โ”‚   โ”‚   โ”œโ”€โ”€ ForgotPasswordPage.jsx # Email-based password reset
โ”‚   โ”‚   โ”œโ”€โ”€ HomePage.jsx           # Main feed with category filtering
โ”‚   โ”‚   โ”œโ”€โ”€ LoginPage.jsx          # Email/password login
โ”‚   โ”‚   โ”œโ”€โ”€ NotFoundPage.jsx       # Animated 404 page
โ”‚   โ”‚   โ”œโ”€โ”€ ProfilePage.jsx        # Stats, reputation, badges
โ”‚   โ”‚   โ”œโ”€โ”€ QuestionDetailPage.jsx # Full question + answers + accepted
โ”‚   โ”‚   โ”œโ”€โ”€ SearchPage.jsx         # Global search results
โ”‚   โ”‚   โ””โ”€โ”€ SignupPage.jsx         # User registration
โ”‚   โ”œโ”€โ”€ App.jsx                    # Route definitions with AnimatePresence
โ”‚   โ”œโ”€โ”€ main.jsx                   # App entry point
โ”‚   โ””โ”€โ”€ index.css                  # Global styles & design tokens
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ vite.config.js
โ”œโ”€โ”€ vercel.json                    # Vercel SPA routing config
โ””โ”€โ”€ package.json

๐Ÿ’ป Technology Stack

Layer Technology Version Purpose
Frontend Framework React 19 Component architecture with hooks
Build Tool Vite 8 Lightning-fast HMR and optimized production builds
Styling Tailwind CSS v4 CSS-first utility engine with design tokens
Animations Framer Motion 12 Spring-physics transitions & micro-interactions
Icons Lucide React 1.17 Consistent, tree-shakeable icon library
Forms React Hook Form 7 Performant form state management
Routing React Router 7 Client-side navigation with route guards
Backend & DB Supabase PostgreSQL Auth, Database, Storage, Realtime
Search Engine Fuse.js 7 Client-side fuzzy matching & similarity scoring
Voice Input Web Speech API Native Browser speech-to-text recognition
Audio Output SpeechSynthesis API Native Browser text-to-speech playback

| Deployment | Vercel | โ€” | Edge-optimized SPA hosting |


๐Ÿ—„๏ธ Database Schema

The PostgreSQL database is organized into 8+ core tables with strict relational constraints, Row-Level Security (RLS) policies, and cascade delete rules:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    auth.users     โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚      users       โ”‚     โ”‚    categories    โ”‚
โ”‚  (Supabase Auth)  โ”‚     โ”‚  id, name, email โ”‚     โ”‚  id, name, icon  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚  role, avatar    โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚  reputation, rank โ”‚              โ”‚
                          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
                                  โ”‚                         โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚             โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚        questions          โ”‚
              โ”‚  id, title, description   โ”‚
              โ”‚  category, tags, views    โ”‚
              โ”‚  upvotes, attachment_url  โ”‚
              โ”‚  flags                    โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚           โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚    answers     โ”‚  โ”‚ question_upvotes   โ”‚
        โ”‚  id, content   โ”‚  โ”‚ question_id,       โ”‚
        โ”‚  verification  โ”‚  โ”‚ user_id (PK)       โ”‚
        โ”‚  is_accepted   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚  admin_note    โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚  answer_upvotes    โ”‚     โ”‚   notifications   โ”‚
        โ”‚  answer_id,        โ”‚     โ”‚  id, user_id,     โ”‚
        โ”‚  user_id (PK)      โ”‚     โ”‚  message, is_read โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚  search_analytics    โ”‚
        โ”‚  id, search_term,    โ”‚
        โ”‚  user_id, created_at โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Database Features

Feature Implementation
Auto User Profiles Database trigger on auth.users INSERT automatically creates a public.users row
Cascade Deletes Deleting a question removes all associated answers, upvotes, and notifications
Duplicate Vote Prevention Composite primary keys on upvote tables enforce one-vote-per-user
Trending Analytics RPC function get_trending_searches() returns top 10 search terms from the past 7 days
Toggle Upvotes RPC functions atomically insert/delete upvote records and update counters
16+ RLS Policies Fine-grained row-level security ensuring users only access authorized data
Reputation Tracking Points calculated from user actions and stored for leaderboard rankings

๐ŸŽ™๏ธ Voice & Accessibility Features

Speech-to-Text (Voice Search / Voice Chat)

The useSpeechToText hook wraps the native Web Speech Recognition API to provide hands-free voice input across the platform:

Feature Details
Continuous Recognition Keeps listening until manually stopped
Interim Results Shows real-time transcription as you speak
Multi-Language Defaults to en-US, configurable via lang parameter
Error Recovery Graceful handling of microphone permission errors
Used In Search bar, Ask Question (title + description), FAQ search

Text-to-Speech (Read Aloud)

The useTextToSpeech hook uses the native SpeechSynthesis API for audio content playback:

Feature Details
One-Tap Playback Single button to play/stop on any content
Unique Tracking Each content item has a unique speech ID to track active playback
Auto Cleanup Speech synthesis is cancelled on component unmount
Used In Question cards, FAQ answer panels

๐Ÿš€ Getting Started

Prerequisites

Requirement Minimum Version
Node.js v18+
npm v9+
Supabase Account Free Tier

Installation

1. Clone & Install

git clone https://github.com/sonivishal66666/Answerhub.git
cd Answerhub
npm install

2. Database Setup

  1. Create a new project on the Supabase Dashboard
  2. Navigate to SQL Editor โ†’ New Query โ†’ Blank Query
  3. Copy the entire contents of supabase/schema.sql and paste into the editor
  4. Click Run โ€” this creates all tables, triggers, RLS policies, indexes, and seed data

3. Storage Configuration

  1. In the Supabase Dashboard, go to Storage
  2. Click New Bucket โ†’ name it attachments
  3. Toggle Public Bucket to ON โ†’ Click Create

4. Environment Configuration

cp .env.example .env

Update .env with your Supabase project credentials:

VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key-here

5. Launch Development Server

npm run dev

Open http://localhost:5173 in your browser.

6. Production Build

npm run build
npm run preview     # Preview the production build locally

๐Ÿ”‘ Admin Dashboard Setup

To activate the admin moderation dashboard:

  1. Create an account on the running application via Sign Up
  2. Open the Supabase Dashboard โ†’ Table Editor โ†’ users table
  3. Locate your user row and change the role column from user to admin
  4. Refresh your browser โ€” the Admin link will appear in the navigation bar

Admin Capabilities

Capability Description
๐Ÿ“Š Platform Metrics Total questions, answers, pending reviews, user counts, and reputation stats
โœ… Bulk Moderation Approve, reject, or flag multiple answers at once
๐Ÿ—‘๏ธ Question Deletion Delete any question with premium animated confirmation dialogs
๐Ÿšฉ Flag Review Queue Review and resolve community-flagged content
๐Ÿ“ Admin Notes Attach feedback notes to reviewed answers
๐Ÿ”” Auto-Notifications Authors are notified of verification decisions in real-time
๐Ÿ† Reputation Management View and manage user reputation and badge assignments

๐ŸŒ Deployment

Vercel (Recommended)

  1. Push your repository to GitHub
  2. Import the project on Vercel
  3. Add environment variables:
    • VITE_SUPABASE_URL
    • VITE_SUPABASE_ANON_KEY
  4. Deploy โ€” the included vercel.json handles SPA routing automatically

Manual Build

npm run build          # Outputs to ./dist
npx serve dist         # Serve locally for testing

๐ŸŽฏ Complete Feature Summary

# Feature Description
1 ๐Ÿ” Role-Based Access Control Guest, User, and Admin permission tiers
2 ๐Ÿ›ก๏ธ Moderated Answer Pipeline Admin-verified answers with 4-state workflow
3 ๐Ÿ† Reputation System Points for actions (ask, answer, upvote, accepted)
4 ๐ŸŽ–๏ธ Badge System Bronze, Silver, Gold, and Special achievement badges
5 ๐Ÿ”ฅ Leaderboard Live rankings of top contributors
6 โœ… Accepted Answers Question owners mark the best answer (+30 pts)
7 ๐Ÿ“ˆ Progress Tracker Visual progress bars toward next badge
8 ๐ŸŽ™๏ธ Voice Search (Voice Chat) Hands-free voice input across the platform
9 ๐Ÿ”Š Text-to-Speech Listen to questions and FAQ answers
10 ๐ŸŒ Translation Multi-language translation for questions & answers
11 ๐Ÿ” Type-Ahead Autocomplete search suggestions as you type
12 ๐Ÿšฉ Content Flagging Flag inappropriate questions or answers
13 ๐Ÿ“ Track Your Questions Real-time status tracking for submissions
14 ๐Ÿ”‘ Forgot Password Email-based password reset flow
15 ๐Ÿง  Duplicate Detection Fuse.js fuzzy matching with similarity scores
16 ๐Ÿšซ Spam Detector Heuristic auto-flagging of spam content
17 ๐Ÿ”ฎ AI Summarizer Client-side NLP extractive summaries
18 ๐Ÿ“Ž File Attachments Upload images and documents to questions/answers
19 ๐Ÿ”” Real-Time Notifications In-app notification bell with live updates
20 ๐ŸŽจ Obsidian & Paper Themes Cinematic dark/light theme system
21 โœจ Spring-Physics Animations Framer Motion transitions & micro-interactions
22 ๐ŸŒŒ Cosmic Particle Backdrops Floating particle emitter with ambient nebulas

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m "feat: add amazing feature"
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.



Built with โค๏ธ for knowledge-sharing communities


GitHub Stars GitHub Forks