Use Case: On-demand application creation, agile software delivery with WSO2 App Factory
By Manisha Eleperuma
- 24 Sep, 2013
In general, a business may need to expose their data (with certain restrictions) to their partners and enable partners to expose their data within the community. Around this data, both the parent business and the partners may need to develop applications and market them. Therefore, it is vital that the parent business possesses a platform, so that any partner organization can register and build their own applications and solutions on top of that. This is exactly what WSO2 App Factory enables you to do as the parent business, thereby opening up endless opportunities.
Leisure Line Holidays (LLH) is a travel planner with several stakeholders connected to it. The travel planning portal is a combination of a number of other software systems as shown below.
|Airline reservation system||Airlines|
|Hotel reservation system||Hotels and resorts|
|Ground transportation booking system||Vehicle renters|
|Tour planning system||LLH itself|
LLH develops its own systems for tour planning. However, other systems are developed and maintained by partner organizations and exposed externally. For example, Lion Air is an airline; they have developed their own airline reservation system; they have exposed this reservation system to external parties as well via their APIs; therefore, since LLH has a partnership with Lion Air, they use Lion Air's booking system APIs in their LLH portal.
A person or a traveller comes to the LLH online portal and starts planning an overseas trip. He checks on the available and affordable flights, books a hotel to stay, and picks the locations to travel to as per the travel plan. Therefore, the LLH portal should have a flight scheduling app, a hotel reservation app, and a travel planning app.
For the flight schedule app, there needs to be flight details published by various airlines with their departure and arrival times, fares, benefits, etc. For that, the airline data should be exposed via APIs. Similarly, for a hotel reservation application, there should be hotel reservation data exposed by numerous hotels via APIs.
A travel agency can create a flight schedule app on their own. For this, it would need
- Four environments - Developing, Testing, Staging, Prod
- API store to discover flight schedule APIs created by airlines
- Sandbox and Prod keys of the above APIs (that are exposed via API-M)
- AS instance to host the webapp
- Developers to develop the app and promote to Test
- Testers to test and promote to Staging
- DevOps to promote from Staging to Prod
Once all of the above requirements are completed, you can have a production ready Flight Schedule App.
Now, let's consider how an airline company can expose their flight details API to the outside. An airline who creates an API would need the following
- A database that holds flight data
- 4 stratos environments - Dev, Test, Staging, Prod
- DS instance to expose data as a service
- API-M instance to expose the DS as an API
- Developers to develop the API and promote to Test
- Testers to test and promote to Staging
- DevOps to promote from Staging to Prod
Once all of the above requirements are met, you can have a production ready Flight detail API.
An Airline Partner will do the following to create a production ready Flight detail API
- Create a database for flight schedules and ticket fares
- Create the data service Flight Timetable using Dev Studio
- The created data service type application will be sent through the SDLC
- Create flight schedule API out of the production data service
- Obtain sandbox URL for Dev/Testing/Staging
- Obtain the Production url and expose as API
The Travel Agency will do the below to create a production ready Flight Schedule Web Application
- Create a new Web App type application in App Factory
- Discover Flight schedule API using the App Store
- Subscribe to flight schedule API as a resource for the created Web App
- Check out the project repository
- Build the web app artifact using Dev Studio
- Build the Web App
- Sets the SDLC
- QA test the Web App in the Testing environment
- DevOps deploy Pick Flight App into Production
- Keep an eye on the statistics of the project, such as Bug counts, LoC etc.
As mentioned in the last point above, the executives of an organization need to keep a close look at the high level statistics of a project status. For this, the LLH Travel Agency Owners should have CXO dashboards that show the usage of their Flight Schedule app, Status of the app while it is in Development/Testing, Resource usage such as re-using of existing APIs, etc. Below are some of the features that LLH owners will look at:
- Issues with priorities
- Issues by Stage
- Bug Assigners
- Bug Reporters
- Application Creators
- Build Status
- Resource Usage
How can the airline partner create a service for flight scheduling and expose this as an API?
Step 1: Login to AF and create a new Data Service Project. Let's say the project name is LionJetFlightScheduler and the project key is lionjet1.
Step 2: Allocate people resources for various roles. There can be multiple people working on a single project. Invite them to the respective role. The relevant person will be notified with an email and a description of the project. You can invite members into a Developer role, QA role, and DevOps role. Note that the project invitations can be sent only to the people who are listed in your User Store/LDAP. We have not implemented the adding of external people who are not in the user store to a project.
Now developers can create the necessary databases, data sources, and build the data service with relevant querying, etc.
Step 3: Create a database for the project named Lion1. With advanced options, create a DB User and a DB Template as well.
Database Name: Lion1
Advanced Options: Tick on
Database Environment: Development
User: Create New User Username: liondb1 Password: liondb1
Step 4: Create a data source for the project.
Data source Name: lionds
Step 5: From the MySQL client in your local machine, log into MySQL using the command: MySQL -u liondb1_+tRJFvrU -h rss.dev.appfactorypreview.wso2.com -p where liondb1_+tRJFvrU is the database user.
Step 6: Run the MySQL database script lionJetDb.sql. It will fill the databases created in Step 3 with test data. You can find the sample scripts in the attached example's root directory.
Step 7: Checkout the GIT project created for Data service application LionJetFlightScheduler. Do the changes required to the data service. Commit and push the changes to the git repo.
Step 8: Build and Deploy the new application. Click on Test. Make sure the service is deployed fine with the changes made to the data service.
Step 9: Go to Repos and Builds page and create a branch for the application. If we do not create a branch, we cannot perform the life cycle related promote/demote operations on the SNAPSHOT/Trunk version.
Step 10: Go to the Lifecycle Management page and click on Promote. Make sure the mandatory check list items are performed on the created data service before promoting. Now the data service will be in the QA stage.
Step 11: At the QA stage, the necessary testing will be performed on the service and if the tests are properly validated, the QA will promote the service to the Staging environment.
Step 12: Likewise, the data service will be promoted up to the Production stage. Once the service is available in production, this should be exposed via a REST API so that external parties can easily access this within their applications. This can be done by the API-Manager instance, which is a part of the App Factory solution.
Step 13: Login in to API-Manager Publisher via the URL https://apimanager.appfactorypreview.wso2.com/publisher/. Click on Add and create a new API with the details below:
Tier Availability: Unlimited
Click on Create. Once the API is created, this will be shown in the API list in the publisher. Select the newly-created API and go to the Lifecycle tab. Change the state to PUBLISHED. Now the API has been published publicly and anyone who has access to the API store will be able to discover the API and use it in their application.
How will LLH create their Flight Schedule Application in the LLH Portal?
Developers in LLH need to create a flight scheduling component for their LLH portal. Since this will be a web application, as the airline partners, they too need to login to the App Factory and develop their application using the previously created LionJetFlightSchedulerAPI and any other similar APIs exposed by the other airlines.
Step 1: Login to App Factory and create a Web Application flightschedulerapp1.
Step 2: As done in Step 2 of the above section, you have to invite all the personnel who will be involved in development, testing, and deployment of the application.
Step 3: Subscribe to the APIs created and exposed by the airlines. From the filghtschedulerapp1's Resources page, go to the APIs page. Navigate to the API Manager page from there and subscribe to the airline APIs from the flightschedulerapp1. You will get the access token along with the secret key and consumer key. Make sure you generate the keys for both the Production and Sandbox environments. The production keys will be used for the ultimate production environment. The sandbox keys will be used when using the application in the development, testing, and production stages.
Step 4: Checkout the GIT project created for the flightschedulerapp1. Do the necessary changes required for the web application to call the APIs exposed by the airlines. For this, you need to access the APIs passing the access token you obtained when subscribing to the API. A sample code can be found from sample/flightSchedulerApp1/Webcontent/index.jsp. Commit and push the changes to the git repo.
Step 5: Build and Deploy the new application. Click on Test. Make sure the app is successfully deployed with the changes made to it.
Step 6: Go to Repos and Builds page and create a branch for the application.
Step 7: Go to the Lifecycle Management page and click on Promote. Make sure the mandatory check list items are performed on the created data service before promoting. Now the data service will be in the QA stage.
Step 8: At the QA stage, the necessary testing will be performed on the service and if the tests are properly validated, the QA will promote the service to the Staging environment.
Step 9: Then, the DevOp will login and promote the application to Production. Once the Flight Schedule webapp goes to production, the external users can login to the webapp portal and check the flight schedules published by the various airlines.