Building an app like Uber using React-Native

Madhu Naidu
3 min readJun 14, 2019

--

Part 1: Create NodeJS project and create api’s

  1. We can create the project initially using ‘npm init’ and add the required code to run the project as a Node server

or

2. We can use existing libraries which will create ready made templates to start the server.

I will be going ahead with the later approach to save time. I will be using “ express-generator” module which will create project with NodeJS and ExpressJs template. In the latest version of express most of the boiler plate already exists and makes it easy for us. Express comes with logger, default exception handler, url encoder etc

1) Install express-generator globally(“-g”) if you don’t have it already

npm install express-generator -g

2. create express app using “express app-name”

3. Navigate into the app directory and use NPM to install dependencies

4. start the server using npm start

5. Open a browser and navigate to: http://localhost:3000/. You should be able to see the below image

Our package.json will look like below:

We will be using MVC architecture to create our server side application. So we will following the below folder structure.

Various files we will be using are:

/routes/route.js will consist of all the incoming api routes. This is similar to the servlet where the incoming api calls are received and routed

/routes/user.js will consist of all api’s related to user. This is similar to creating a UserController class in Spring which will receive the api calls for “/user” and processing it and returning the respective success/failure response

/routes/trip.js will handle the respective api requests for trips

/routes/driver.js will handle respective api requests for driver

/routes/cab.js will handle respective api requests for cabs

The various api’s in each of these files can be found the previous section.

The routes.js file will look like below:

routes.js file

When an api is called, our file in /route will receive the request and route it to the file in /dao which will fetch the data from Json file.

In the next section we will look into the user api flow.

--

--

Madhu Naidu

An enthusiastic developer interested in taking up challenges in my daily life