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
![Page 2: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/2.jpg)
Tech Stack
Client side
Server side
![Page 3: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/3.jpg)
Tech Stack
JSClient side
Server side
![Page 4: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/4.jpg)
Tech Stack
Client side
Server side
![Page 5: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/5.jpg)
Tech Stack
Client side
Server side
![Page 6: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/6.jpg)
Tech Stack
Client side
Server side
![Page 7: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/7.jpg)
Tech Stack
Client side
Server side
![Page 8: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/8.jpg)
JSON
Client side
Server side
![Page 9: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/9.jpg)
JSON
JSO
N
Client side
Server side
![Page 10: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/10.jpg)
JSON
Client side
Server side
![Page 11: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/11.jpg)
JSON
SQ
L+JS
ON
Client side
Server side
![Page 12: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/12.jpg)
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
![Page 13: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/13.jpg)
Single Table Inheritance
Brandfolder
Assets• type• name• desc
![Page 14: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/14.jpg)
Single Table Inheritance
Brandfolder
Assets• type• name• desc
• phone• email• twitter• linkedin• cmyk
• rgb• pnt• hex• url• googID
• otherID
![Page 15: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/15.jpg)
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
![Page 16: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/16.jpg)
Single Table Inheritance + JSON
Brandfolder
Assets• type• name• desc• data =>
JSON
![Page 17: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/17.jpg)
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
![Page 18: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/18.jpg)
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
![Page 19: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/19.jpg)
Extending Postgres JSON
• Index the JSON
• Query records by values stored in the
JSON
![Page 20: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/20.jpg)
More Postgres + JSON
• Postgres can also serialize records
natively, returning a string of valid
JSON.
– Does not require the instantiation of
Ruby objects
– FAST
![Page 21: Brandfolder - JSON + Postgres](https://reader036.vdocuments.mx/reader036/viewer/2022062307/556a55f7d8b42a7a138b4aa6/html5/thumbnails/21.jpg)
Even more
• You can install V8 in Postgres and
write custom query functions in
Javascript
– Awesome
–Web developers are already familiar
with it