CampusQuest
Gamified college bucket-list engine for JavaScript and Node.js applications.
CampusQuest enables students and educational applications to turn college experiences into actionable quests, earn XP, unlock achievements, maintain daily completion streaks, and view insightful analytics.
Highlights
- Zero Runtime Dependencies: Ultra-lightweight and fast.
- Node.js & Browser Support: Native ES Modules compatible with Node 18+ and modern browsers.
- Quest Lifecycle: Add, update, delete, filter, and complete bucket-list quests.
- Gamified Leveling: XP rewards by difficulty (
easy: 50 XP, medium: 100 XP, hard: 200 XP) and smooth progression curves.
- Achievement Engine: Built-in milestone detection with custom achievement registration.
- Streak Tracker: Consecutive day completion tracking with same-day deduplication.
- Storage Adapters: In-memory and browser localStorage adapters included, with support for custom backends.
- Event System: Built-in pub/sub emitter for reactive application architectures.
- TypeScript Ready: Complete typings included.
Installation
npm install campusquest
Quick Start
import { CampusQuest, LocalStorageAdapter } from 'campusquest';
const quest = new CampusQuest({
username: 'Ankur',
storage: new LocalStorageAdapter()
});
// Listen for events
quest.on('quest:completed', ({ quest, xpEarned, totalXP, levelUp }) => {
console.log(`Completed: ${quest.title} (+${xpEarned} XP)`);
if (levelUp) {
console.log(`Leveled up! Current level: ${quest.getCurrentLevel?.() || 'Upgraded'}`);
}
});
// Add a quest
const newQuest = quest.addQuest({
title: 'Participate in a Hackathon',
description: 'Form a team and build a prototype in 24 hours.',
category: 'career',
difficulty: 'hard'
});
// Complete the quest
quest.completeQuest(newQuest.id);
Categories & Difficulty
Supported categories:
academic
career
social
adventure
fitness
personal
Difficulty rewards:
easy: 50 XP
medium: 100 XP
hard: 200 XP
Core API Reference
Quest Operations
quest.addQuest(input): Adds a new quest and returns the created quest object.
quest.getQuest(id): Fetches a quest by ID.
quest.getQuests(filters): Retrieves quests matching category, difficulty, or completion status.
quest.updateQuest(id, updates): Updates an existing quest.
quest.deleteQuest(id): Removes a quest and adjusts XP if it was completed.
quest.completeQuest(id, options): Marks a quest complete, awards XP, updates streaks, and triggers achievement checks.
quest.getRandomQuest(filters): Returns a random pending quest.
Progression & Metrics
quest.getTotalXP(): Returns current total XP.
quest.getCurrentLevel(): Returns current numerical level.
quest.getLevelInfo(): Provides level title, progress percentage, and XP needed for next level.
quest.getStreakInfo(): Returns current streak, longest streak, and completion dates.
quest.getAnalytics(): Comprehensive breakdown of quests, categories, and achievements.
Persistence & Data
quest.exportJSON(options): Exports full state as a JSON string.
quest.importJSON(data, options): Imports valid state data.
quest.reset(): Resets all progress.
Interactive Demo
To run the interactive React & Vite demo dashboard:
npm run demo
Testing
Run unit tests via Vitest:
npm test
License
MIT