Skip to content

Firestore Architecture

Jeffery edited this page Oct 2, 2024 · 16 revisions

We use Firestore to manage the database infrastructure. All firestore types should be defined and documented in server/src/data-layer/models/firebase.ts.

Furthermore, new collections need to be created in server/src/data-layer/adapters/FirestoreCollections.ts

users collection

After a user signs up through the web app, extra information will be populated through this collection on top of the Firebase User object.

Field Type Example Value
date_of_birth timestamp 1 January 1970 at 00:00:00
does_freestyle boolean true
does_racing boolean false
does_snowboarding boolean false
does_ski boolean true
gender string female
emergency_name string Jane Doe
emergency_phone string 123 456 789
emergency_relation string Friend
first_name string John
last_name string Doe
dietary requirements string "no dairy"
faculty string or undefined Engineering
university 'UoA' or string or undefined 'Waikato'
student_id string or undefined 123456789
returning boolean true
university_year string "2nd" or "Graduate"
stripe_id string "asdsdsdssd"

booking_slot collection

An individual slot a user can book on. These slots should be for a specific day.

Field Type Description Example Value
description string? An optional description for this date Beginners Weekend
date timestamp The date this booking slot refers to 23 July 2024 at 00:00:00
max_bookings number The maximum number of bookings that can exist on this date 30

bookings collection

This manages the link between users and booking IDs

Field Type Example Value
user_id reference /users/lVsOjAp06AfD6atT8bnrVEpcdcg2
booking_slot_id reference /booking_slot/sddsdsdsds
stripe_payment_id string 'cs_test_a11YYufWQzNY63zpQ6QSNRQhkUpVph4WRmzW0zWJO2znZKdVujZ0N0S22u'

event_slot collection

An event slot and supposedly upcoming events collection that is linked to these slots

Field Type Description Example
title string The title of this event Snowboarding race!
description string? An optional description for this event in markdown format Come join your friends in this exciting UASC event and race!
image_url string? The link for the image to display on the event page
location string The location of this event University of Auckland
start_date Timestamp Start date of the event in UTC time
end_date Timestamp The signup period end date.
physical_start_date Timestamp Event start date for the event i.e the day members should meet at shads,
physical_end_date? Timestamp Event end time for the event i.e the last day members will be at the lodge, is optionial in case of one day events.
max_occupancy number? Max number of attendees at this event, left as optional for uncapped 30

booking_history collection

All documents in this collection will contain the following fields:

Field Type Description Example
timestamp Timestamp The time which the booking operation was performed. MUST be in UTC format 2024-08-02T07:38:35Z
start_date Timestamp The start of the operated on date range 2024-08-01T00:00:00Z
end_date Timestamp The end of the operated on date range 2024-08-01T23:59:59Z
event_type "added_user_to_booking" | "removed_user_from_booking" | "changed_date_availability" The type of event that the admin performed, used for parsing on the front-end "added_user_to_booking"

Based on the type of event, there will also be additional fields:

BookingAddedEvent

Field Type Description Example
uid string The id corresponding to the user who had a manually added booking user123
event_type "added_user_to_booking" The type of event that the admin performed, used for parsing on the front-end "added_user_to_booking"

BookingDeletedEvent

Field Type Description Example
uid string The id corresponding to the user who had a manually deleted booking user456
event_type "removed_user_from_booking" The type of event that the admin performed, used for parsing on the front-end "removed_user_from_booking"

BookingAvailabilityChangeEvent

Field Type Description Example
change number The signed difference between the newly available slots and the previously available slots -32
event_type "changed_date_availability" The type of event that the admin performed, used for parsing on the front-end "changed_date_availability"