11436 SSO

From Proof-of-Concept to Production-Grade With Uber and Hue

Jun 09, 2016

Previously, we discussed building a proof-of-concept app that integrates the Philips Hue API with Uber’s API to build a mobile app that seamlessly incorporates both platforms to provide a new user experience. Our app enables you to send your Uber ride status to Hue and track your ride’s progress using different colors from the Hue light bulbs.

Here, we’ll discuss building a production-grade app quickly with Apigee using out-of-the-box components that make apps thin and help them work well across various endpoints by leveraging the power of APIs.

Here’s the basic architecture that we used to build our proof of concept:



Production-grade app requirements

You might notice that it’s missing some key pieces, including user management, user preferences, data storage, an API management layer, and integration with other third-party applications.

Ideally, If we were building a production-grade app, we would require the ability to:

  • store user preferences in datastores, such as like Philips Hue settings, device settings, and user information
  • include API management capabilities like API security, rate limiting, throttling, and separation of  the API layer from server logic
  • integrate third-party services, such as the ability to turn on lights using an SMS service like Twilio when data network is unavailable
  • track app usage using API analytics
  • scale API performance to match API traffic
  • decouple client app and backend capability by providing unified API (as facade) and access mechanism (OAuth); client app for different devices can evolve independently
  • build backend capabilities as microservices for scale and faster innovation

Considering these requirements, a typical architecture would look like this:


This architecture needs a database, server-side logic to expose the database and features to the outside world via APIs, a server to execute business logic, and an API management layer to secure, scale, connect, manage, and analyze your APIs.

If you were building the solution from scratch, you’d need a database like Amazon RDS, a server (Apache, Tomcat, IIS, or Nginx, for example), and the database and functionality exposed to the outside world using APIs via server-side code logic written with PHP, Java, or some other language.

API management to the rescue

The APIs are built and managed with Apigee Edge. In this approach, we’ll use Node.js to build the intermediate APIs that facilitate seamless interaction between Uber and Philips Hue.

Edge helps with :

  • building highly customized, standalone APIs and backend services
  • building backend logic for API BaaS to leverage cloud data storage and management, user management, push notifications, and more
  • solving complex orchestration and mobile optimization problems using Apigee policies, with the advantage of a scriptable target endpoint
  • building composite services and mashups
  • rapidly developing prototypes of new APIs using frameworks like Express

BaaS helps with :

  • data storage and management
  • CRUD operations
  • User management, out-of-the-box entities, roles, and permissions
  • Geolocation-based queries, push notifications, and much more

Implementing Hueber on Apigee Edge is separated into the following steps:

  • using Express.js to build routes and APIs
  • storing Philips Hue-related information in the Apigee BaaS data store
  • using Uber WebHooks to call APIs implemented in the Apigee Edge Node.js server
  • invoking Philips Hue APIs to control the lights from Node.js servers by retrieving the Hue information from BaaS

With Apigee,  the architecture looks like this:

Let’s build a simple API that demonstrates Apigee Edge capabilities and uses Apigee BaaS for data storage:

var express    = require('express');        // call express

var app        = express();                 // define our app using express

var bodyParser = require('body-parser');


app.use(bodyParser.urlencoded({ extended: true }));



var port = process.env.PORT || 9000;        // set our port



// =============================================================================

var router = express.Router();              // get an instance of the express Router




   .post(function(req, res) {

       //turn on hue light api code goes here..

       res.json({ message: 'Light turned on !!'});



// more routes for our API will happen here


// REGISTER OUR ROUTES -------------------------------

// all of our routes will be prefixed with /api

app.use('/', router);



// =============================================================================


console.log('Magic happens on port ' + port);


The app above will be deployed to Apigee Edge using the apigeetool command:

apigeetool deploynodeapp -n {A name for your new proxy} -d {The root directory of your Node.js app} -m {The name of the main Node.js file} -o {Your org name on Edge} -e {The environment to deploy to} -b {The base URL for your proxy} -u {Your Edge email address} -p {Your Edge password}

Once it’s deployed, you can manage APIs using Apigee Edge’s built-in features and policies.



If some of your developers would like to see output in XML instead of default JSON, you can just add JSON to XML policy in the response flow to make the transformation:


Using Apigee BaaS to store user information, you can just do CRUD operations by making API calls (gone are the days where you run SQL commands):


Apigee Edge provides you out-of-the-box solutions to secure, scale, connect, manage, and analyze your APIs. Building production-grade apps quickly with Apigee makes your apps thin and flexible to meet future changes and integrations.


Creating World-Class Developer Experiences