Skip to content

vicharanashala/cs20

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

121 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 PippaQ β€” Semantic Q&A & FAQ Platform

A high-performance, semantic query-resolution and FAQ generation platform featuring a QP (Quality Point) reputation economy, role-based access control, Qdrant Cloud vector search, local Sentence Transformers, and admin-controlled email whitelist signup. Users raise real-time queries (RTQs), get peer/moderator/senior answers, and high-quality content graduates into an approved FAQ knowledge base.

Stack: React + Vite | Express.js + MongoDB | Qdrant Cloud | Sentence Transformers (all-MiniLM-L6-v2)


✨ Features

πŸ” Authentication & Access Control

  • Email whitelist-gated signup with OTP verification
  • Role-based access control β€” Student, Moderator, Senior, Admin
  • JWT authentication with role + QP payload
  • Access request flow for non-whitelisted users (admin approval required)
  • Re-access request system for blocked users
  • 100 QP welcome bonus on account activation

πŸ‘¨β€πŸŽ“ Peer Panel (Student & Moderator)

Page Feature Description
Dashboard Quick Stats Personal QP score, rank, recent activity, quick links to all features
RTQ Page Real-Time Questions Browse, search, filter by status/category, expand answers inline
Raise Question Ask a Question Submit questions through RAG duplicate detection engine
Track Questions Personal Tracker Track own submitted questions with interactive status selectors
FAQ Page Knowledge Base Browse approved FAQs by category, upvote, search
Leaderboard Rankings Peer leaderboard (Student/Moderator) with crown & trophy badges
Notifications Activity Feed QP changes, approvals, rejections, promotions
QP History Transaction Log Full history of QP earnings and deductions

πŸŽ“ Senior Panel (Senior & Admin)

Page Feature Description
Dashboard Command Center Senior-specific stats, quick actions, pending reviews
RTQ Management Full Control Accept/reject questions, approve/reject answers, flag for review, permanently remove
Add to FAQ Controlled Conversion Multi-step review modal to convert resolved RTQs into approved FAQs
Add New FAQ Manual Creation Directly create new FAQ entries with category and tags
Working History Personal Audit Trail Track all RTQ→FAQ conversions performed by the senior
Leaderboard Senior Rankings Independent senior/admin leaderboard track
FAQ Conversion Requests Review Panel Approve/reject FAQ conversion requests from moderators
User Management Admin Controls Whitelist management, access request approvals, role assignments, block/unblock users

🧠 RAG Duplicate Detection Engine

  • Semantic Embeddings via local @xenova/transformers (all-MiniLM-L6-v2, 384-dim vectors)
  • Qdrant Cloud ANN Search with HNSW indexes and cosine distance
  • Decision Tree evaluates FAQ + RTQ similarity to accept, reject, or penalize duplicate submissions
  • LRU Embedding Cache (500 entries) for sub-10ms repeated queries
  • Auto-Upvote Engine β€” duplicate submissions automatically upvote matching FAQ/RTQ entries

πŸ’° QP Reputation Economy

  • Granular point system rewarding quality contributions across all roles
  • Automatic penalties for duplicate/low-quality submissions
  • QP < 50 β†’ Question-raising restricted
  • QP β‰₯ 500 β†’ Auto-promotion request to Moderator
  • 100 QP welcome bonus on first signup
  • Full transaction history with notifications

🎨 Design System

The UI follows a premium academic-tech aesthetic inspired by Linear and Notion β€” minimal, structured, and trustworthy.

Typography

Font Usage
Playfair Display Brand accent, logo, elegant headings
Outfit Body text, navigation, UI elements

Design Principles

  • Glassmorphism β€” Frosted-glass overlays with backdrop blur for modals and search
  • Gradient Accents β€” Accent-to-violet gradient buttons, badges, and icon containers
  • Micro-Animations β€” Accordion transitions, scale-in modals, hover effects, floating elements
  • Card-Based Layout β€” Consistent card design with subtle shadows and border accents
  • Status-Coded Borders β€” Left border color coding (green/amber/red) for question status

Shared Component Library

Component Description
Nav Persistent navbar with PippaQ branding, QP animation, and global search
GlobalSearch "/" shortcut overlay searching FAQ + RTQ simultaneously
UpvoteButton Toggleable upvote with optimistic updates
Avatar Role-colored avatar with initials
StatusBadge Dynamic role-aware status badges (moderator=blue, senior=purple)
EmptyState Illustrated empty state with optional action button
SkeletonLoader Shimmer loading placeholders for all page layouts
BackToTop Smooth scroll-to-top floating button
Breadcrumb Navigation breadcrumb trail
MiniChart SVG sparkline for 7-day trend charts

πŸ“Έ App Screenshots

πŸ”‘ General (Auth & Profile)


Sign Up

Login

Request Approval

Profile

πŸ‘¨β€πŸŽ“ Peer Panel (Student & Moderator)


Peer Dashboard

Real-Time Questions

RAG Duplicate Check

Track Questions

Peer Leaderboard

FAQ Page (Moderator View)

RTQ Moderation

RTQ Moderation Actions

FAQ Conversion Request Modal

πŸŽ“ Senior Panel (Senior & Admin)


Senior Dashboard

FAQ Management

RTQ Management

Senior RTQ Actions

Add to FAQ Modal

Working History

Senior Leaderboard

Admin Whitelist Management

Admin Access Requests

πŸ—οΈ Project Structure

FAQ/
β”œβ”€β”€ SPEC.md                              # Project specification
β”œβ”€β”€ CONTEXT.md                           # Detailed implementation context
β”œβ”€β”€ README.md
β”‚
β”œβ”€β”€ client/                              # React + Vite frontend
β”‚   └── src/
β”‚       β”œβ”€β”€ App.jsx                      # Role-based dashboard routing
β”‚       β”œβ”€β”€ index.css                    # Design system (Playfair Display & Outfit)
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ Nav.jsx                  # Persistent navbar with QP animation
β”‚       β”‚   β”œβ”€β”€ GlobalSearch.jsx         # "/" shortcut β†’ overlay search FAQ+RTQ
β”‚       β”‚   β”œβ”€β”€ UpvoteButton.jsx         # Toggleable upvote with optimistic UI
β”‚       β”‚   β”œβ”€β”€ Avatar.jsx              # Role-colored avatar
β”‚       β”‚   β”œβ”€β”€ Badge.jsx               # Status badges (accepted/rejected/review)
β”‚       β”‚   β”œβ”€β”€ MiniChart.jsx           # SVG sparkline for trend charts
β”‚       β”‚   └── ...                     # EmptyState, BackToTop, Breadcrumb, etc.
β”‚       β”œβ”€β”€ context/
β”‚       β”‚   β”œβ”€β”€ AuthContext.jsx          # JWT auth with role + QP
β”‚       β”‚   └── QPContext.jsx            # QP state management
β”‚       β”œβ”€β”€ pages/
β”‚       β”‚   β”œβ”€β”€ LoginPage.jsx            # PippaQ branded login
β”‚       β”‚   β”œβ”€β”€ SignupPage.jsx           # Whitelist signup + access request flow
β”‚       β”‚   β”œβ”€β”€ StudentDashboard.jsx     # Student/Moderator dashboard
β”‚       β”‚   β”œβ”€β”€ SeniorDashboard.jsx      # Senior/Admin dashboard
β”‚       β”‚   β”œβ”€β”€ FAQPage.jsx              # Knowledge base with categories & upvotes
β”‚       β”‚   β”œβ”€β”€ RTQPage.jsx              # Real-time questions list
β”‚       β”‚   β”œβ”€β”€ RTQDetailPage.jsx        # Full question detail + answers
β”‚       β”‚   β”œβ”€β”€ RaiseQuestionPage.jsx    # Submit question (RAG-evaluated)
β”‚       β”‚   β”œβ”€β”€ TrackQuestionPage.jsx    # Track own questions
β”‚       β”‚   β”œβ”€β”€ UserListPage.jsx         # Leaderboard + Admin user management
β”‚       β”‚   β”œβ”€β”€ WorkingHistoryPage.jsx   # Senior's conversion history
β”‚       β”‚   β”œβ”€β”€ AboutPage.jsx            # Interactive About page with symbolism
β”‚       β”‚   └── ...                      # Profile, QP History, Add FAQ, etc.
β”‚       └── services/
β”‚           β”œβ”€β”€ api.js                   # Axios instance with interceptors
β”‚           β”œβ”€β”€ auth.service.js          # Auth API methods
β”‚           β”œβ”€β”€ faq.service.js           # FAQ CRUD + conversion requests
β”‚           β”œβ”€β”€ rtq.service.js           # RTQ operations
β”‚           └── dashboard.service.js     # Dashboard stats + activity feed
β”‚
β”œβ”€β”€ server/                              # Express.js backend
β”‚   └── src/
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   β”œβ”€β”€ db.js                    # MongoDB connection
β”‚       β”‚   β”œβ”€β”€ env.js                   # Environment config
β”‚       β”‚   └── qdrant.js               # Qdrant Cloud singleton client
β”‚       β”œβ”€β”€ controllers/
β”‚       β”‚   β”œβ”€β”€ auth.controller.js       # Signup, OTP, login
β”‚       β”‚   β”œβ”€β”€ faq.controller.js        # FAQ CRUD + review/trending
β”‚       β”‚   β”œβ”€β”€ faq-conversion.controller.js  # Conversion request workflow
β”‚       β”‚   β”œβ”€β”€ rtq.controller.js        # RTQ submit + moderation + QP loops
β”‚       β”‚   β”œβ”€β”€ rag.controller.js        # RAG evaluation + vector rebuild
β”‚       β”‚   β”œβ”€β”€ admin.controller.js      # User CRUD, roles, block/unblock
β”‚       β”‚   β”œβ”€β”€ admin.whitelist.controller.js  # Whitelist + access requests
β”‚       β”‚   β”œβ”€β”€ categoryUpvote.controller.js   # Category ranking + upvotes
β”‚       β”‚   └── qp.controller.js         # QP score + history
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   β”œβ”€β”€ User.model.js            # Roles: student|moderator|senior|admin
β”‚       β”‚   β”œβ”€β”€ FAQ.model.js             # FAQ with review & trending flags
β”‚       β”‚   β”œβ”€β”€ RTQ.model.js             # RTQ with bidirectional FAQ link
β”‚       β”‚   β”œβ”€β”€ Answer.model.js          # Approvals/rejections + review flag
β”‚       β”‚   β”œβ”€β”€ QPTransaction.model.js   # QP earn/deduct ledger
β”‚       β”‚   β”œβ”€β”€ Notification.model.js    # Role-scoped notifications
β”‚       β”‚   β”œβ”€β”€ FAQConversionRequest.model.js  # Moderatorβ†’Senior conversion requests
β”‚       β”‚   β”œβ”€β”€ EmailWhitelist.model.js  # Admin-controlled signup gate
β”‚       β”‚   β”œβ”€β”€ AccessRequest.model.js   # Non-whitelisted signup requests
β”‚       β”‚   └── ...                      # CategoryUpvote, RoleRequest, Question
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   β”œβ”€β”€ auth.service.js          # Signup + OTP + JWT generation
β”‚       β”‚   β”œβ”€β”€ qp.service.js            # Award/deduct QP + auto-promotion
β”‚       β”‚   β”œβ”€β”€ autoupvote.service.js    # Atomic auto-upvote on duplicates
β”‚       β”‚   β”œβ”€β”€ notification.service.js  # Notification creation
β”‚       β”‚   β”œβ”€β”€ vector/                  # Qdrant vector services
β”‚       β”‚   β”‚   β”œβ”€β”€ transformer.service.js   # Local Sentence Transformer + LRU cache
β”‚       β”‚   β”‚   β”œβ”€β”€ embedding.service.js     # Embedding pipeline
β”‚       β”‚   β”‚   β”œβ”€β”€ faq.vector.service.js    # FAQ vector CRUD in Qdrant
β”‚       β”‚   β”‚   └── rtq.vector.service.js    # RTQ vector CRUD in Qdrant
β”‚       β”‚   └── sync/                    # MongoDB ↔ Qdrant sync
β”‚       β”‚       β”œβ”€β”€ faq.sync.service.js      # FAQ sync + rollback
β”‚       β”‚       β”œβ”€β”€ rtq.sync.service.js      # RTQ sync + rollback
β”‚       β”‚       └── sync.repair.service.js   # Missing/stray vector detection
β”‚       └── routes/                      # Express route definitions
β”‚
β”œβ”€β”€ rag-engine/                          # RAG Decision Engine
β”‚   └── decision-engine/
β”‚       └── decision.tree.js             # Semantic duplicate detection via Qdrant ANN
β”‚
β”œβ”€β”€ shared/
β”‚   └── constants.js                     # FAQ_CATEGORIES, QP_RULES, ROLES, RAG_THRESHOLDS
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ migrate-categories.js            # Category normalization migration
β”‚   └── bulk-import.js                   # Bulk FAQ import utility
β”‚
└── assets/
    └── UI_Visuals/                      # App screenshots for README

πŸ› οΈ Tech Stack

Layer Technology
Frontend React 18, Vite, React Router v6, Axios
Styling Tailwind CSS + Premium Typography (Playfair Display & Outfit via Google Fonts)
Backend Express.js, Mongoose ODM, JWT (bcryptjs)
Database MongoDB (Atlas)
Vector Store Qdrant Cloud (HNSW indexes, cosine distance, 384-dim, metadata payload filters)
Embeddings @xenova/transformers β€” local WebAssembly/ONNX execution of all-MiniLM-L6-v2
Dev Tools concurrently (parallel client + server), Vite HMR

🧠 RAG Duplicate Detection Engine

Questions are evaluated semantically against the FAQ and RTQ collections stored in Qdrant:

User Question
      β”‚
      β–Ό
Generate Embedding ──► Local Sentence Transformer (all-MiniLM-L6-v2, 384-dim)
      β”‚
      β–Ό
Qdrant HNSW ANN Search ──► Compare with FAQ/RTQ Collections
      β”‚
      β–Ό
Apply Decision Tree Rules:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ F1: FAQ similarity > 80%      β”‚ REJECT, -5 QP, upvote FAQ     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ F2: FAQ similarity 50–80%     β”‚                               β”‚
β”‚  β”œβ”€β”€ R1: RTQ > 60%            β”‚ REJECT, -5 QP, upvote FAQ     β”‚
β”‚  β”œβ”€β”€ R2: RTQ 20–60%           β”‚ REJECT (no penalty)           β”‚
β”‚  └── R3: RTQ ≀ 20%            β”‚ ACCEPT β†’ Route to RTQ         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ F3: FAQ similarity ≀ 50%      β”‚                               β”‚
β”‚  β”œβ”€β”€ R1: RTQ > 60%            β”‚ REJECT (no penalty), upvote   β”‚
β”‚  └── R2/R3: RTQ ≀ 60%         β”‚ ACCEPT β†’ Route to RTQ         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Performance: Includes an LRU Embedding Cache (500 entries) and model warmup on server startup for sub-10ms semantic queries.


πŸ‘₯ Roles & Permissions

Role Key Capabilities
Student Ask RTQ questions, answer (1Γ—/question), upvote, track own questions
Moderator + Approve/reject answers, accept/reject questions, request FAQ conversions
Senior + Create FAQs, convert RTQ→FAQ via review panel, delete content, manage working history
Admin + Manage email whitelist, approve access requests, assign/revoke roles, block/unblock users

πŸ’° QP (Quality Point) Economy

Earning QP

Action QP
Answer a question +2
Answer approved by Moderator/Senior +5
Answer selected for FAQ +10
Question accepted (valid RTQ) +5
Question promoted to FAQ +20
Senior converts RTQ→FAQ +10
Senior creates new FAQ manually +15
Welcome bonus (account activation) +100

Penalties

Action QP
Duplicate FAQ match (F1) -5
F2+R1 match -5
Answer removed by Senior -3
Question removed -5

Thresholds

  • QP < 50 β†’ Cannot raise questions
  • QP β‰₯ 500 β†’ Auto-request Moderator promotion

πŸ“‚ Key API Routes

Route Description
POST /api/auth/signup Register + email OTP verification
POST /api/auth/login JWT login
POST /api/auth/request-access Request signup approval (non-whitelisted)
GET /api/faq List approved FAQs (paginated, searchable)
POST /api/faq Create FAQ (Senior/Admin)
GET /api/rtq List RTQs with filters
POST /api/rtq/question Submit question through RAG engine
POST /api/rtq/:id/answer Add answer to RTQ
POST /api/rag/evaluate-question Run RAG decision tree
POST /api/faq/request-conversion Moderator: request FAQ conversion
GET /api/faq/conversion-requests Senior/Admin: list pending conversions
GET /api/users User list / leaderboard
GET /api/qp/my-score Current QP balance
PATCH /api/admin/assign-role Admin: change user role

πŸ”„ User Flows

Signup & Access

Whitelisted Email β†’ Signup β†’ OTP Verification β†’ 100 QP Welcome Bonus β†’ Login
Non-Whitelisted   β†’ Access Request β†’ Admin Approval β†’ Account Created β†’ Login
Blocked User      β†’ Re-Access Request β†’ Admin Approval β†’ Account Reactivated

Question Lifecycle

Student submits question
      β”‚
      β–Ό
RAG Engine evaluates (FAQ + RTQ similarity)
      β”‚
      β”œβ”€β”€ REJECT (duplicate) β†’ -5 QP penalty, auto-upvote match
      β”‚
      └── ACCEPT β†’ Added to RTQ pool
            β”‚
            β”œβ”€β”€ Peers answer β†’ Moderators approve/reject β†’ QP awarded
            β”‚
            β”œβ”€β”€ Moderator requests FAQ conversion β†’ Senior reviews β†’ Approved/Rejected
            β”‚
            └── Senior converts to FAQ directly β†’ Published to Knowledge Base

Multi-Moderator Decision Flow

Moderator Action on Question:
  β”œβ”€β”€ Accept β†’ Status: resolved, +5 QP to questioner, +3 QP to moderator
  β”œβ”€β”€ Reject (1st) β†’ Status: rejected, +3 QP to moderator
  └── Reject (2nd, different moderator) β†’ Permanent deletion, -5 QP to questioner

πŸš€ Getting Started

Prerequisites

Setup

  1. Clone the repository

    git clone https://github.com/vicharanashala/cs20.git
    cd cs20
  2. Install all dependencies

    npm run install:all
  3. Configure environment

    cp server/.env.example server/.env
    # Edit server/.env β€” set MONGO_URI, JWT_SECRET, QDRANT_URL, QDRANT_API_KEY
  4. Run the app

    npm run dev

πŸ›‘οΈ System Guarantees

  • βœ… Semantic duplicate detection via Qdrant ANN before any question is accepted
  • βœ… Atomic QP transactions with rollback-safe decision changes
  • βœ… Bidirectional RTQ↔FAQ traceability for all conversions
  • βœ… Multi-moderator approval/rejection with collusion prevention (max 2 per moderator)
  • βœ… Auto-upvote on duplicate detection rewards original authors
  • βœ… Role-based UI constraints β€” actions are hidden from unauthorized roles
  • βœ… Idempotent decision rollbacks when moderators change their verdict
  • βœ… MongoDB ↔ Qdrant sync with automatic rollback on vector store failures
  • βœ… 100 QP welcome bonus across all account activation paths
  • βœ… Email whitelist gate prevents unauthorized signups

πŸ“„ License

Authors: Vicharanashala Team


Built with ❀️ using React, Express, MongoDB & Qdrant

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages