Skip to content

Latest commit

 

History

History
93 lines (69 loc) · 9.08 KB

File metadata and controls

93 lines (69 loc) · 9.08 KB

Firestore Data Model

This project stores application data in Google Cloud Firestore using a document-oriented (NoSQL) schema. The collections listed below are derived from the application's forms, utilities, and data-fetching logic and describe the shape of the documents the frontend expects.

Collections and Documents

Users

Each document is stored at Users/{uid} where the document ID matches the Firebase Authentication user ID. User documents are created on first sign-in and updated through the account settings and terms & conditions flows.

Field Type Description
uid string Firebase Authentication UID; also used as the document ID.
email string User email address sourced from authentication or edited later.
name string Display name captured at sign-up and editable in account settings.
role "User" | "Admin" Determines access to admin-only event management screens.
events string[] Event IDs created by the user; maintained when publishing, copying, or deleting events.
reviews string[] Event IDs the user has reviewed; updated after submitting feedback.
locPref string[] Preferred campus sections used to filter event notifications (e.g., "East", "Central").
timePref string[] Reserved for notification time preferences (currently stored but unused).
foodPref string[] Reserved for dietary preferences (currently stored but unused).
agreedToTerms boolean Tracks whether the user accepted the program terms; required before accessing events.

Events

Event documents live at Events/{eventId} where eventId is generated by Firestore. Documents are created via the admin event form and updated through the event management actions.

Field Type Description
id string Stored copy of the Firestore document ID for convenient lookups and client-side routing.
host string Hosting department or organization name.
name string Event title displayed across listings and detail views.
Location object Structured location with map metadata; see Location object.
locationDetails string Additional pickup instructions shown on the event page.
notes string Extra comments about the food or logistics.
duration number (minutes) Pickup window length derived from the time picker (stored as minutes even though the type is declared as string).
foodArrived Timestamp When food first became available; controls validation limits for pickup timing.
foodAvailable Timestamp Pickup start time displayed in event cards and previews.
foods FoodItem[] Array of food entries including quantity, unit, and item name.
status "drafted" | "saved" | "open" | "closed" Workflow state toggled by publishing and ending events.
images string[] Up to three Firebase Storage download URLs representing event photos.
reviewedBy string[] User IDs that already submitted feedback; prevents duplicate reviews.

Events reference the creating admin via the Users/{uid}.events array and are filtered client-side to show only status === "open" when listing public events.

Location object

The Location embedded object standardizes site-wide geocoding details used in filters and maps.

Field Type Notes
name string Human-readable location name (defaults to "BU Campus").
address string Full address displayed to users and in map popups.
abbreviation string Short label shown alongside locationDetails.
lat / lon string Latitude and longitude stored as strings, parsed when rendering maps.
campus_section string Campus region used for filtering and preference chips (e.g., East, Central).
abbreviatedAddress string? Optional shortened label when provided.

Reviews/{eventId}/Reviews

Feedback is organized under a top-level Reviews collection where each event ID has its own document containing a nested Reviews subcollection. Submissions append documents to Reviews/{eventId}/Reviews/{reviewId} with the following fields.

Field Type Description
id string Stored review document ID for client rendering.
comment string Participant feedback message (required).
date Timestamp Submission timestamp used for ordering newest-first.
images string[] Optional Firebase Storage download URLs; limited to three via the upload component.
shareContact boolean Indicates whether contact information can be shared with admins.
name string Reviewer name collected only when shareContact is true.
email string Reviewer email collected only when shareContact is true.

Submitting feedback also updates Users/{uid}.reviews and Events/{eventId}.reviewedBy arrays to reflect participation.

Media Storage

Event and review images are uploaded to Firebase Storage under events/images/ or reviews/images/. Download URLs are stored directly in images arrays, and users can manage up to three images per record.

Query & Index Considerations

The frontend issues several Firestore queries that influence indexing strategy:

  • Event listings order by foodAvailable descending and filter client-side by status === "open". Ensure a single-field index on foodAvailable exists (Firestore creates it automatically).
  • Admin dashboards query events with where("id", "in", user.events) combined with orderBy("foodAvailable", "desc"); this requires a composite index on (id asc, foodAvailable desc) for best performance.
  • Reviews are ordered by date within each Reviews/{eventId}/Reviews subcollection to show recent feedback first.

Relationships Summary

  • Users own events through the events array and must have role === "Admin" to create or manage them.
  • Participants mark event attendance by submitting feedback, which updates both the user's reviews list and the event's reviewedBy list to prevent duplicate submissions.
  • Access to event listings is gated by the agreedToTerms flag; users are redirected to accept terms before seeing live events.

This document should serve as a reference when adding new fields or updating Firestore security rules so that the client and backend remain in sync.