# 4. Short Inventory IDs

Date: 2020-03-25
Driver: Wisen Tanasa

# Status

Accepted

# Context

Our building id is currently generated from UUID, and it looks like 22cadcb6-00e5-4baa-a701-785854fc2a9e. We would like to make our building id shorter to make the seekers' UX better:

  • They would be able to type the ID in the browser if they are printing the building page
  • They would be able to share the URL without URL shortener

These are the decision criteria:

  • Short
  • Low collission probability (https://zelark.github.io/nano-id-cc/)
  • Unambiguity, 0 (zero) and O (capital o) must not be confused
  • Cost of implementation

Based on the above consideration, we have the following options:

  1. 123456: Automatically generated sequence ID:
  2. canvas: Manually generated ID
  3. BBBB2221: Pretty generated letters and numbers
  4. A4VHAOFG: Random generated letters and numbers
  5. canvas-A4VH: Combination of building name and generated id

On a discussion and research:

  • We ruled out option 1, as it will be to costly to implement. It requires new infrastructure to be provisioned as we're adopting serverless architecture. Generated sequence is a concept from RDBMS. if we randomly generate numbers, the collission probability is also quite high and will need longer id.
  • We ruled out option 2, as it will involve too much human intervention
  • We ruled out option 3, as we couldn't find a library that will easily support this
  • We ruled out option 5, as we can use slug if we're concerned about the URL

# Decision

  • We will increase the ID length when we're scaling up
  • We're going with option 4, and use nanoid with the following configuration:
    • Building ID:
      • ID Length: 6
      • Characters: 23456789ABCDEFGHJKMNPQRSTUVWXYZ
    • Space ID:
      • ID Length: 8
      • Characters: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
    • Provider ID:
      • ID Length: 5
      • Characters: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

# Consequences

  • We may produce profanity words, but we're not bothered as we might get more traffic from the joke
  • We don't have to provision any infrastructure, as the ID can be generated with nanoid tiny library
  • If we generate 1 building ID per hour, we have 1% probability of 1 collission. We think this is quite high, and we don't think that we'll have 1 building ID per hour.