2.0 Orphan Management System - FatinaAlTaherr/HopeConnect GitHub Wiki

Overview

The Orphan Management System provides comprehensive functionality for managing orphanages and their associated orphans. It includes features for orphanage registration, verification, orphan records management, and reporting. The system implements role-based access control with different permissions for admin, orphanage owners, donors, and sponsors.

Models

Orphan

Represents an orphan entity in the system.

  • Attributes:
    • id: Unique identifier (auto-generated)
    • fullName: Full name of the orphan (required)
    • birthDate: Date of birth
    • age: Current age
    • gender: Enum (MALE, FEMALE, OTHER)
    • educationStatus: Current education status
    • school: Name of attending school
    • grade: Current school grade
    • performance: Academic performance description
    • healthCondition: Health status (text)
    • lastDonationUsedFor: Description of last donation usage
    • photo: Photo reference
    • recentPhotoURL: URL of recent photo
    • orphanage: Associated orphanage (many-to-one)
    • createdAt: Timestamp of creation (auto-set)
    • updatedAt: Timestamp of last update (auto-updated)

Orphanage

Represents an orphanage entity.

  • Attributes:
    • id: Unique identifier (auto-generated)
    • reviews: List of associated reviews (one-to-many)
    • owner: User who owns the orphanage (one-to-one)
    • name: Orphanage name (required)
    • verificationStatus: Enum (PENDING, VERIFIED, REJECTED)
    • verificationNotes: Admin notes about verification
    • location: Physical address
    • contactNumber: Phone number
    • email: Contact email
    • verifiedStatus: Boolean verification flag
    • createdAt: Timestamp of creation (auto-set)
    • updatedAt: Timestamp of last update (auto-updated)
    • orphans: List of associated orphans (one-to-many)

VerificationStatus

Enum representing orphanage verification states.

  • Values:
    • PENDING: Awaiting admin review
    • VERIFIED: Approved by admin
    • REJECTED: Denied by admin

Services

OrphanageService

Handles business logic for orphanages and orphans.

  • Methods:
    • saveOrphanForOwner(orphan, ownerEmail): Creates orphan record linked to owner's orphanage
    • saveOrphanageWithOwner(orphanage, ownerEmail): Registers new orphanage with owner
    • getOrphansByOrphanageId(orphanageId): Retrieves all orphans for an orphanage
    • deleteOrphanage(id): Removes orphanage
    • getAllOrphanages(): Lists all orphanages
    • getOrphanageById(id): Gets specific orphanage
    • verifyOrphanage(id): Approves orphanage registration
    • saveOrphan(orphan): Creates orphan record
    • getAllOrphans(): Lists all orphans
    • getOrphanById(id): Gets specific orphan
    • updateOrphan(id, updatedOrphan): Modifies orphan details
    • deleteOrphan(id): Removes orphan record
    • getOrphanageByUser(user): Gets orphanage for owner user
    • getOrphanageByEmail(email): Finds orphanage by email

Controllers

OrphanageController

Handles HTTP requests for orphanage management.

  • Endpoints:
    • POST /HopeConnect/api/orphanages: Creates new orphanage (ADMIN only)
    • GET /HopeConnect/api/orphanages/{id}/orphans: Gets orphans by orphanage ID
    • GET /HopeConnect/api/orphanages: Lists all orphanages
    • GET /HopeConnect/api/orphanages/{id}: Gets specific orphanage
    • PUT /HopeConnect/api/orphanages/verify/{id}: Verifies orphanage (ADMIN only)
    • DELETE /HopeConnect/api/orphanages/{id}: Deletes orphanage (ADMIN only)
    • POST /HopeConnect/api/orphans: Creates new orphan (ORPHANAGE_OWNER only)
    • GET /HopeConnect/api/orphans: Lists all orphans
    • GET /HopeConnect/api/orphans/{id}: Gets specific orphan
    • PUT /HopeConnect/api/orphans/{id}: Updates orphan (ORPHANAGE_OWNER only)
    • DELETE /HopeConnect/api/orphans/{id}: Deletes orphan (ORPHANAGE_OWNER/ADMIN)
    • GET /HopeConnect/api/generate-report/{orphanId}: Generates orphan report (DONOR/ADMIN/SPONSOR)

Security

  • Role-based access control:
    • ADMIN: Full management privileges
    • ORPHANAGE_OWNER: Manage their orphanage and orphans
    • DONOR/SPONSOR: View access and reporting
  • JWT authentication required for all endpoints
  • Automatic timestamping for creation/modification

Workflows

  1. Orphanage Registration:

    • ADMIN creates orphanage record
    • System sends verification email
    • ADMIN verifies via endpoint
    • Owner gains management access
  2. Orphan Management:

    • Owner adds orphan records
    • Donors/sponsors view information
    • Reports generated on demand
  3. Data Maintenance:

    • Owners update orphan details
    • ADMIN can remove orphanages/orphans
    • All changes are timestamped