8.0 Volunteering - FatinaAlTaherr/HopeConnect GitHub Wiki

Overview

The Volunteering Event Management System facilitates the organization and participation in volunteer events. It allows administrators to create and manage events while enabling volunteers to register for available opportunities. The system implements role-based access control and maintains relationships between events and volunteers.

Models

Event

Represents a volunteer opportunity or activity.

  • Attributes:
    • id: Unique identifier (auto-generated)
    • name: Event title (required)
    • description: Detailed information about the event
    • startDateTime: Scheduled beginning time
    • endDateTime: Scheduled conclusion time
    • location: Physical or virtual venue
    • participants: Set of registered volunteers (many-to-many relationship)
    • organizerEmail: Contact for event coordinator

Volunteer

Represents a volunteer participant (associated via many-to-many relationship).

  • Note: The Volunteer model is referenced but not shown in provided code. Assumed to contain at minimum:
    • id: Unique identifier
    • email: Unique contact identifier
    • Other relevant volunteer profile fields

Services

EventService

Handles core business logic for event management.

  • Methods:
    • getAllEvents(): Retrieves all events
    • getEventById(id): Finds specific event by ID
    • createEvent(event): Creates new event record
    • updateEvent(id, updatedEvent): Modifies existing event
    • deleteEvent(id): Removes event permanently
    • registerVolunteer(eventId, volunteerEmail): Adds volunteer to event

Controllers

EventController

Handles HTTP requests for event operations.

  • Endpoints:
    • GET /api/events: Lists all events
    • GET /api/events/{id}: Retrieves specific event
    • POST /api/events: Creates new event (ADMIN only)
    • PUT /api/events/{id}: Updates event (ADMIN only)
    • DELETE /api/events/{id}: Deletes event (ADMIN only)
    • POST /api/events/{eventId}/register/{volunteerEmail}: Registers volunteer (VOLUNTEER only)

Workflows

Event Management

  1. Administrator Creates Event:

    • ADMIN submits event details via POST endpoint
    • System validates and stores new event
    • Event becomes visible in public listings
  2. Volunteer Registration:

    • VOLUNTEER selects event and registers via endpoint
    • System verifies volunteer credentials
    • Volunteer added to event participants
    • Both parties receive confirmation
  3. Event Updates:

    • ADMIN modifies event details via PUT
    • Changes propagate immediately
    • Registered volunteers receive notifications
  4. Event Cancellation:

    • ADMIN removes event via DELETE
    • System notifies all registered volunteers
    • Event disappears from listings

Security Features

  • Role-based access control:
    • ADMIN: Full event management privileges
    • VOLUNTEER: Self-registration capabilities
  • JWT authentication for all endpoints
  • Sensitive operations require proper authorization
  • Volunteer registration limited to own account

Data Relationships

  • Many-to-Many association between Events and Volunteers
  • Junction table volunteer_event_members maintains relationships
  • Bi-directional mapping enables efficient queries

Validation

  • Event name cannot be blank
  • Date/time validation (end after start)
  • Email format verification
  • Duplicate registration prevention

Error Handling

  • 404 for non-existent resources
  • 403 for unauthorized actions
  • 400 for invalid requests
  • 500 for server errors with detailed logging