Components as microservices

SOA in the front-end world

Matteo Figus / @matteofigus

Who am I

Coding, technology, conferences
London, UK

Restaurant Reservations - Free • Instant • Confirmed

more than 32K restaurants worldwide

more than 16M reservations every month

more than 450K reviews per month

The Microsites architecture

SOA from the back-end to the front-end

Europe, North and South America, Asia

millions of requests per minute

more than 50 engineers make changes every day

The monolith

Deployments every 15 days

Not very resilient

Not very robust

Code consistency (one single language)

Dedicated team for infrastructure

Dedicated team for testing

A couple of years later...



Quick deployments

More (focused and effective) testing


Diversity on tech stacks

Microsites: not a free ride!

    Static resources duplication

    Markup, javascript, css duplication


    Every microsite including ~150K of javascript libraries

    Every microsite including ~50K of css

The common parts

The common parts


A framework for developing and deploying HTML components


Enables people to create new components independently and publish them

Granular ownership



Serve as framework for experimenting and A/B testing new ideas in the front-end

Microsites have control

How does it work

Demo time!

Getting started

$ npm install -g oc

$ mkdir demo && cd demo
$ oc init test-component jade
$ echo 'div this is my component' > test-component/template.jade

$ oc dev . 3030
$ oc preview http://localhost:3030/test-component

Ship it!

$ oc registry add
$ oc publish /test-component

$ oc preview

Static resources? Let me handle this!

// template.jade


// server.js = function(context, cb){
  cb(null, {
    staticPath: context.staticPath

Client-side rendering

    <oc-component href="">
    <script src="">

Server-side rendering with node.js

npm install oc-client --save

var Client = require('oc-client'),
    client = new Client();

client.config = {
  registries: [''],
  components: {'hello-world': '~1.0.0'}

client.renderComponent('hello-world', function(err, componentHtml){
  console.log(componentHtml); // => rendered html

Server-side rendered components

$ curl

  "href": "",
  "version": "1.0.0",
  "requestVersion": "",
  "html": "<div>hello John Doe</div>",
  "type": "oc-component",
  "renderMode": "rendered"

Server-side pre-rendered components

$ curl 
-H Accept:application/vnd.oc.prerendered+json
  "href": "",
  "version": "1.0.0",
  "requestVersion": "",
  "data": {
    "name": "John doe"
  "template": {
    "src": "",
    "type": "handlebars",
    "key": "cad2a9671257d5033d2abfd739b1660993021d02"
  "type": "oc-component",
  "renderMode": "pre-rendered"


SOA is not just about code

Test, test, test

Failure is a feature

Componentise all the web!

Thank you

follow me on twitter - @matteofigus