A robust, production-ready Node.js backend for the DeskBuddy onboarding and event management system. Handles student onboarding, QR code generation, multi-stage scanning, and bulk email notifications with advanced logging and Supabase integration.
- Express.js REST API for all onboarding and event flows
- Supabase integration for student data storage and updates
- Bulk Email sending with CSV upload, QR code attachment, and SMTP (Gmail) support
- SMS Notifications for arrival, hostel, and documents verification events
- QR Code generation and download for each student
- Multi-stage Scanning (arrival, hostel, documents, kit)
- Robust Logging to both console (color) and
logs/app.log(JSON) - CSV Parsing with validation and error reporting
- Modular Controllers/Services for clean, maintainable code
deskbuddy-backend/
controllers/ # Business logic for email, scan, student
routes/ # API route definitions
services/ # Email, CSV, Supabase integrations
utils/ # Logger utility
uploads/ # Temporary CSV uploads
logs/ # Log files (gitignored)
index.js # Main entry point
env.example # Environment variable template
package.json # Dependencies and scripts
- Clone the repository:
git clone <your-repo-url> cd DeskBuddy/deskbuddy-backend
- Install dependencies:
npm install
- Configure environment variables:
- Copy
env.exampleto.envand fill in your credentials:cp env.example .env # Edit .env with your Supabase and Gmail SMTP details
- Copy
- Start the server:
- For production:
npm start
- For development (with auto-reload):
npm run dev
- For production:
| Variable | Description |
|---|---|
| SUPABASE_URL | Your Supabase project URL |
| SUPABASE_ANON_KEY | Supabase anon/service key |
| EMAIL_USER | Gmail address for SMTP |
| EMAIL_PASSWORD | Gmail app password |
| SMS_BASE_URL | SMS API base URL |
| PORT | Server port (default: 3001) |
| NODE_ENV | Environment (development/production) |
GET /api/student/:studentId— Fetch student details
POST /api/scan/arrival— Mark arrival for a studentPOST /api/scan/hostel— Mark hostel verificationPOST /api/scan/documents— Mark document verificationPOST /api/scan/kit— Mark kit collection
Request Body (for scan):
{
"studentId": "NST124",
"volunteerName": "John Doe"
}POST /api/email/upload-csv— Upload CSV, send bulk emails with QRGET /api/email/qr-code/:studentId— Get QR code (data URL)GET /api/email/qr-download/:studentId— Download QR code (PNG)POST /api/email/test-email— Send test emailGET /api/email/test-smtp— Test SMTP connectionGET /api/email/stats— Email stats
- Required columns:
name,email,studentid - Example:
name,email,studentid Aryan Vibhuti,aryan@example.com,NST123 Jane Doe,jane@example.com,NST124
- All API/database/scan actions are logged to both console (color-coded) and
logs/app.log(JSON). - Log file is gitignored and not pushed to GitHub.
- Log structure includes timestamp, level, message, and context.
- Never commit real credentials; use
.envfor secrets. - Ensure CORS is configured for your frontend domain.
- Use HTTPS in production (behind a reverse proxy or AWS load balancer).
- Regularly rotate your SMTP and Supabase keys.
- Can be hosted on AWS EC2, Elastic Beanstalk, or any Node.js-compatible service.
- Expose the chosen
PORTand ensure security group/firewall allows inbound traffic. - For persistent logs, consider AWS CloudWatch or similar.
Pull requests and issues are welcome! Please open an issue to discuss major changes.
For support, email: aryanvibhuti@gmail.com
© 2025 DeskBuddy. All rights reserved.