Author: Jeetan Madaan
This document will articulate the solution design of a restful interface that allows front facing applications create & retrieve contacts from a backend MongoDB database.
- Contact App-1 will pass in the name & type of the contact to the Contact API and it should create a document in contact collection.
- Contact App-2 can only pass in name and Contact API should pass in the default type while creating the document in the contact collection.
Front End Contact App-1
- In an enterprise environment, contacts are created through different channels, but we will use an angularJS web app. In this angular app, users will have the ability to provide the name & type through a form interface & we will use http service to invoke the restful contact API served from Mule runtime.
Front End Contact App-2
- Though Contact-App-2 can be any other application that can make a restful call, but to maintain the simplicity of the user story & enable demo, we will reuse the contact app-1 & create another app that will only require the name & not type so that the business logic of enriching the type will be handled in the mule implementation of the restful API.
- Develop RAML spec using API Designer that will have a contact as a top level resource with GET method to retrieve the contact & POST method to create a contact.
- Implement the API by using MongoDB connector operations of Find Documents for GET method and Insert Documents for POST method.
MongoDB – Contact Collection
- Use Atlas cloud offering of MongoDB and configure the connection string with the testuser in the connector interface.
- Setup initial Data in backend contact collection with 2 contacts [Test1 Doe, Test2 Doe] with a ‘Default’ contact type.
- Contact App also shows 2 same contacts in the Contact List.
- Create a contact with Contact App 1 with name as John Doe & type as Personal. Hit the Name, Type button.
- New Contact with the same name & type should be added to the contact collection and also be added to the contact list on Contact App.
- Create a contact with Contact App 2 with name as Jane Doe. Hit the Name button.
- New Contact with the same name & ‘Default’ type should be added to the contact collection and also be displayed in the contact list on Contact App.