masaruk Logo

analysis/04-functional-spec/users-management-module.md

Users Management

Users Management Module – Functional Specification

1. Purpose

The Users Management Module handles the administration of all user accounts across the MASARUK platform.

This module covers:

  • Viewing all registered users (B2C customers)
  • Managing user account status (active/blocked)
  • Viewing user booking history
  • Admin user management (Admin Panel only)
  • Provider staff management (handled in providers-module)

4. User Entity Fields

FieldTypeLabelNotes
idPKAuto-generated
full_nameStringFull NameRequired
emailStringEmail AddressUnique, required
phoneStringPhone NumberUnique, required
password_hashStringEncrypted
roleEnumRoleuser, admin, super_admin, provider_admin, provider_staff
statusEnumStatusACTIVE, BLOCKED
avatar_urlStringProfile PictureOptional
provider_idFK (nullable)Only for provider users
created_atTimestampRegistration DateAuto
updated_atTimestampAuto

5. User Roles

RoleArabicDescription
userمستخدم (User)B2C customer
adminمشرف (Admin)Platform administrator
super_adminمشرف أعلى (Super Admin)Full system access
provider_adminمدير الشركة (Provider Admin)Provider company admin
provider_staffموظف الشركة (Provider Staff)Provider staff member

6. User Statuses

Activeblocked
LabelEnumMeaning
ActiveACTIVEUser can login and use platform
BlockedBLOCKEDUser cannot login

7. Business Rules

BR-1. Only admins can manage users

CUSTOMER role cannot access this module.

BR-2. Cannot delete users

Users are never deleted; only blocked. This preserves booking history integrity.

BR-3. Blocking a user

When user.status = BLOCKED: User cannot login, existing bookings remain intact, user appears with 'Blocked' badge.

BR-4. Admin cannot block themselves

Prevent self-blocking to avoid admin lockout.

BR-5. Super Admin is protected

Cannot block a super_admin account.

BR-6. Provider users managed separately

Provider staff are managed via providers-and-companies-module.md

BR-7. View user booking history

Admin can view all bookings associated with a user.

8. Actions & Behaviors

A-1. View Users List

Users Management
→ Users Table
→ Columns: Name, Email, Phone, Role, Status, Registration Date
→ Filter by Role / Status
→ Search by Name or Email

A-2. View User Details

Users List
→ Select User
→ Eye Icon
→ View Details:
    - Personal Data
    - Bookings List
    - Account Status

A-3. Block User

User Details
→ "Block User" Button
→ Confirmation Modal: "Are you sure you want to block this user?"
→ Confirm
→ Status changes to "Blocked"

A-4. Unblock User

User Details (Blocked)
→ "Unblock" Button
→ Confirmation Modal
→ Confirm
→ Status changes to "Active"

9. UI Structure

Users List Screen

┌─────────────────────────────────────────────────────────┐
│  Sidebar  │          Users Management                     │
│           │  ┌─────────────────────────────────────────┐│
│           │  │  Search: [____________]   Filter: [▼]   ││
│           │  └─────────────────────────────────────────┘│
│           │  ┌─────────────────────────────────────────┐│
│           │  │ Name │ Email │ Phone │ Role │ Status│Actions││
│           │  │──────────────────────────────────────────│
│           │  │ John │ j@x.com│ 05... │ User │ Active│ 👁️ ││
│           │  │ Ahmed│ a@x.com│ 05... │ User │ Blocked│ 👁️ ││
│           │  └─────────────────────────────────────────┘│
│           │  [Pagination: < 1 2 3 ... >]               │
└─────────────────────────────────────────────────────────┘

10. Error Cases

CaseMessage
No users foundNo users match the search criteria
Attempt to block selfYou cannot block your own account
Attempt to block super_adminCannot block Super Admin
User has active bookingsWarning: This user has active bookings
Network errorError loading data. Please try again.

12. Access Permissions (RBAC)

RoleView UsersView DetailsBlock/Unblock
SUPER_ADMIN
ADMIN✅ (not super_admin)
FINANCE_ADMIN
PROVIDER_ADMIN
PROVIDER_STAFF
CUSTOMER

13. Saved Travelers Directory (Slice 4)

SSOT: analysis/04-functional-spec/users-management-module.md §15

Users can save frequently-used traveler information in their profile for faster booking.

Official Decisions

  • DEC-S4-01: Travelers Directory in Profile → المسافرين
  • DEC-S4-02: Relationship field: CHILD, PARENT, SIBLING, FRIEND, OTHER
  • DEC-S4-03: Birth date optional for domestic trips

SavedTraveler Entity Fields

FieldTypeRequired
full_name_arString✅ Domestic
full_name_enString✅ International
genderEnum✅ (MALE|FEMALE)
document_typeEnum✅ Domestic
document_numberString
birth_dateDate⚠️ Optional (domestic)
passport_numberString✅ International
passport_expiryDate✅ International
nationalityString✅ International
relationship_typeEnum⚠️ Optional
phonePhone⚠️ Optional (DEC-S3-01)

Business Rules

  • ST-BR-1: Maximum 20 saved travelers per account
  • ST-BR-2: Cannot save duplicate document_number
  • ST-BR-3: Deleting does not affect existing bookings