Outline

Initiating Server

mongod

Mongod

is the primary daemon process for the MongoDB system.

npm start

Starts the node server and executesindex.jsof the project.

Index.js

Mainly performs three tasks in following order:

  1. MongoDB connection: Mongoose makes a connection to mongoDB.
  2. Socket connection: Starts the socket server (/config/socket-server.js)
  3. Node server: Starts the node server and configure port (/config/express.js)

MongoDB Models

All the mongoDB models or schemas are defined under/server/models.

Socket Server

Socket-server performs following functionalities :

  1. Starts the socket server
  2. Once when client is connected, it checks for authentication
  3. If successfully authenticated, Socket Handler is called to handle different socket scenarios (/server/socketHanlder/index.js)

Socket Handler

Socket Handler handles three scenarios, namely:

  • requestTripHandler: Handles all the request-trip events (requestTrip.js)
  • updateLocationHandler: Handles event related to updation of user's GPS location (updateLocation.js)

Express JS

Express JS contains all the configuration details related to node server. It performs the following tasks:

  1. Create and start server
  2. Add different middleware namely:
    • bodyParser: Parse body params and attache them to req.body
    • cookieParser: Parse Cookie header and populate req.cookies with an object added as key by the cookie names.
    • Compress: Helps in decreasing the size of the response body and improve the speed of the API calls.
    • Passport: Helps to authenticate different API call.
    • Helmet: Helps to protect the application from different attacks such as cross-site scripting (XSS), script injection.
    • Cors: It helps in connecting the different domain to the application i.e enable cross-origin resource sharing.
    • APIError: Handles any other error that occurred inside of an API calls such as API not found, internal server error, parameter validation error.

    • API route: Manage various other routes of the application (/server/routes/index.js)

Passport JS

This module lets you authenticate endpoints using a JSON web token and passport-jwt. A passport middleware is added to all the routes and socket which will check for authorized token. We can also change the strategy of the passport in the passport-config.jsfile.

Api Routes

It handles the different routes of the application, namely:

  • auth: Manages the login and logout route. This route handles the authentication of the user by generating the token and registration of the new user, updating the user details, etc.
  • orders: Handles the user order related route such as getting the order history of the user, etc.
  • payment: Handles the user add card, update card, delete card and make payment for order and place the order.
  • restaurants: This route contains different routes related to the restaurant such as restaurant creation, getting near by restaurant, searching the restaurant, etc
  • foods: This route contains different routes related to the food such as food menus creation, getting food by restaurant Id, searching food, etc.
  • favourite: This route contains different routes related to the user such as mark favourite restaurant and get favourite restaurants.
  • payment: Handle payment of order, save card details, etc.
  • address: This route contains different routes related to the user such as save address by type and getting address.
  • coupons: Handles the creation of coupons and geetings.
  • earnings: Handle the delivery boy earnings calculation, etc.

Controllers

Following are the controllers defined for the above-mentioned routes:

  • auth Controller Performs user related functions, such as:
    • Create new user
    • Get user details
    • Update user-details
    • Update Profile-Pic
    • Update user-loc
    • Update delivery-boy status
    • Send otp
  • orders Controller Performs order related functions, such as:

    • Get Orders
    • Get Process Order
    • Update order status
  • payment Controller Performs payment related functions, such as:

    • Get Save Cards
    • Save Card
    • Delete Card
    • Make Payment
  • restaurants Controller Performs restaurants related functions, such as:

    • Create restaurants
    • Apply filter
    • Search Restaurants
    • Get Restaurant By Category
    • Get Total Number oF Category Restaurant
  • foods Controller
    Performs foods related functions, such as:

    • Get Menu List by Restaurants,
    • Search Food Menu
  • favourite Controller
    Performs favourite related functions, such as:

    • Create Favourite Restaurants
    • Get Favourite Restaurants
  • address Controller
    Performs address related functions, such as:

    • Create Address
    • Delete Address
    • Save Address
    • Update Address
  • coupons Controller
    Performs coupons related functions, such as:

    • Create Coupons
    • Get Coupons
  • earnings Controller Performs earnings related functions, such as:

    • Get Earnings

results matching ""

    No results matching ""