masaruk Logo

Entities & Relationships

Domain Entities & Relationships

1. Purpose

This document defines all core domain entities extracted strictly from the UI/UX analysis of:

B2C Mobile App
B2C Web
Admin Panel
Provider Portal
Booking Flow
Payment Flow
Ratings
Trip Details
Buses / Hotels / Rest Stops
Financial Reports
Ad Campaigns
Arabic Labels
Arabic labels from UI are preserved exactly as they appear.

2. Entity List Overview

Core Customer-facing Entities

  • User المستخدم
  • Booking الحجز
  • BookingPassenger بيانات المسافر
  • Trip الرحلة
  • TripItineraryDay البرنامج اليومي
  • Rating التقييم

Provider Resource Entities

  • Provider شركة السياحة
  • Bus الباص
  • Hotel الفندق
  • RestStop الاستراحة
  • AdCampaign الحملة الإعلانية

Financial Entities

  • PaymentTransaction معاملة الدفع
  • FinancialRecord السجل المالي

System Entities

  • Notification الإشعار
  • SystemSetting إعدادات النظام
  • AdminUser مستخدم الإدارة
  • MediaAsset الوسائط

3. Entities & Their Descriptions

3.1 User

Represents a B2C customer who books trips.

FieldArabic UI LabelNotes
idPrimary key
full_nameالاسم بالكاملAs seen in signup/login
emailالبريد الالكترونيRequired in auth
mobileرقم الجوالUsed in booking & rating
password_hashbcrypt/argon2 hash
profile_imageOptional
created_at
Relationships:has_many Bookings, has_many Ratings
Appears In:إنشاء حساب، تسجيل الدخول، حجوزاتي، تأكيد الحجز، تقييم الرحلة

3.2 Trip

The main product entity representing a travel program.

FieldArabic UI LabelNotes
idPrimary key
nameاسم البرنامجFrom Admin/Provider trip creation
destinatione.g., مكة المكرمة
price_per_person"ابتداءً من"
old_priceStrikethrough price
trip_typeنوع الرحلة(سياحية / عمرة)
start_date
end_date
duration_daysDerived
duration_nightsDerived
descriptionLong text
services_includedما يشمله السعرArray of boolean flags
imagesMediaAsset[]
statusالحالةفعّالة / غير فعّالة
Relationships:belongs_to Provider, has_one Hotel, has_one Bus, has_many RestStops, has_many TripItineraryDay, has_many Bookings

3.4 Booking

A confirmed or pending reservation for a Trip.

FieldArabic UI LabelNotes
idرقم الحجزShown everywhere
user_idFK
trip_idاسم الرحلةFK
total_amountالسعرSum after VAT
payment_statusحالة الدفعمكتمل / ملغاه / قيد التنفيذ
booking_statusالحالةمؤكدة / ملغاه / قيد التنفيذ / مكتملة / قادمة
booking_dateتاريخ الحجز
travel_dateتاريخ الرحلة
passengers_countعدد المسافرين
Note
UI shows مؤكدة (feminine form). Internal enum is CONFIRMED. See statuses-and-lifecycles.md for canonical mappings.

3.8 Bus

As managed in "قائمة الباصات".

FieldArabic UI LabelNotes
idPK
provider_idFK
plate_numberرقم اللوحة
modelموديل الباص"سكانيا 2021"
seatsسعة المقاعد
statusالحالةنشطة / غير نشطة / تحت الصيانة
servicesالخدمات المتوفرةواي فاي، حمام، تكييف…
driver_nameاسم السائقEmbedded
driver_mobileرقم الجوالEmbedded
driver_photoصورة السائق
bus_photoصورة الباص

3.7 Provider

Represents a tourism company using the B2B portal.

FieldArabic UI LabelNotes
idPK
nameاسم الشركة
logoImage
cr_numberCommercial registration
city
contact_nameاسم المسؤول
contact_mobileرقم الجوال
contact_emailالبريد الالكتروني
Relationships:has_many Trips, Buses, Hotels, RestStops, AdCampaigns

3.12 PaymentTransaction

Records payments for bookings and campaigns.

FieldArabic UI LabelNotes
idPK
booking_idNullable for AdCampaign
reference_numberرقم المعاملة
amountالمبلغ الإجمالي
vat_percentضريبة15% or 20%
payment_methodطريقة الدفعMada/STC Pay/Apple Pay
statusحالة الدفعمكتمل / ملغاه / قيد التنفيذ
paid_atتاريخ الدفع

4. High-Level ER Relationships

User ───< Booking ───< BookingPassenger
  │             │
  │             └─── PaymentTransaction ───< FinancialRecord
  │
  └──< Rating >── Booking

Provider ───< Trip ───< TripItineraryDay
   │         │  │
   │         │  └──< RestStop (many-to-many per direction)
   │         └─── Bus
   │             Hotel
   │
   └──< Bus / Hotel / RestStop / AdCampaign

Trip ───< Booking >── User
Trip ───< AdCampaign >── Provider

5. Cross-Module Dependencies

EntityDepends OnDepended By
BookingUser, TripRating, PaymentTransaction
TripProviderBooking, Rating, AdCampaign
RestStopProviderTrip (details)
HotelProviderTrip (details)
BusProviderTrip
PaymentTransactionBooking / AdCampaignFinancialRecord
RatingBooking

6. Data Types & Constraints Reference

6.1 Standard Field Types

Field PatternPostgreSQL TypeConstraints
idBIGSERIALPRIMARY KEY
*_id (foreign keys)BIGINTNOT NULL, REFERENCES
emailVARCHAR(255)UNIQUE where applicable
mobileVARCHAR(20)Format: 05xxxxxxxx
national_idVARCHAR(10)10 digits
name, titleVARCHAR(255)NOT NULL
description, notesTEXTNULLABLE
price, amountDECIMAL(12,2)NOT NULL, CHECK >= 0
percentageDECIMAL(5,2)CHECK BETWEEN 0 AND 100
statusVARCHAR(50)NOT NULL, CHECK in enum
*_date, *_atTIMESTAMPTZ
is_* (booleans)BOOLEANDEFAULT false
servicesJSONBArray of service flags

6.2 Standard Audit Fields

FieldTypeNotes
created_atTIMESTAMPTZDEFAULT NOW()
updated_atTIMESTAMPTZTrigger on update
deleted_atTIMESTAMPTZSoft delete (nullable)
created_byBIGINTUser/Admin who created
updated_byBIGINTUser/Admin who updated