While playing in BlueMix and looking for cool things to try, I came across this chap 



Now, he has got some really cool starter BlueMix ‘chat’ apps that you can have a play with, modify and bend to your will. I recommend you have a play – here is the link:



What impressed me was that the process of picking up and playing was so simple. Effectively, playing breaks down into three easy steps


1  Grabbing some context information

Applications need to retrieve certain context information from environment variables. Two prominent examples are:

  • VCAP_APP_PORT (integer) to get the port where the application should listen
  • VCAP_SERVICES (JSON object string) to get access information for services used by the application such as a database service

Please find below a simple code snippet to be used for applications based on node.js:

// Get port
var port = process.env.VCAP_APP_PORT;

// Get credentials to access mongo database service
var services = JSON.parse(process.env.VCAP_SERVICES);
var mongoAddress = services.mongolab[0].credentials.uri;

2. Deploy the App’

Simple chat application based on node.js that logs all conversations in a mongo database.

First, create a Bluemix account at http://www.bluemix.net. Second, install the cf command-line tool and connect it to Bluemix using your Bluemix account. Then, run the following commands:

git clone https://github.com/jojow/bluemix-demo-apps.git
cd bluemix-demo-apps/chat
cf push mychatapp -c 'node app.js'

Of course, you can use a different name for your application instead of “mychatapp”. Now, use the cf create-service SERVICE PLAN SERVICE_NAME command to create a mongo database service:

cf create-service mongolab sandbox chatlogdb

Use the cf bind-service APP_NAME SERVICE_NAME command to bind the service to the application:

cf bind-service mychatapp chatlogdb

Restart the application to refresh all environment variables for the application. This enables the application to connect to the database:

cf restart mychatapp

Go to http://mychatapp.mybluemix.net to access the chat application. 


and then…

3. Deploy the viewer

Simple mongo database viewer based on mongo-express to view the chat logs produced by the chat application.

Similar to the deployment of the chat application, run the following commands to deploy the chat log viewer and connect it to the same mongo database:

cd ../chatlog-viewer
cf push mychatlogs -c 'node app.js'
cf bind-service mychatlogs chatlogdb
cf restart mychatlogs

Go to http://mychatlogs.mybluemix.net to access the chat logs. 


Very helpfully in the README there is also a hackathon starter link so you can expand on your new found skills!  https://github.com/sahat/hackathon-starter

Nice :0)