Skip to content

2. Engine Back End

Nick Holbrook edited this page Apr 21, 2021 · 10 revisions

Our application's backend is running on AWS (Amazon Web Services) utilizing a variety of services. The primary services we're utilizing are ECS (Elastic Container Service) running on EC2 and RDS (Relational Database Service) running Aurora PostgreSQL. Our API is a Flask application containerized via Docker running on ECS.

Networking services include ALB (Application Load Balancer) and VPC (Virtual Private Cloud) which allows us to create a secure network on that cloud where we can isolate certain AWS resources from the internet (such as our database), and only allow access from our API.

Our application also utilizes Terraform, which is an IaC [Infrastructure as Code] tool that allows us to programmatically define our infrastructure setup.

For more information on the services we utilize, see the following links:

Get List of Venues

This endpoint (GET /venues/) returns a complete list of all venues that are stored in the database. Each venue has a corresponding name, description, and image that are stored on the backend as well. When the API is called, our function (link to code) returns this list of data about the venues. The API also has two optional parameters, latitude and longitude. If called with these parameters, the API will return the list of venues sorted in increasing order of distance from the user's latitude/longitude.

Get List of Destinations

Similar to the previous endpoint, GET /venues/:id/destinations/ returns a complete list of all destinations that are within the corresponding venue, with the id in the URL. These destinations also have a corresponding set of data similar to the venues, and this endpoint can also be called with a latitude/longitude pair. The endpoint will then return destination at the venue in increasing order of distance from the user's latitude/longitude (link to code).

Get Directions

The directions endpoint (GET /venues/:id/destinations/:id/directions), a part of the backend app, functions by getting a venue id/destination id pair, and returning a path of waypoints to the caller. The function responsible for this functionality creates a graph and runs a pathfinding algorithm to find the shortest distance between the user's current location and their end destination. This is done by performing the following steps:

  1. Read in a graph from the database of waypoints and paths between pairs of waypoints (link to code)

  2. Adding the user's current location as a waypoint and one edge to the nearest other waypoint (link to code)

  3. Running Dijkstra's Algorithm on the graph to find shortest path between user and end destination (link to code)

  4. Path correction to ensure no backtracking in the graph (link to code)

  5. Get bearings for each waypoint, aka the direction to next waypoint (link to code)

  6. Calculate the distance to the destination, and the amount of time it will take a user to walk to that location, assuming an average speed of 3 miles per hour (link to code)

This functionality is wrapped up and performed in this function. From here, the response is returned to the user for the relevant venue/destination pair.

Clone this wiki locally