Connect Donors, Save Lives β A real-time blood and platelet donor connection platform that brings donors and patients together.
Live Demo β’ Report Bug β’ Request Feature
- β Runtime Error Resolution: Fixed "HTML Element with id=admin-qr-reader not found" error
- β Robust DOM Handling: Implemented proper element waiting pattern with retry logic
- β Enhanced Camera Initialization: Added safety checks and improved cleanup with error handling
- β Element Validation: Added validation before scanner creation with retry mechanism
- β Production Ready: QR scanners now work reliably in both admin QR checker and event attendance scanner
- β Vercel Compatibility: Resolved "Cannot install with 'frozen-lockfile'" deployment error
- β
Dependency Cleanup: Removed problematic
baseline-browser-mappingdependency - β
Lockfile Management: Updated
.gitignoreto prevent future lockfile conflicts - β
Build Optimization: Created fresh npm lockfile and proper
.vercelignoreconfiguration - β Deployment Ready: Seamless deployment to Vercel with zero configuration issues
- β Beautiful Samarpan Loader: Animated blood drop with rotating rings, multiple size variants
- β Modern Maintenance Page: Light theme design with real-time clock and duration tracking
- β Complete Route Protection: Middleware blocks ALL routes during maintenance except admin and static assets
- β Smart Navbar Integration: Auto-hiding navigation with maintenance indicator
- β Priority-Based Styling: Different colors and messages for maintenance priority levels (low, medium, high, critical)
- β Real-Time Updates: 30-second auto-refresh with connection status monitoring
- β Mobile Responsive: Perfect experience across all devices
- β Professional Design: Glass morphism effects with light theme consistency
- β Blood PNG Integration: Custom blood drop image in maintenance loader
- β Perfect Center Alignment: Maintenance indicator absolutely centered with loader
- β Light Theme Consistency: Maintenance page matches site's current light theme
- β Responsive Navbar: Smart hiding of navigation elements during maintenance
- β Professional Animations: Smooth transitions and GPU-accelerated effects
Samarpan is a comprehensive blood donation management platform designed to connect donors with patients in need of blood and platelets. Built with modern web technologies, it enables real-time connections, efficient donor management, and streamlined administrative operations.
- Real-Time Connections β Instantly connect blood donors with patients in need
- User Authentication β Secure signup, login, and password management
- Donation Tracking β Track your blood donation history and earn certificates
- Request Management β Create and manage blood requests with priority levels
- Event Participation β Join upcoming blood donation events in your area
- Notifications β Real-time alerts for matching blood requests
- User Dashboard β Comprehensive profile and activity management
- Certificate Generation β Automatic certificate creation for donors
- Admin Panel β Centralized dashboard for system management
- User Management β View and manage all registered users
- Donation Management β Track and verify all donations
- Request Management β Review and approve blood requests
- Event Management β Create and manage blood donation events
- QR Code Scanning β Reliable QR code scanning for event check-ins
- Transportation Coordination β Manage transportation logistics
- Notification System β Send bulk notifications to users
- Image Management β View and manage donation images
- Contact Submissions β Review and respond to user inquiries
- Certificate Management β Generate and track donor certificates
- Maintenance Mode β Professional maintenance system with real-time monitoring
- Maintenance System β Complete maintenance mode with route protection
- Real-Time Monitoring β Auto-refresh maintenance status every 30 seconds
- Priority Management β Different maintenance levels (low, medium, high, critical)
- IP Whitelisting β Allow specific IPs to bypass maintenance mode
- Emergency Access β Secret key bypass for emergency access
- Professional UI β Beautiful maintenance page with Samarpan branding
-
Access the Admin Panel
- Visit
/admin/loginin your browser - Use the default credentials:
- Email:
admin@samarpan.com - Password:
admin@123
- Email:
- Change your password immediately after first login
- Visit
-
Understanding the Dashboard
- User Management: View and manage all registered donors
- Event Management: Create and manage blood donation events
- Donation Tracking: Monitor donation activities and certificates
- Notifications: Send bulk notifications to users
- Maintenance Mode: Enable/disable maintenance with custom messages
- Create Events: Go to Admin Dashboard β Events β Create New Event
- Set Event Details: Title, date, location, volunteer slots needed
- Monitor Registrations: View donor registrations and QR codes
- QR Code Scanning: Use reliable QR scanner for event check-ins
- Track Donations: Update donation status and blood test results
- View Donor List: Admin Dashboard β Users β View all registered users
- Event Donors: Events β Select Event β View Registered Donors
- QR Verification: Scan donor QR codes for attendance verification
- Update Blood Types: After blood testing, update donor blood types
- Generate Certificates: Automatically generate donation certificates
- Enable Maintenance: Admin Dashboard β Maintenance Mode
- Set Priority Level: Choose from low, medium, high, or critical
- Custom Messages: Add specific maintenance messages for users
- IP Whitelisting: Allow specific IPs to bypass maintenance
- Emergency Access: Set secret keys for emergency bypass
- Real-Time Monitoring: View maintenance duration and auto-refresh status
- Event Creation: Create event with date, time slots, and location
- Donor Registration: Donors register through the public portal
- Check-in Process: Use QR codes to verify donor arrival (now working reliably)
- Blood Testing: Update blood types after lab results
- Certificate Generation: Generate certificates for completed donations
- Environment Variables: Ensure all required environment variables are set
- Email Configuration: Set up email service for notifications
- Database Backup: Regular backups of MongoDB data
- Admin Permissions: Assign appropriate permissions to staff members
- Maintenance Settings: Configure maintenance mode parameters
- Can't access admin panel: Check login credentials and permissions
- Events not showing: Verify event dates and status
- QR codes not working: β FIXED - QR scanners now work reliably
- Email notifications failing: Check email service configuration
- Maintenance mode issues: β NEW - Complete maintenance system available
- Deployment failures: β FIXED - Vercel deployment now works seamlessly
- Framework: Next.js 16 with App Router
- UI Library: React 19
- Language: TypeScript 5
- Styling: Tailwind CSS 4 + Radix UI components
- State Management: Redux Toolkit
- Form Handling: React Hook Form + Zod validation
- Charts: Recharts
- Icons: Lucide React
- PDF Generation: PDFKit & PDF-Lib
- QR Code Scanning: html5-qrcode (enhanced with robust error handling)
- Runtime: Node.js (Next.js Server)
- Database: MongoDB 6.20
- Authentication: JWT + bcryptjs
- Email: Nodemailer
- Cloud Storage: AWS S3 (via AWS SDK)
- PDF Processing: PDFKit
- Maintenance System: Custom middleware with route protection
- Package Manager: npm/pnpm
- Build Tool: Next.js (Turbopack)
- Linting: ESLint
- Environment: Node.js 18+
- Deployment: Vercel (optimized configuration)
- Node.js 18+ and npm/pnpm
- MongoDB instance (local or Atlas)
- AWS S3 credentials (optional, for file uploads)
- Email service credentials (SendGrid or similar via Nodemailer)
-
Clone the repository:
git clone https://github.com/yourusername/samarpan.git cd samarpan -
Install dependencies:
npm install # or pnpm install -
Configure environment variables:
cp .env.example .env.local
Update
.env.localwith:# Database MONGODB_URL=mongodb+srv://username:password@cluster.mongodb.net/samarpan # JWT JWT_SECRET=your-secret-key-here # Email Service EMAIL_USER=your-email@gmail.com EMAIL_PASSWORD=your-app-password # AWS (optional) AWS_ACCESS_KEY_ID=your-access-key AWS_SECRET_ACCESS_KEY=your-secret-key AWS_S3_BUCKET=your-bucket-name AWS_REGION=us-east-1 # Google OAuth (optional) NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id # Maintenance System (new) MAINTENANCE_INTERNAL_TOKEN=your-internal-token-for-maintenance-checks
-
Set up the database and create super admin:
npm run setup:admin
This initializes the admin system with database indexes and creates the super admin account.
π For detailed admin setup instructions, see Admin Quick Start Guide
-
Start the development server:
npm run dev
The application will be available at
http://localhost:3000
Login at /admin/login:
- Email:
admin@samarpan.com - Password:
admin@123
npm run setup:admin # Recommended: Sets up everything with indexes
npm run create-admin # Interactive: Create super admin or regular admin
npx tsx create-admin.ts # Direct: Create/update super adminβ
Create and manage admin accounts with specific features/permissions
β
Two-tier system: Super Admin (full access) and Regular Admin (limited)
β
Granular permission control (16+ different permissions)
β
Real-time admin dashboard with activity tracking
β
NEW: Comprehensive maintenance mode management
β
FIXED: Reliable QR code scanning system
For complete documentation, see:
- π Admin Quick Start Guide
- π Admin Creation Guide
- π§ Admin System Documentation
- π οΈ Maintenance System Documentation
samarpan/
βββ app/ # Next.js App Router
β βββ (public)/ # Public routes
β β βββ page.tsx # Home page
β β βββ auth/ # Auth routes (login, signup)
β β βββ dashboard/ # User dashboard
β β βββ donate-blood/ # Blood donation requests
β β βββ request-blood/ # Blood request creation
β β βββ events/ # Event listings
β β βββ notifications/ # Notification center
β β βββ maintenance/ # π Maintenance page with blood.png
β β βββ ...
β βββ admin/ # Admin routes
β β βββ login/ # Admin login
β β βββ page.tsx # Admin dashboard
β β βββ ...
β βββ api/ # API routes
β β βββ auth/ # Authentication endpoints
β β βββ admin/ # Admin operations
β β β βββ maintenance/ # π Maintenance mode API
β β β βββ ...
β β βββ blood-request/ # Blood requests API
β β βββ donation-requests/ # Donations API
β β βββ users/ # User management API
β β βββ events/ # Events API
β β βββ notifications/ # Notifications API
β β βββ ...
β βββ layout.tsx # Root layout
β βββ globals.css # Global styles
βββ components/ # React components
β βββ ui/ # Radix UI components
β βββ admin-*.tsx # Admin panel components
β βββ admin-qr-*.tsx # π§ Fixed QR scanner components
β βββ blood-*.tsx # Blood-related components
β βββ samarpan-loader.tsx # π Enhanced loader with blood.png
β βββ maintenance-mode-manager.tsx # π Maintenance management
β βββ navbar.tsx # π§ Enhanced navbar with maintenance mode
β βββ login-form.tsx # Auth forms
β βββ ...
βββ lib/ # Utility functions
β βββ auth.ts # Authentication utilities
β βββ mongodb.ts # Database connection
β βββ email.ts # Email service
β βββ store.ts # Redux store
β βββ slices/ # Redux slices
β βββ maintenance-cache.ts # π Maintenance caching system
β βββ utils.ts # Helper utilities
βββ hooks/ # Custom React hooks
β βββ use-geolocation.ts # Geolocation hook
β βββ use-mobile.ts # Mobile detection
β βββ use-toast.ts # Toast notifications
βββ public/ # Static assets
β βββ maintenance/ # π Maintenance assets
β β βββ blood.png # π Blood drop image for loader
β βββ ...
βββ scripts/ # Utility scripts
β βββ create-admin.ts # Admin creation script
β βββ update-admin-password.ts # Password update script
βββ styles/ # CSS files
βββ package.json # Dependencies (cleaned up)
βββ tsconfig.json # TypeScript config
βββ next.config.mjs # Next.js config
βββ tailwind.config.ts # Tailwind CSS config
βββ middleware.ts # π§ Enhanced middleware with maintenance
βββ .vercelignore # π Vercel deployment config
βββ MAINTENANCE_LIGHT_THEME_UPDATE.md # π Maintenance system docs
- Robust DOM Element Waiting: Implemented retry logic with maximum attempts
- Enhanced Safety Checks: Added element validation before scanner creation
- Improved Cleanup: Better error handling and resource cleanup
- Camera Initialization: Enhanced camera access with proper error handling
- Production Ready: Reliable QR scanning in both admin QR checker and event scanner
- Complete Route Protection: Middleware blocks all routes during maintenance
- Real-Time Monitoring: 30-second auto-refresh with connection status
- Priority-Based Styling: Different colors for maintenance levels
- IP Whitelisting: Allow specific IPs to bypass maintenance
- Emergency Access: Secret key bypass functionality
- Professional UI: Beautiful maintenance page with Samarpan branding
- Mobile Responsive: Perfect experience across all devices
- Vercel Compatibility: Fixed lockfile conflicts and dependency issues
- Build Optimization: Cleaned up problematic dependencies
- Configuration Management: Proper
.vercelignoreand build settings - Zero-Config Deployment: Seamless deployment to Vercel
- Light Theme Consistency: Maintenance page matches site theme
- Perfect Center Alignment: Maintenance indicator aligned with loader
- Smart Navbar: Auto-hiding navigation during maintenance
- Blood Drop Animation: Custom blood.png in maintenance loader
- Glass Morphism: Modern design with subtle effects
POST /api/auth/signup β Register new user
{
"email": "user@example.com",
"password": "secure-password",
"name": "John Doe",
"phone": "+91XXXXXXXXXX",
"bloodType": "O+"
}POST /api/auth/login β User login
{
"email": "user@example.com",
"password": "password"
}POST /api/auth/admin-login β Admin login
{
"email": "admin@samarpan.com",
"password": "admin-password"
}GET /api/admin/maintenance β Get maintenance status
{
"enabled": false,
"message": "Maintenance message",
"priority": "medium",
"enabledAt": "2026-01-02T18:00:00.000Z",
"allowedIps": ["192.168.1.100"],
"secretKey": "emergency-key"
}POST /api/admin/maintenance β Update maintenance settings
{
"enabled": true,
"message": "We are performing scheduled maintenance...",
"priority": "high",
"allowedIps": ["192.168.1.100", "10.0.0.50"],
"secretKey": "emergency-access-2026"
}GET /api/blood-request β Get all blood requests
POST /api/blood-request β Create new blood request
PUT /api/blood-request/[id] β Update blood request
DELETE /api/blood-request/[id] β Delete blood request
GET /api/users β Get all users (admin only)
GET /api/users/[id] β Get user profile
PUT /api/users/[id] β Update user profile
GET /api/events β Get all events
POST /api/events β Create event (admin only)
PUT /api/events/[id] β Update event (admin only)
DELETE /api/events/[id] β Delete event (admin only)
- Password Hashing: bcryptjs with salt rounds = 10
- JWT Tokens: Secure token-based authentication
- Protected Routes: Enhanced middleware-based route protection
- Maintenance Security: IP whitelisting and emergency access keys
- Environment Variables: Sensitive data stored in
.env.local - HTTPS Ready: Production-ready for HTTPS deployment
- CORS: Properly configured cross-origin policies
# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Run linting
npm run lint
# Create/Update admin account
npm run create-admin
# Initialize database
npm run db:init
# Full setup (install + create admin)
npm run setupThe application uses environment-specific configurations:
- Development:
npm run devβ Hot reload enabled - Production:
npm run build && npm startβ Optimized build - Vercel: Automatic deployment with optimized configuration
Create a .env.local file in the project root:
# MongoDB Connection
MONGODB_URL=mongodb+srv://user:pass@cluster.mongodb.net/samarpan
# JWT Configuration
JWT_SECRET=your-secret-key-min-32-characters
# Email Service
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-app-password
EMAIL_FROM=noreply@samarpan.com
# AWS S3 (Optional)
AWS_ACCESS_KEY_ID=XXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXX
AWS_S3_BUCKET=samarpan-uploads
AWS_REGION=us-east-1
# Google OAuth (Optional)
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
# Admin Credentials (for initialization)
ADMIN_EMAIL=admin@samarpan.com
ADMIN_PASSWORD=strong-password
# Maintenance System (NEW)
MAINTENANCE_INTERNAL_TOKEN=your-internal-maintenance-token
# WhatsApp (Optional)
WHATSAPP_ENABLED=true
WHATSAPP_TOKEN=your-meta-whatsapp-token
WHATSAPP_PHONE_NUMBER_ID=your-phone-number-id
WHATSAPP_DEFAULT_COUNTRY_CODE=91Enable WhatsApp notifications alongside inβapp notifications and email:
- Set
WHATSAPP_ENABLEDtotrueto activate WhatsApp sending. - Provide
WHATSAPP_TOKENfrom your Meta WhatsApp Business Cloud API. - Set
WHATSAPP_PHONE_NUMBER_IDto the sender phone number ID from Meta. - Optionally set
WHATSAPP_DEFAULT_COUNTRY_CODE(e.g.,91) if your users store local numbers without a country code.
When enabled, flows such as blood requests, admin broadcasts, event registrations, QR verification, donation image reviews, certificate generation, transportation creation and status updates attempt bestβeffort WhatsApp delivery if the user has a phone saved.
The project uses Tailwind CSS with a custom theme. Modify theme colors in tailwind.config.ts:
theme: {
colors: {
primary: '#your-color',
secondary: '#your-color',
// ... other colors
}
}All UI components are in components/ui/ and based on Radix UI. Customize them as needed:
import { Button } from "@/components/ui/button"
import { Card } from "@/components/ui/card"
import { Input } from "@/components/ui/input"The maintenance page supports custom styling and messages:
// Custom maintenance messages by priority
const priorityConfigs = {
low: { message: 'Routine maintenance in progress' },
medium: { message: 'Scheduled maintenance underway' },
high: { message: 'Important system updates' },
critical: { message: 'Critical maintenance required' }
}- Push your repository to GitHub
- Connect to Vercel: https://vercel.com/new
- Set environment variables in Vercel dashboard:
- CRITICAL FOR PASSWORD RESET: Set
NEXT_PUBLIC_APP_URLto your production domain (e.g.,https://yourdomain.com)- Without this, password reset links will not work correctly
- If not set, the app will try to auto-detect using
VERCEL_URL, but explicitly setting it is recommended
- Include all other required variables:
MONGODB_URL,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,SMTP_*settings - NEW: Add
MAINTENANCE_INTERNAL_TOKENfor maintenance system
- CRITICAL FOR PASSWORD RESET: Set
- Deploy! (Now works seamlessly with fixed dependency issues)
/reset-password. This URL must be accessible from the internet. The app constructs it using:
- Priority 1:
NEXT_PUBLIC_APP_URLenvironment variable - Priority 2: Vercel's automatic
VERCEL_URL(if not set in Priority 1) - Priority 3: Request headers (x-forwarded-proto, x-forwarded-host)
- Priority 4: Request origin
To ensure password reset works on production:
NEXT_PUBLIC_APP_URL=https://your-production-domain.com
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
CMD ["npm", "start"]npm install --production
npm run build
npm startContributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow ESLint rules
- Use TypeScript for type safety
- Add comments for complex logic
- Test new features thoroughly
- Keep components focused and reusable
- Test QR scanner functionality on real devices
- Verify maintenance mode works across all routes
This project is licensed under the MIT License - see the LICENSE file for details.
- Radix UI β For excellent accessible components
- Next.js β For the amazing React framework
- MongoDB β For robust database solutions
- Tailwind CSS β For utility-first CSS framework
- html5-qrcode β For reliable QR code scanning functionality
- The Open Source Community β For invaluable libraries and tools
For support, email support@samarpan.com or open an issue in the repository.
- QR Scanner System - Reliable QR code scanning β
- Maintenance System - Complete maintenance mode β
- Deployment Optimization - Vercel compatibility β
- Mobile app (React Native)
- Advanced analytics dashboard
- AI-powered donor matching
- SMS notifications
- WhatsApp integration
- Multi-language support
- Blood bank inventory management
- Plasma donation support
- Problem: "HTML Element with id=admin-qr-reader not found"
- Solution: β RESOLVED - Implemented robust DOM element waiting with retry logic
- Problem: "Cannot install with 'frozen-lockfile'" on Vercel
- Solution: β RESOLVED - Cleaned up dependencies and lockfile conflicts
- Enable: Admin Dashboard β Maintenance Mode β Toggle switch
- Priority Levels: Choose from low, medium, high, critical for different styling
- Emergency Access: Use secret key parameter:
?secret=your-key - IP Bypass: Add allowed IPs in maintenance settings
- HTTPS Required: Camera access requires HTTPS on mobile devices
- Permissions: Ensure camera permissions are granted in browser
- Testing: Use
npm run dev -- --hostfor local mobile testing
Made with β€οΈ to save lives
Latest Update: January 2026 - Enhanced QR System, Maintenance Mode & Deployment