Skip to content

OPQ Data Architecture

anthonyjchriste edited this page Oct 1, 2015 · 9 revisions

This is a working document which explains our data architecture between OPQView and OPQHub.

Data from our backend (OPQHub) is generally going to be noisy and non-intuitive for the average user. The backend is responsible for creating digestible data products for the front end to consume. The following is a list of data objects and roles we see playing a part in our data design between these two components.

OPQView DB Model

Enumerations

box_event_type

  • TEMP_INTERRUPTION
  • UNDER_VOLTAGE
  • OVER_VOLTAGE
  • TRANSIENT
  • IMPULSE
  • SPIKE
  • NOTCH
  • NOISE
  • HARMONIC

grid_event_type

  • DEFAULT

access_modifier

  • PUBLIC
  • SUBSCRIBE
  • ACADEMIC

subscription_request_status

  • PENDING
  • APPROVED
  • DENIED

subscription_request_type

  • BOX
  • GROUP

Access Modifiers

access_modifers are used to control access to data. Three of our collections use access modifiers, box, box_event, and group. Each box_event inherits the access_modifiers of its box.

These collections take an array of access modifiers. The possible combinations are described below.

Access Modifiers
[] (empty list) All data and groups are private to owners of the device only.
[ACADEMIC] Same as [], but allows certain anonymous data to be used for academic purposes.
[SUBSCRIBE] Same as [], but allows other users to request permission to subscribe to a device or group.
[SUBSCRIBE, ACADEMIC] Same as [SUBSCRIBE], but allows certin anonymous data to be used for academic purposes.
[PUBLIC] Anyone can subscribe to public groups or boxes. Public data is automatically used for academic purposes.

Collections

box

  • _id: oid
  • device_id: int
  • secret_key: string
  • access_modifiers: list(access_modifier)
  • created_on: date
  • last_seen: date
  • box_events: list(box_event.oid)
  • grid_events: list(grid_event.oid)
  • messages: list(box_message.oid)
  • owners: list(opq_user.oid)
  • subscribers: list(opq_user.oid)
  • groups: list(group.oid)
  • subscription_requests: list(subscription_request.oid)

box_message

  • _id: oid
  • box: box.oid
  • message: string
  • timestamp: date
  • active: boolean

box_event

  • _id: oid
  • timestamp: date
  • duration: int (seconds)
  • event_type: box_event_type
  • value: float
  • data: list(float)
  • access_modifiers: list(access_modifier)

grid_event

  • _id: oid
  • timestamp: date
  • grid_event_type: grid_event_type
  • duration: int (seconds)
  • boxes: list(box.oid)
  • box_events: list(box_event.oid)
  • updated_on: date

opq_user

  • _id: oid
  • email: string
  • created_on: date
  • updated_on: date
  • owned_boxes: list(box.oid)
  • subscribed_boxes: list(box.oid)
  • owned_groups: list(group.oid)
  • subscribed_groups: list(group.oid)
  • subscription_requests: lists(subscription_request.oid)
  • messages: list(box_message.oid)

group

  • _id: oid
  • access_modifiers: list(access_modifier)
  • group_name: string
  • boxes: list(box.oid)
  • groups: list(group.oid)
  • owners: list(opq_user.oid)
  • subscribers: list(opq_user.oid)
  • created_on: date
  • updated_on: date

subscription_request

  • _id: oid
  • requestee: opq_user.oid
  • request_type: request_type
  • resource: opq_box.oid | group.oid
  • status: subscription_request_status
  • created_on: date
  • updated_on: date

Clone this wiki locally