Skip to main content

Collections Overview

The database consists of the following main collections:
  1. artist-clients - Manages relationships between artists and their clients
  2. availability - Stores availability schedules and time slots
  3. bookings - Contains booking/appointment information
  4. conversations - Stores messaging and communication data
  5. customerPaymentInfo - Manages customer payment-related information
  6. user-notifications - Handles user notification settings and data
  7. user-onboarding - Stores user onboarding progress and related data
  8. users - Contains core user profile information and details

Database Diagram

Database Schema Diagram

The diagram above shows the main collections in our Firebase database and how they relate to each other. Each connection line represents a relationship between collections, typically through document references.

Collection Schemas

artist-clients

The artist-clients collection uses a nested structure to manage the relationship between artists and their clients:

Key Details:

  • The collection uses a nested structure for efficient querying of artist-client relationships
  • Each artist’s document contains a subcollection of their clients
  • Client documents track booking history, spending, and artist notes
  • The bookingIds array enables quick access to all bookings between the artist and client
  • firstBookingDate is stored as a timestamp for chronological ordering

bookings

The bookings collection stores all booking information between artists and clients. Each booking document goes through various states in its lifecycle:

Booking Status Lifecycle:

The booking goes through different states, tracked by the status field:
  • REQUESTED: Initial state when client submits booking request
  • AWAITING_DEPOSIT: Artist has accepted and waiting for client’s deposit
  • CONFIRMED: Deposit received and booking is confirmed
  • COMPLETED: Tattoo session completed
  • CANCELLED: Booking was cancelled

Key Details:

  • Each booking document contains all necessary information about the tattoo request
  • The status field determines which fields are required/optional
  • Images and links are stored as URLs, with actual files in Firebase Storage
  • Timestamps are stored as numbers for efficient querying
  • The booking maintains references to both the artist and client
  • A conversation is automatically created and linked to each booking

conversations

The conversations collection manages messaging between users, with a nested structure for messages:

Message Types:

The messages subcollection supports different types of messages:
  1. TEXT: Standard text messages
  2. FILE: File attachments (images, documents, etc.)
  3. REQUEST: Booking requests with tattoo details
  4. CONFIRMATION: Booking confirmation details
  5. CANCELLED: Booking cancellation notifications
  6. EDIT: Booking edit notifications
Currently each conversation is unique per booking. We might want to refactor this to be one conversation per artist-client pair in the future.

Key Details:

  • Each conversation document tracks participants and message metadata
  • The unreadCounts map enables efficient unread message tracking per user
  • lastMessageText and lastMessageTimestamp enable conversation previews
  • Messages are stored in a subcollection for efficient pagination
  • File messages store URLs pointing to Firebase Storage
  • Special message types (REQUEST, CONFIRMATION) integrate with the booking system
  • The readBy array tracks message read status for all participants

user-notifications

The user-notifications collection manages notification state and history for each user, with a nested structure for individual notifications:

Notification Types

The system primarily supports booking-related notifications that track the lifecycle of a booking:
  • Booking Status Updates: Notifications for new requests, confirmations, edits, cancellations, and declines
  • Payment Updates: Notifications for deposit payments (to be implemented)
  • System Updates: Platform-wide notifications like new feature announcements (to be implemented)
Each notification includes relevant context like booking IDs and user names for display purposes.

Key Details:

  • Each user has a document tracking their notification state
  • lastUpdated tracks when the user last viewed their notifications
  • newNotificationIds maintains a list of notifications that appeared since the last view
  • Individual notifications are stored in a subcollection for efficient pagination
  • The isRead flag tracks individual notification read status
  • Notification data is type-safe through TypeScript generics

user-onboarding

The user-onboarding collection tracks the onboarding progress for users:

Key Details:

  • Each document represents a user’s onboarding progress
  • Boolean flags track completion status of each onboarding step
  • Steps include email verification, profile setup, calendar configuration, booking link setup, and payment setup
  • updatedAt field helps track when users last made progress in onboarding
  • Used to guide users through the necessary setup steps before they can fully use the platform

users

The users collection stores core user profile information and extends Firebase Authentication user data:

Key Details:

  • Extends Firebase Authentication with additional user profile information
  • Supports both artist and client user types
  • Artists have additional fields for styles, social media, and payment processing
  • Profile photos and media are stored in Firebase Storage with URLs in the document
  • Some fields become required based on user type and onboarding progress
  • Integrates with Stripe for artist payment processing
  • Social media integration currently focuses on Instagram, with potential for expansion

availability

This collection is still under development
The availability collection will manage artist availability and scheduling:

customerPaymentInfo

This collection is still under development
The customerPaymentInfo collection will handle customer payment methods and history:

Relationships

The database is built around several key relationships that enable the booking and communication flow:

Core User Relationships

  • usersuser-onboarding: Each user has an onboarding document tracking their setup progress
  • usersuser-notifications: Each user has a notifications document with their notification history
  • usersartist-clients: Artists have client relationships stored in nested collections

Booking Flow

  • bookingsusers: Each booking references both an artist and a client
  • bookingsconversations: Each booking has an associated conversation for communication
  • bookingsartist-clients: Bookings are tracked in the artist-client relationship

Communication

  • conversationsusers: Conversations track participants and their read/unread status
  • conversationsbookings: Messages can contain booking-related actions (requests, confirmations)
  • user-notificationsbookings: Notifications are generated for booking status changes
This interconnected structure ensures that:
  1. Artists can manage their client relationships and booking history
  2. Clients can track their bookings and communications with artists
  3. All booking-related actions are properly communicated and tracked
  4. User progress and notifications are properly managed

Data Access Patterns

[To be populated with common data access patterns]

Security Rules

[To be populated with Firebase security rules overview]

Best Practices

[To be populated with database-specific best practices]