- Overview
- Architecture
- Tech Stack
- Features
- Prerequisites
- Installation
- Firebase Setup
- Environment Configuration
- Running the Project
- Project Structure
- Core Systems
- Component Architecture
- State Management
- API Integration
- Styling System
- Testing
- Deployment
- Contributing
OPTIMUM is a comprehensive Adaptive Testing System built with modern web technologies. It features intelligent difficulty adjustment, AI-powered question generation, real-time analytics, proctoring capabilities, and a premium user interface with smooth animations.
- Adaptive Algorithm: Dynamic difficulty adjustment based on real-time performance
- AI Integration: OpenRouter AI for automated question generation from PDFs
- Real-time Database: Firebase Realtime Database for instant synchronization
- Modern UI/UX: Custom animations, dark mode, responsive design
- Performance Tracking: Comprehensive analytics and visualization
- Proctoring: Tab switching and fullscreen monitoring
- Accessibility: WCAG compliant with keyboard navigation
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Student β β Admin β β Auth β β
β β Dashboard β β Dashboard β β System β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Adaptive Test Engine (Client-side) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Firebase Services β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Auth β β Realtime β β Storage β β
β β β β Database β β β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β External Services β
β ββββββββββββββββ ββββββββββββββββ β
β β OpenRouter β β EmailJS β β
β β AI β β β β
β ββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Authentication: Firebase Auth β User Context β Protected Routes
- Test Taking: Student β Adaptive Engine β Firebase DB β Real-time Updates
- AI Generation: PDF Upload β OpenRouter API β Question Parsing β Database
- Analytics: Database β Performance Service β Chart.js Visualization
- React 18.3.1 - Component-based UI library
- TypeScript 5.5.3 - Type-safe development
- Vite 5.4.2 - Lightning-fast build tool
- React Router DOM 7.7.1 - Client-side routing
- TailwindCSS 3.4.1 - Utility-first CSS framework
- Custom CSS Animations - Smooth transitions and effects
- Lucide React - Modern icon library
- Dark Mode - System-aware theme switching
- Firebase 12.0.0
- Authentication (Email/Password, Google)
- Realtime Database (NoSQL)
- Storage (File uploads)
- OpenRouter AI - Question generation
- EmailJS - Contact form emails
- Chart.js 4.5.0 - Interactive charts
- React Chart.js 2 - React wrapper
- XLSX 0.18.5 - Excel file parsing
- PDF.js 5.4.54 - PDF text extraction
- jsPDF 3.0.3 - PDF generation
- html2canvas 1.4.1 - Screenshot capture
- ESLint - Code linting
- TypeScript ESLint - TS-specific linting
- PostCSS - CSS processing
- Autoprefixer - CSS vendor prefixes
- Adaptive test-taking with real-time difficulty adjustment
- Performance dashboard with charts and analytics
- Test history and detailed results
- Answer review with color-coded feedback
- Leaderboard with department filtering
- Profile management with avatar selection
- Dark mode support
- Mobile-responsive design
- Test creation with manual/AI/bulk import
- Question bank management
- Student performance analytics
- Admin user management
- Test configuration (adaptive/non-adaptive)
- Difficulty assignment
- Real-time test monitoring
- PDF result generation
- Real-time database synchronization
- Custom sliding squares loader animation
- Smooth page transitions
- Optimistic UI updates
- Error boundary handling
- Protected routes
- Session management
- Performance optimization
- Node.js >= 18.0.0
- npm >= 9.0.0 or yarn >= 1.22.0
- Git
- Firebase Account (free tier sufficient)
- OpenRouter API Key (optional, for AI features)
- EmailJS Account (optional, for contact form)
git clone https://github.com/nareshAiNexus/Optimum-test.git
cd Optimum-testnpm installcp .env.example .envEdit .env with your configuration (see Environment Configuration)
npm run devApplication will be available at http://localhost:5173
- Visit Firebase Console
- Click "Add Project"
- Enter project name:
optimum-test - Disable Google Analytics (optional)
- Click "Create Project"
- Navigate to Build β Authentication
- Click "Get Started"
- Enable Email/Password provider
- Enable Google provider (optional)
- Go to Build β Realtime Database
- Click "Create Database"
- Select location (closest to your users)
- Start in Test Mode
{
"rules": {
"tests": {
".read": "auth != null",
".write": "auth != null && root.child('users').child(auth.uid).child('role').val() === 'admin'",
"$testId": {
"timesAttempted": {
".write": "auth != null"
}
}
},
"responses": {
".read": "auth != null",
"$testId": {
"$userId": {
".read": "auth != null && ($userId === auth.uid || root.child('users').child(auth.uid).child('role').val() === 'admin')",
".write": "auth != null && ($userId === auth.uid || root.child('users').child(auth.uid).child('role').val() === 'admin')"
}
}
},
"questions": {
".read": "auth != null",
".write": "auth != null && root.child('users').child(auth.uid).child('role').val() === 'admin'"
},
"userTestStates": {
"$userId": {
".read": "auth != null && ($userId === auth.uid || root.child('users').child(auth.uid).child('role').val() === 'admin')",
".write": "auth != null && ($userId === auth.uid || root.child('users').child(auth.uid).child('role').val() === 'admin')"
}
},
"users": {
".read": "auth != null",
"$uid": {
".write": "auth != null && ($uid === auth.uid || root.child('users').child(auth.uid).child('role').val() === 'admin')",
"role": {
".write": "auth != null && root.child('users').child(auth.uid).child('role').val() === 'admin'"
}
}
}
}
}- Go to Project Settings (gear icon)
- Scroll to "Your apps"
- Click web icon (
</>) - Register app name:
OPTIMUM - Copy configuration values to
.env
Create .env file in project root:
# Firebase Configuration
VITE_API_KEY=AIzaSyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
VITE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_DATABASE_URL=https://your-project-default-rtdb.firebaseio.com
VITE_PROJECT_ID=your-project-id
VITE_STORAGE_BUCKET=your-project.firebasestorage.app
VITE_MESSAGE_SENDER_ID=123456789012
VITE_APP_ID=1:123456789012:web:abcdef123456
VITE_MEASUREMENT_ID=G-XXXXXXXXXX
# AI Service (Optional)
VITE_AI_API_KEY=sk-or-v1-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX- Visit OpenRouter.ai
- Sign up / Log in
- Navigate to Keys section
- Create new API key
- Add to
.envasVITE_AI_API_KEY
npm run devRuns on http://localhost:5173 with hot module replacement (HMR)
npm run buildOutputs to dist/ directory
npm run previewnpm run lintoptimum/
βββ public/
β βββ optimum.png # App logo
β βββ sliding-squares.gif # Loading animation
β βββ avatars/ # Profile avatars
βββ src/
β βββ assets/ # Static assets
β β βββ avatars.js # Avatar configuration
β βββ components/
β β βββ admin/ # Admin-only components
β β β βββ AdminDashboard.tsx
β β β βββ AdminManagement.tsx
β β β βββ AiGenerationModal.tsx
β β β βββ CreateTestModal.tsx
β β β βββ EditTestModal.tsx
β β β βββ ResultsView.tsx
β β β βββ StudentProgressModal.tsx
β β β βββ TestManagement.tsx
β β βββ auth/ # Authentication components
β β β βββ AdminLoginForm.tsx
β β β βββ AdminRegisterForm.tsx
β β β βββ EmailVerification.tsx
β β β βββ LoginForm.tsx
β β β βββ RegisterForm.tsx
β β βββ common/ # Shared components
β β β βββ DifficultyBadge.tsx
β β β βββ LoadingSkeleton.tsx
β β β βββ Navbar.tsx
β β β βββ ProtectedRoute.tsx
β β βββ debug/ # Debug utilities
β β β βββ EmailVerificationDebug.tsx
β β βββ student/ # Student-only components
β β βββ Dashboard.tsx
β β βββ Leaderboard.tsx
β β βββ PerformanceTracker.tsx
β β βββ Profile.tsx
β β βββ TestInterface.tsx
β β βββ TestResult.tsx
β βββ contexts/
β β βββ AuthContext.tsx # Authentication context
β βββ hooks/
β β βββ useTestProctor.ts # Proctoring logic
β β βββ useTheme.ts # Theme management
β βββ lib/
β β βββ firebase.ts # Firebase initialization
β βββ pages/
β β βββ AboutUs.tsx
β β βββ ContactUs.tsx
β β βββ Home.tsx
β β βββ PublicDashboard.tsx
β βββ services/
β β βββ adaptiveTestService.ts # Adaptive algorithm
β β βββ aiService.ts # AI question generation
β β βββ emailService.ts # Email verification
β β βββ performanceTrackingService.ts
β β βββ registrationValidation.ts
β βββ styles/
β β βββ animations.css # Custom animations
β βββ utils/
β β βββ pdfUtils.ts # PDF processing
β β βββ testResultsPdfGenerator.ts
β β βββ xlsxUtils.ts # Excel processing
β βββ App.tsx # Main app component
β βββ main.tsx # Entry point
β βββ index.css # Global styles
βββ .env # Environment variables (gitignored)
βββ .env.example # Environment template
βββ .gitignore
βββ eslint.config.js
βββ index.html
βββ package.json
βββ postcss.config.js
βββ tailwind.config.js
βββ tsconfig.json
βββ tsconfig.app.json
βββ tsconfig.node.json
βββ vite.config.ts
βββ README.md
Location: src/services/adaptiveTestService.ts
Algorithm:
// Difficulty progression logic
if (correctStreak >= 2) {
increaseDifficulty();
} else if (wrongStreak >= 2) {
decreaseDifficulty();
}
// Weighted scoring
const points = {
easy: 1,
medium: 2,
hard: 3
};Features:
- Real-time difficulty adjustment
- Streak-based progression
- Weighted scoring system
- Performance analytics
Location: src/services/aiService.ts
Process:
- PDF text extraction using PDF.js
- Text chunking (max 4000 chars)
- OpenRouter API call with prompt engineering
- JSON response parsing
- Question validation and formatting
Supported Models:
- DeepSeek R1 (default)
- GPT-4
- Claude 3
Location: src/services/performanceTrackingService.ts
Metrics:
- Average score calculation
- Test completion rate
- Performance trends
- Difficulty progression
- Time analytics
Location: src/hooks/useTestProctor.ts
Features:
- Tab switch detection
- Fullscreen monitoring
- Violation tracking
- Warning system
- Auto-submission on violations
App
βββ AuthContext Provider
β βββ Navbar
β βββ Routes
β β βββ Public Routes
β β β βββ Home
β β β βββ About
β β β βββ Contact
β β β βββ PublicDashboard
β β βββ Auth Routes
β β β βββ Login
β β β βββ Register
β β βββ Protected Routes (Student)
β β β βββ Dashboard
β β β βββ TestInterface
β β β βββ TestResult
β β β βββ Profile
β β β βββ Leaderboard
β β βββ Protected Routes (Admin)
β β βββ AdminDashboard
β β βββ TestManagement
β β βββ AdminManagement
β β βββ ResultsView
β βββ Theme Provider
- Manages test state
- Implements adaptive logic
- Handles proctoring
- Timer management
- Question navigation
- Fetches performance data
- Renders charts (Chart.js)
- Calculates metrics
- Displays trends
- Test creation form
- Question management
- AI generation integration
- Bulk import support
AuthContext (src/contexts/AuthContext.tsx):
interface AuthContextType {
currentUser: User | null;
userData: UserData | null;
loading: boolean;
login: (email: string, password: string) => Promise<void>;
register: (data: RegisterData) => Promise<void>;
logout: () => Promise<void>;
}- Component State:
useStatefor UI state - Side Effects:
useEffectfor data fetching - Custom Hooks: Reusable logic (useTestProctor, useTheme)
- Refs: DOM manipulation, timers
Firebase DB β Service Layer β Component State β UI
β β
βββββββββββββ User Actions βββββββββββββββββ
Structure:
{
"users": {
"userId": {
"name": "string",
"email": "string",
"role": "student | admin",
"department": "string",
"registrationNumber": "string"
}
},
"tests": {
"testId": {
"title": "string",
"description": "string",
"questions": ["questionId"],
"duration": "number",
"isAdaptive": "boolean"
}
},
"questions": {
"questionId": {
"question": "string",
"options": ["string"],
"correctAnswer": "number",
"difficulty": "easy | medium | hard"
}
},
"responses": {
"testId": {
"userId": {
"score": "number",
"answers": ["number"],
"completedAt": "timestamp"
}
}
}
}Endpoint: https://openrouter.ai/api/v1/chat/completions
Request:
{
model: "deepseek/deepseek-r1",
messages: [{
role: "user",
content: "Generate questions from: [PDF_TEXT]"
}]
}Custom Theme (tailwind.config.js):
theme: {
extend: {
colors: {
'warp-primary': '#6366f1',
'warp-secondary': '#8b5cf6'
},
animation: {
'slide-in-right': 'slideInRight 0.3s ease-out',
'slide-out-right': 'slideOutRight 0.3s ease-in'
}
}
}Sliding Squares Loader (src/styles/animations.css):
@keyframes slide-square-loader-1 {
0%, 100% { transform: translate(0, 0); }
25% { transform: translate(0, 32px); }
50% { transform: translate(32px, 32px); }
75% { transform: translate(32px, 0); }
}
.sliding-squares-loader {
width: 64px;
height: 64px;
}Implementation:
- System preference detection
- localStorage persistence
- CSS variables for theming
- Smooth transitions
- User registration and login
- Admin creation and permissions
- Test creation (manual, AI, bulk)
- Adaptive test taking
- Performance analytics
- PDF generation
- Dark mode switching
- Mobile responsiveness
Admin:
- Email:
admin@gmail.com - Password:
admin@123
Student:
- Email:
student@gmail.com - Password:
student@123
- Push code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy
Configuration (vercel.json):
{
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}- Connect GitHub repository
- Build command:
npm run build - Publish directory:
dist - Add environment variables
- Deploy
npm install -g firebase-tools
firebase login
firebase init hosting
npm run build
firebase deploy- Fork repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
- Use TypeScript for type safety
- Follow React best practices
- Use TailwindCSS for styling
- Write meaningful commit messages
- Add comments for complex logic
feat: Add new feature
fix: Bug fix
docs: Documentation update
style: Code style changes
refactor: Code refactoring
test: Add tests
chore: Maintenance tasks
MIT License - see LICENSE file
- React Team for the framework
- Firebase for backend services
- Vite for build tooling
- TailwindCSS for styling
- Lucide for icons
- OpenRouter for AI capabilities
- Email: optimum-test@gmail.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with by the OPTIMUM Team
