Medium Feed

 

Tuesday, December 18, 2018

How to build a basic online Taxi service mobile application

In this tutorial, we will see how to build a basic UBER or OLA like functional Taxi booking service mobile application and what it involves to host in google play store.

This is the experiment I did few months back in spare time. Here, will try to explain  technology stack involved in development from end to end and sharing my github repository where you can access entire source code too.


To develop back end and front end, the technology stack I have chosen are

  • Node as web server
  • Node Express JS - as web framework
  • HTML 5 Geo location API /Google map API -  for location navigation
  • Mongo DB - as data source to store cab driver & user information.
  • Socket.IO - as websocket programming library for real-time bidirectional event-based communication for live location emitting
  • RabbitMQ - for scalability as message broker to the subscribed web sockets.
  • Cordova - Hybrid mobile application development framework ( i.e can run in both IOS and Android)
  • Express JS - Building Rest API services backbone.

* Note: I have read in google, currently the Uber architecture also is based on Node Server only.


For any basic can booking service application, the high level requirements can be


As Uber driver login:


  • Ability to sign up and login as driver
  • Create profile Email, Phone number payment account information.
  • Live navigation to cab service booked user pick up and drop location
  • Push notification if new users booked.
  • Ability to view booked users basic information.

As Uber user login:


  • Ability to sign up and login as user
  • Create profile Email, Phone number, etc
  • Live listings of taxi's which are near by
  • Ability to see list of taxi options available ( Mini, Zedan...etc)
  • Ability to book taxi for trip
  • Live navigation tracking of where cab driver coming now
:-) Hope it has basic needed functionalities.


Ok..Let's IMPLEMENT...


Before we start coding, let us first setup the development environment needed to run our application.



Node setup 


if you are new to Node development, you can follow below steps to setup node dev environment in your machine.

Download and install Node from
        https://nodejs.org/en/
  • Make sure you added Node JS in your system environment PATH variable.
  • To test installation, open command prompt and type "node ---version". If version number displayed. It installed correctly and working !


Setting Up Database environment


 For user management and taxi booking session management the backend database system I used is MongoDB instance. Considering the advantages, easy Node +  MongoDB integration  and cost fact of cloud service provider with the account I have, i had chosen MonogDB as DB instance, but it is absolutely your choice to prefer a reliable DB system.

For peoples who are new to MongoDB, you can follow my old post related to setting up MongoDB development environment.


http://ramstepsonweb.blogspot.in/2016/01/how-to-setup-mongodb-environment.html.



Testing MongoDB installation in your machine.


Open command prompt

  • Navigate to “C:\MongoDB\Bin” folder (or the path you have installed MongoDB)  in command prompt
  • Type “Mongod” and hit enter. Now you should be able to see message like “Waiting for connections on port 27017” in your command prompt
  • Open a new command prompt ( don’t close exiting command prompt ) and navigate to “C:\MongoDB\Bin” folder in command prompt. Type “Mongo” and enter. You will be getting a message “MongoDB shell version and connecting to “test” db” Also you can notice in other opened command prompt, the console message got changed to         “Connection accepted from “127.0.0.1”…etc”


Setting Up Cordova platform


Corodova is the mobile development platform for Hybrid mobile application development.


For peoples who are new to Cordova Hybrid app development, here are the steps to setup development environment in your local machine.


Cordova behind the scenes running in GIT version control system, so as prerequisites first install GIT in your machine ( ignore if you already have GIT installed in your machine)  Download and install from: http://git-scm.com. Default settings are recommended.


After GIT installation you can install Cordova using Node Package Manager (npm). 


npm install -g cordova


You can confirm the installation by running cordova --version in your command prompt.


Other Dependencies Setup


  • Download and install RabbitMQ from :https://www.rabbitmq.com/install-windows.html
  • In command prompt navigate to project folder run below commands to setup the express and mongo client dependencies.    
               npm install -g express
           npm install mongodb -- save   (IMPORTANT : Npm installs latest version of                          MongoDB which does not supprt. db.collection() function, hence update project.json file                to change mongodb version to "^2.1.4")
           npm install socket.io --save


All Done, you have the development environment setup.


Run the Code and Mobile APP build 


Clone the source code from my Github repository
https://github.com/ramkrivas/ani-hola.git

In the command prompt 

> Navigate to "C:\MongoDB\bin" and start MongoDB instance
      Type Mongod in one command prompt
      Type Mongo in another command prompt 

> Navigate to "NodeAppDevelopment" folder and run node server file by " node hehaserver.js". This will run the application in your local machine.

> Navigate to "Services" folder and APIServer.js NODE server file, this will run API in your machine.


Host the app in Google Play store.


As prerequisites makes sure your node App and DB instance are running in cloud or in your on-premises system.

To host your application in play store, you would need a google play store licence which may cost of 25 $ 

To build your application for play store hosting ready. you can follow below steps.

Assuming your project folder is C:\MyUberApp

Step 1: Navigate to your Project Folder in command prompt

Step 2: Type "cordova build --release android"

Step 3 : Navigate to build output path: ...\platforms\android\build\outputs\apk

Step 4: Sign apk using below command
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOURAPP.keystore android-release-unsigned.apk YOURAPP

Step 5: Compress/zip  apk
Naivate to below path in command prompt:
C:\AndroidStudio\build-tools\23.0.2\
Run the below command
zipalign -v 4 android-release-unsigned.apk YOURAPP.apk

Now the APK is ready in below path to release in Play store
  ../platforms\android\build\outputs\apk\YOURAPP.apk


The above steps will give an APK which you can upload in your play store account and make it LIVE !! .


That's all.. Your Taxi booking service application is now ready. Enjoy riding with your friends !!!