docs.zenspace.io
    docs.zenspace.io
    • ๐Ÿงญ Introduction
    • ๐Ÿงฑ System Components
    • ๐Ÿงฐ Tech Stack
    • ๐Ÿ—๏ธ System Architecture
    • ๐ŸŒ Deployment Architecture
    • ๐Ÿ—„๏ธ Database Design Documentation
    • API Endpoints
      • RaspberryPi
        • Heartbeat API
        • Retrieve all active sensors and device permissions
        • Control a device (e.g., turn on/off, adjust intensity)
        • Enable or disable a device
        • Register a meeting space ID and retrieve network details
      • Meeting Space
        • Schedule meeting space state
        • Get meeting spaces by customer
        • Get meeting space state by ID
        • Get meeting space state by device ID
        • Disable meeting space state
        • Send meeting space state by meeting space ID
        • Store meeting space availability
        • Create Google Calendar
      • Device Management
        • Create device
        • Create device sensors
        • Create or update admin unlock codes
        • Upload meeting space screenshot
      • Authentication
        • Create authorization token
      • Messaging
        • Send message to Android device
      • Booking
        • Send meeting space state by booking ID
        • Create or update booking

    ๐Ÿ—„๏ธ Database Design Documentation

    ๐Ÿงฎ Supabase PostgreSQL Overview#

    We use Supabase as our backend database solution. It provides robust, scalable, and real-time PostgreSQL support with automatic APIs and authentication.
    Our system is organized into two main databases:
    ๐Ÿ“˜ Bookings Database: Manages all user reservations, time slots, payments, and meeting room data.
    ๐Ÿ”Œ Automation Database: Controls and logs SmartPod hardware components, sensor data, device permissions, and configurations.

    1๏ธโƒฃ Bookings Database Schema Documentation (Supabase PostgreSQL)#

    This document describes the structure of the Bookings database used in our application. It includes all tables, their fields, and brief descriptions.

    Table: amenities#

    Column NameData TypeDescription
    idintegerPrimary key for the amenity.
    nametextName of the amenity (e.g., WiFi, AC).
    created_attimestampTimestamp of when the amenity was created.
    updated_attimestampLast updated timestamp.

    Table: app_users#

    Column NameData TypeDescription
    iduuidPrimary key for the user.
    emailvarcharUnique email address.
    namevarcharFull name of the user.
    password_hashvarcharHashed password (if used).
    roletextRole (admin, user, etc.).
    created_attimestampWhen user was created.
    updated_attimestampWhen user was last updated.
    user_iduuidLinked Supabase Auth user ID.
    phone_numbertextPhone number of the user.
    customer_iduuidLink to customer entity.

    Table: bookings#

    Column NameData TypeDescription
    iduuidPrimary key.
    meeting_space_iduuidForeign key to meeting_spaces.
    user_iduuidForeign key to app_users.
    typetextType: 'Pay as you go' or 'Pre-booking'.
    statustext'Ongoing', 'Completed', 'Cancelled'.
    start_timetimestampStart of booking.
    end_timetimestampEnd of booking.
    total_amountnumericTotal cost of booking.
    voucher_codetextApplied voucher code.
    payment_statustext'Paid', 'Pending', etc.
    room_indicatorsjsonbExtra indicators (e.g., light, fan).
    cancellation_reasontextReason for cancellation.
    created_at / updated_attimestampTimestamps.
    user_infojsonCached user details.
    booking_overridebooleanAllow override.
    invoice_numberbigintUnique invoice number.
    meeting_space_event_idtextExternal calendar event ID.
    group_event_idtextGroup calendar ID.
    payment_iduuidFK to payments.
    unlock_keytextFor IoT unlock.
    device_manage_urltextURL to manage pod.
    customer_iduuidFK to customers.
    discount_amountnumericTotal discount.
    total_amount_to_paidnumericFinal payable amount.
    voucher_datajsonbFull voucher details.
    voucher_redeem_idtextVoucher redemption ref.
    refunded_amountnumericAmount refunded.
    refund_percentagenumeric% refunded.

    Table: customers#

    Column NameData TypeDescription
    iduuidPrimary key.
    namevarcharCustomerโ€™s name.
    address fieldsvarcharFull address (street, city, etc.).
    logo/footer_logotextImage URLs.
    api_keyvarcharFor internal API access.
    customer_identifiertextUnique 6-char ID.
    emailtextUnique email.
    slugtextURL-safe identifier.
    phone_numbertextOptional phone.
    company_nametextOrg name.
    is_activebooleanEnabled/disabled.
    created_at / updated_attimestampTimestamps.

    Table: groups#

    Column NameData TypeDescription
    iduuidPrimary key.
    namevarcharGroup name.
    created_by / updated_byuuidUser who created/updated.
    calendar_idtextGoogle Calendar ID.
    time_zonetextTime zone.
    date fieldsdateValidity range.
    indoor_building_image / indoor_floor_plantextImage URLs.
    customer_iduuidFK to customers.

    Table: group_meeting_space#

    Column NameData TypeDescription
    iduuidPrimary key.
    group_iduuidFK to groups.
    meeting_space_iduuidFK to meeting_spaces.

    Table: log_entries#

    Column NameData TypeDescription
    iduuidPrimary key.
    entity_typetextE.g., 'booking'.
    entity_iduuidReferenced object.
    actiontextE.g., 'update'.
    user_iduuidFK to app_users.
    user_roletextRole of actor.
    descriptiontextAction log.
    created_attimestampTimestamp.

    Table: meeting_space_slots#

    Column NameData TypeDescription
    iduuidPrimary key.
    meeting_space_iduuidFK to meeting_spaces.
    start_time / end_timetimestampTime slot.
    is_availablebooleanTrue if available.

    Table: meeting_spaces#

    Column NameData TypeDescription
    iduuidPrimary key.
    name / addresstextName and location.
    typetextPod, Table, or Room.
    pay_per_hournumericPrice/hr.
    is_paidbooleanFree or paid.
    payment_formtextBooking method.
    seatsintCapacity.
    working_hoursjsonbAvailability hours.
    photos / amenitiesarrayAsset lists.
    login_typetextGuest, Account, Both.
    auth_tokenuuidFor secure access.
    created_by / updated_byuuidFK to users.
    main_imagetextImage URL.
    statustextAvailable, Unavailable.
    calendar_idtextCalendar reference.
    time_zone / slug / statetextLocation-related data.
    min_hrs_cancellationintPolicy settings.
    zeniot_meeting_space_idtextExternal system ID.

    Table: payments#

    Column NameData TypeDescription
    iduuidPrimary key.
    amountnumericAmount paid.
    currencytextCurrency (USD).
    stripe_payment_intent_idtextStripe reference.
    statustext'Pending', 'Paid', etc.
    created_attimestampTime of payment.

    Table: room_indicators#

    Column NameData TypeDescription
    iduuidPrimary key.
    nametextIndicator name.
    keytextOptional key.
    created_attimestampTimestamp.

    2๏ธโƒฃ Automation Database#

    This database is focused on smart device control, sensor states, and real-time environmental automation.

    Table: app_users#

    ColumnTypeDescription
    iduuidPrimary key; unique user identifier
    emailvarcharUnique email address
    namevarcharFull name of the user
    password_hashvarcharHashed password
    roleUSER-DEFINEDUser role
    customer_iduuidFK to customers.id
    created_attimestampRecord creation time
    updated_attimestampLast update time
    user_iduuidFK to auth.users.id; external user ref
    phone_numbertextContact number

    Table: available_slots#

    ColumnTypeDescription
    idbigintPrimary key
    created_attimestamptzCreation time
    start_datetimetimestamptzStart time of the slot
    end_datetimetimestamptzEnd time of the slot
    datedateCalendar date
    meeting_space_iduuidFK to meeting_spaces.id
    is_activebooleanWhether slot is available

    Table: booking#

    ColumnTypeDescription
    iduuidPrimary key
    created_attimestamptzCreation time
    start_datetimetimestamptzBooking start time
    end_datetimetimestamptzBooking end time
    meeting_space_iduuidFK to meeting_spaces.id
    created_by_nametextName of person who created the booking
    created_by_emailtextTheir email address
    created_by_phone_notextTheir contact number
    unlock_keytextAccess key
    external_idtextExternal system ID
    is_activebooleanActive status
    google_event_idtextGoogle Calendar event ID

    Table: booking_attendees#

    ColumnTypeDescription
    booking_iduuidFK to booking.id
    nametextAttendee name
    emailtextAttendee email
    phonetextAttendee phone number
    iduuidPrimary key

    Table: cron_logs#

    ColumnTypeDescription
    idbigintPrimary key
    created_attimestamptzLog creation time
    last_runtimestamptzLast run time of cron job
    whentextTime expression or schedule

    Table: customers#

    ColumnTypeDescription
    iduuidPrimary key
    namevarcharCustomer name
    streetvarcharAddress - street
    cityvarcharAddress - city
    statevarcharAddress - state
    zipcodevarcharAddress - zip code
    countryvarcharAddress - country
    logotextCompany logo URL
    api_keyvarcharAPI integration key
    is_activebooleanActive flag
    created_attimestampCreation time
    updated_attimestampLast updated time
    podbigintNumber of pods available
    meetingroombigintNumber of meeting rooms
    tablebigintNumber of tables
    phone_numbertextContact phone number
    customer_identifiertextUnique customer short ID
    emailtextContact email

    Table: device_log#

    ColumnTypeDescription
    device_idvarcharDevice ID
    event_namevarcharName of the event
    event_valuevarcharValue of the event
    event_descriptionvarcharDescription of the event
    timesttimestamptzEvent timestamp

    Table: device_sensor_master#

    ColumnTypeDescription
    iduuidPrimary key
    nametextInternal name
    sensor_nametextDisplay/logical sensor name
    moduletextModule the sensor belongs to
    typetextread or write
    created_attimestamptzCreation time

    Table: device_sensors#

    ColumnTypeDescription
    idintegerPrimary key
    namevarcharSensor name
    typevarcharType
    manufacturevarcharManufacturer
    device_idvarcharFK to devices.device_id
    sensor_idvarcharSensor ID
    configjsonbConfiguration object
    is_enabledbooleanWhether the sensor is active
    sensor_typevarcharOptional sensor classification

    Table: device_status#

    ColumnTypeDescription
    iduuidPrimary key
    created_attimestamptzTimestamp
    statusvarcharDevice status
    datajsonbJSON data about the status
    device_idvarcharFK to devices.device_id

    Table: device_types#

    ColumnTypeDescription
    type_iduuidPrimary key
    type_namevarcharName of device type
    type_descriptiontextDescription of type

    Previous
    ๐ŸŒ Deployment Architecture
    Next
    Heartbeat API
    Built with