Skip to content

Latest commit

 

History

History
536 lines (430 loc) · 14.8 KB

File metadata and controls

536 lines (430 loc) · 14.8 KB

HelpCamp 🏕️

A comprehensive community-driven web platform designed to connect people seeking help with those willing to provide it. HelpCamp combines a peer-to-peer help forum with real-time vaccine availability tracking and notifications.


📋 Table of Contents


✨ Features

1. Community Help Forum

  • Post help requests for:
    • Hospital services
    • Medicines
    • Blood donations
  • Create help/service ads
  • Browse and search all posts and ads by location, category, and pincode
  • Comment on posts to provide help or get more details
  • User profiles to manage your posts and activities

2. Vaccine Availability Tracker 💉

  • Real-time vaccine slot availability checking using Co-vin API
  • Subscription-based alerts for vaccine availability
  • Supports multiple age groups and vaccine doses:
    • 45+ years (Dose 1 & 2)
    • 18-44 years (Dose 1 & 2)
  • Email notifications when slots become available in subscribed pincodes
  • Automated background job checking every 5 minutes for slot updates

3. User Authentication & Management

  • User registration with validation
  • Secure login/logout with Passport.js
  • Password reset and recovery functionality
  • User profiles with contact information
  • Account deletion capability
  • Session management with MongoDB store

4. Communication Features

  • Email notifications for:
    • New comments on your posts
    • Vaccine slot availability alerts
    • Password reset links
    • Account notifications
  • Nodemailer integration with Gmail

5. Additional Features

  • Donation/Payment integration using Razorpay
  • Admin panel for system management
  • Comment system with timestamps
  • Input validation and sanitization
  • Responsive design with Bootstrap

🛠️ Tech Stack

Backend

  • Framework: Express.js (Node.js)
  • Database: MongoDB with Mongoose ODM
  • Authentication: Passport.js with Local Strategy
  • Session Management: Express-session with MongoDB store

Frontend

  • Templating Engine: EJS
  • CSS Framework: Bootstrap 5
  • Styling: Custom CSS
  • Client-side Scripting: Vanilla JavaScript & Axios

External APIs & Libraries

  • Co-vin API: Vaccine slot availability data
  • Google APIs: Gmail integration for emails
  • Nodemailer: Email sending service
  • Razorpay: Payment processing
  • Joi: Schema validation
  • Helmet: Security middleware
  • mongo-sanitize: NoSQL injection prevention

📁 Project Structure

HelpCamp/
├── index.js                 # Main application entry point
├── middleware.js            # Custom middleware functions
├── package.json             # Project dependencies
│
├── models/                  # Mongoose schemas
│   ├── user.js              # User model with authentication
│   ├── post.js              # Help request posts
│   ├── ad.js                # Service advertisements
│   ├── comment.js           # Comments on posts
│   ├── adComment.js         # Comments on ads
│   ├── subscribe.js         # Vaccine subscription pincodes
│   ├── userSubs.js          # User subscriptions (45+, Dose 1)
│   ├── userSubs2.js         # User subscriptions (45+, Dose 2)
│   ├── userSubs18.js        # User subscriptions (18+, Dose 1)
│   └── userSubs182.js       # User subscriptions (18+, Dose 2)
│
├── routes/                  # Express route handlers
│   ├── user.js              # Authentication & user management
│   ├── post.js              # Help posts and comments
│   ├── help.js              # Service ads and help requests
│   └── admin.js             # Admin panel routes
│
├── utils/                   # Utility functions
│   ├── AppError.js          # Custom error class
│   └── wrapAsync.js         # Async error wrapper
│
├── views/                   # EJS templates
│   ├── home.ejs             # Homepage with vaccine tracker
│   ├── payment.ejs          # Donation page
│   ├── error.ejs            # Error page
│   ├── admin/               # Admin pages
│   │   └── adminPanel.ejs
│   ├── partials/            # Reusable components
│   │   ├── header.ejs
│   │   ├── navbar.ejs
│   │   ├── footer.ejs
│   │   └── flash.ejs
│   ├── post/                # Post-related templates
│   │   ├── show.ejs         # View single post
│   │   ├── showPosts.ejs    # List all posts
│   │   ├── ad.ejs           # Create help ad
│   │   ├── adEdit.ejs       # Edit ad
│   │   ├── edit_post.ejs    # Edit post
│   │   ├── myads.ejs        # User's ads
│   │   ├── myposts.ejs      # User's posts
│   │   ├── search.ejs       # Search results
│   │   └── comment.ejs      # Comment section
│   └── user/                # User-related templates
│       ├── register.ejs     # Registration form
│       ├── login.ejs        # Login form
│       ├── newProfile.ejs   # User profile
│       ├── subscribe.ejs    # Vaccine subscription
│       ├── forgot.ejs       # Password recovery
│       └── vaccine.ejs      # Vaccine information
│
├── public/                  # Static files
│   ├── css/                 # Stylesheets
│   │   ├── bootstrap.min.css
│   │   ├── style.css
│   │   ├── home.css
│   │   ├── register.css
│   │   ├── login.css
│   │   ├── comment.css
│   │   ├── footer.css
│   │   ├── subscribe.css
│   │   └── showPosts.css
│   ├── js/                  # Client-side scripts
│   │   ├── main.js
│   │   ├── home.js          # Vaccine finder script
│   │   ├── subscribe.js     # Subscription logic
│   │   ├── comment.js       # Comment functionality
│   │   ├── validation.js    # Form validation
│   │   ├── date.js
│   │   ├── edit.js
│   │   ├── option.js
│   │   ├── otp.js
│   │   └── bootstrap.min.js
│   └── imgs/                # Images and assets


💻 Installation

Prerequisites

  • Node.js (v12 or higher)
  • MongoDB (local or cloud instance)
  • npm or yarn

Steps

  1. Clone the repository

    git clone <repository-url>
    cd HelpCamp
  2. Install dependencies

    npm install
  3. Create environment file

    touch .env
  4. Configure environment variables (see Configuration section)

  5. Start the application

    npm start

⚙️ Configuration

Create a .env file in the root directory with the following variables:

# Database
DB_URL=mongodb://localhost:27017/helpCamp
# or for MongoDB Atlas:
# DB_URL=mongodb+srv://username:password@cluster.mongodb.net/helpCamp

# Environment
NODE_ENV=development

# Session Secret
secret=your_secret_key_here

# Email Configuration (Gmail)
GMAIL_USER=your_email@gmail.com
GMAIL_APP_PASSWORD=your_app_password

# Google OAuth (for Gmail API)
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GOOGLE_REDIRECT_URI=http://localhost:3000/oauth2callback
GOOGLE_REFRESH_TOKEN=your_refresh_token

# Razorpay (Payment)
RAZORPAY_KEY_ID=your_key_id
RAZORPAY_KEY_SECRET=your_key_secret

# Port (optional)
PORT=3000

🚀 Running the Application

Development Mode

npm start

The application will start on http://localhost:3000

Features Highlights at Startup

  • Establishes MongoDB connection
  • Initializes Passport authentication
  • Starts vaccine checking job (runs every 5 minutes)
  • Sets up session store

🔄 API Routes

User Routes (/user)

  • GET /register - Registration form
  • POST /register - Register new user
  • GET /login - Login form
  • POST /login - Authenticate user
  • GET /logout - Logout user
  • GET /profile - View user profile
  • POST /profile - Update profile
  • DELETE /profile - Delete account
  • GET /forget/username - Forgot username page
  • POST /forget/username - Send username recovery email
  • GET /forgot - Password reset request
  • POST /forgot - Send password reset link
  • GET /reset/:token - Reset password form
  • POST /reset/:token - Update password

Post Routes (/post)

  • GET / - Create new post form
  • POST / - Create new post
  • GET /show - View all posts
  • GET /:postid - View single post
  • GET /edit/:postid - Edit post form
  • PUT /edit/:postid - Update post
  • DELETE /:postid - Delete post
  • GET /filter/pc/:pc - Filter posts by pincode
  • GET /filter/cat/:cat - Filter posts by category
  • POST /:postid/comment - Add comment to post
  • DELETE /comment/:commentid - Delete comment

Help/Ad Routes (/help)

  • POST / - Create help advertisement
  • GET / - View help ads
  • GET /:postid - View single help ad
  • GET /edit/:postid - Edit help ad form
  • POST /edit/:postid - Update help ad
  • DELETE /:postid - Delete help ad
  • POST /:postid/comment - Add comment to help ad
  • GET /subscribe/:pincode - Subscribe to vaccine alerts
  • GET /unsubscribe/:pincode - Unsubscribe from alerts

Admin Routes (/admin)

  • Administrative and system management routes

🗄️ Database Models

User Model

{
  firstname: String,
  lastname: String,
  gender: String,
  email: String (unique),
  phone: String (unique),
  pincode: String,
  username: String (from Passport),
  resetPasswordToken: String,
  resetPasswordExpires: Date
}

Post Model

{
  categories: ['hospital', 'medicines', 'blood'],
  requirement: String,
  location: String,
  user: ObjectId (ref: User),
  time: String,
  date: String,
  comments: [ObjectId] (ref: Comment),
  pincode: Number
}

Ad Model

{
  categories: ['hospital', 'medicines', 'blood'],
  requirement: String,
  location: String,
  user: ObjectId (ref: User),
  time: String,
  date: String,
  comments: [ObjectId] (ref: AdComment),
  pincode: Number
}

Subscribe Model

{
  pincode: [Number]  // Pincodes to monitor for vaccine availability
}

UserSubs Models (Multiple variants)

  • UserSubs - 45+, Dose 1
  • UserSubs2 - 45+, Dose 2
  • UserSubs18 - 18+, Dose 1
  • UserSubs182 - 18+, Dose 2

🎯 Key Features Explained

1. Real-time Vaccine Tracker

The application continuously monitors vaccine availability by:

  • Fetching data from the Co-vin API every 5 minutes
  • Checking multiple pincodes that users have subscribed to
  • Grouping subscriptions by age (45+, 18-44) and dose number
  • Sending email notifications when slots become available
  • Tracking the last check time to avoid duplicate notifications

Background Jobs:

- subs()    - 45+, Dose 1 (runs every 5 minutes)
- subs2()   - 45+, Dose 2 (runs every 5 minutes)
- subs18()  - 18+, Dose 1 (runs every 5 minutes)
- subs182() - 18+, Dose 2 (runs every 5 minutes)

2. Help Forum System

Users can:

  • Post about their needs (hospital, medicines, blood)
  • Browse posts by others needing help
  • Comment with offers of help
  • Get email notifications when someone comments on their post
  • View helper's contact information in the notification

3. Comment System

  • Two-way commenting (on posts and help ads)
  • Timestamped comments
  • Comments include user details for direct contact
  • Email notifications to post owners

4. User Authentication

  • Password hashing and salting via Passport
  • Session persistence with MongoDB store
  • Password reset with time-limited tokens
  • Account recovery options

🔒 Security

The application implements several security measures:

  1. Helmet.js - Sets HTTP headers for protection
  2. MongoDB Sanitization - Prevents NoSQL injection attacks
  3. Input Validation - Joi schema validation for all inputs
  4. Password Complexity - joi-password-complexity enforcement
  5. CORS & Session Security - Secure session configuration
  6. Environment Variables - Sensitive data stored in .env
  7. Password Reset Tokens - Time-limited recovery tokens

📧 Email Configuration

The application uses Gmail's OAuth2 for sending emails. To set this up:

  1. Enable 2-factor authentication on your Gmail account
  2. Generate an App Password for your account
  3. Update the .env file with:
    • Gmail user email
    • App password or refresh token

Emails are sent for:

  • Password reset links
  • Vaccine availability notifications
  • Comment notifications on posts
  • Registration confirmations

🌐 Live Features

Homepage (/)

  • Displays vaccine slot finder if user is logged in
  • Shows available vaccine slots by pincode
  • Real-time integration with Co-vin API

Vaccine Subscription (/post/sub)

  • Subscribe to vaccine alerts
  • Select age group (45+, 18+)
  • Select dose number (1 or 2)
  • Manage subscriptions
  • Receive email alerts for availability

Admin Panel (/admin)

  • System-wide management
  • User and content moderation
  • Donation/payment tracking

📊 Statistics & Tracking

The application tracks:

  • Last check time for each pincode to avoid redundant API calls
  • User subscription preferences
  • Help post and ad statistics
  • Comment threads and engagement

🐛 Error Handling

  • Custom AppError class for application-specific errors
  • Async error wrapper (wrapAsync) for error handling in routes
  • Validation error messages
  • User-friendly error pages

🤝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

👤 Author

Rushikesh Rajendra Wani


📜 License

This project is licensed under the ISC License.


📝 Notes

  • The application uses IST (Indian Standard Time) timezone for date/time operations
  • Co-vin API is specific to vaccine availability in India
  • The platform is designed to work with Indian pincodes (6-digit format)
  • Email service requires valid Gmail credentials and App Password

🔗 Useful Links


Last Updated: February 2026

For questions or issues, please reach out through the repository's issue tracker.