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 birthage
: Current agegender
: Enum (MALE, FEMALE, OTHER)educationStatus
: Current education statusschool
: Name of attending schoolgrade
: Current school gradeperformance
: Academic performance descriptionhealthCondition
: Health status (text)lastDonationUsedFor
: Description of last donation usagephoto
: Photo referencerecentPhotoURL
: URL of recent photoorphanage
: 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 verificationlocation
: Physical addresscontactNumber
: Phone numberemail
: Contact emailverifiedStatus
: Boolean verification flagcreatedAt
: 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 reviewVERIFIED
: Approved by adminREJECTED
: Denied by admin
Services
OrphanageService
Handles business logic for orphanages and orphans.
- Methods:
saveOrphanForOwner(orphan, ownerEmail)
: Creates orphan record linked to owner's orphanagesaveOrphanageWithOwner(orphanage, ownerEmail)
: Registers new orphanage with ownergetOrphansByOrphanageId(orphanageId)
: Retrieves all orphans for an orphanagedeleteOrphanage(id)
: Removes orphanagegetAllOrphanages()
: Lists all orphanagesgetOrphanageById(id)
: Gets specific orphanageverifyOrphanage(id)
: Approves orphanage registrationsaveOrphan(orphan)
: Creates orphan recordgetAllOrphans()
: Lists all orphansgetOrphanById(id)
: Gets specific orphanupdateOrphan(id, updatedOrphan)
: Modifies orphan detailsdeleteOrphan(id)
: Removes orphan recordgetOrphanageByUser(user)
: Gets orphanage for owner usergetOrphanageByEmail(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 IDGET /HopeConnect/api/orphanages
: Lists all orphanagesGET /HopeConnect/api/orphanages/{id}
: Gets specific orphanagePUT /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 orphansGET /HopeConnect/api/orphans/{id}
: Gets specific orphanPUT /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 privilegesORPHANAGE_OWNER
: Manage their orphanage and orphansDONOR/SPONSOR
: View access and reporting
- JWT authentication required for all endpoints
- Automatic timestamping for creation/modification
Workflows
-
Orphanage Registration:
- ADMIN creates orphanage record
- System sends verification email
- ADMIN verifies via endpoint
- Owner gains management access
-
Orphan Management:
- Owner adds orphan records
- Donors/sponsors view information
- Reports generated on demand
-
Data Maintenance:
- Owners update orphan details
- ADMIN can remove orphanages/orphans
- All changes are timestamped