brandfolder - json + postgres
DESCRIPTION
A talk by the Brandfolder CTO, Ryan Urabe, about how Brandfolder uses JSON and Postgres to simplify it's back-end system.TRANSCRIPT
Tech Stack
Client side
Server side
Tech Stack
JSClient side
Server side
Tech Stack
Client side
Server side
Tech Stack
Client side
Server side
Tech Stack
Client side
Server side
Tech Stack
Client side
Server side
JSON
Client side
Server side
JSON
JSO
N
Client side
Server side
JSON
Client side
Server side
JSON
SQ
L+JS
ON
Client side
Server side
Schema
Brandfolder
Logos Images Documents
People Fonts Colors Videos Press Texts
•name•desc
•name•desc
•name•desc
•name•bio•phone•email•twitter•linkedin
•name•desc•googID•otherID
•name•desc•cmyk•rgb•pnt•hex
•name•desc•url
•name•desc•url
•title•body
Single Table Inheritance
Brandfolder
Assets• type• name• desc
Single Table Inheritance
Brandfolder
Assets• type• name• desc
• phone• email• twitter• linkedin• cmyk
• rgb• pnt• hex• url• googID
• otherID
Single Table Inheritance
Brandfolder
Assets• type• name• desc
• phone• email• twitter• linkedin• facebook
• aboutMe• cmyk• rgb• pnt• hex
• hsla• url• source• googID• fontsID
• adobeID• otherID• etc• etc
Single Table Inheritance + JSON
Brandfolder
Assets• type• name• desc• data =>
JSON
Codeclass Asset < ActiveRecord::Base attr_accessible :name, :description include DataDelegator
# the secret sauce!!!end
class Video < Asset attr_accessible :url data_delegate :only=> [:url]
# moar secrets!!!end
Alternatives
• HSTORE
– Supported by ActiveRecord > 4.0
– Can’t nest
• BATF
– Works with any data store
– Need to serialize
– Can’t manipulate or query in the DB
Extending Postgres JSON
• Index the JSON
• Query records by values stored in the
JSON
More Postgres + JSON
• Postgres can also serialize records
natively, returning a string of valid
JSON.
– Does not require the instantiation of
Ruby objects
– FAST
Even more
• You can install V8 in Postgres and
write custom query functions in
Javascript
– Awesome
–Web developers are already familiar
with it