Skip to content

Team-Go-Local/go_local_backend

Repository files navigation

Go Local: Backend

Table of Contents

Description

Go Local allows travelers to experience their destinations like a local by inviting local users to suggest authentic travel experiences for visitors to enjoy. The app follows a Service-Oriented Architecture pattern and consists of:

This repository houses the back-end Rails app.

To view the deployed application, please visit Go Local on Heroku

System Design

Database Schema

Screen Shot 2021-02-28 at 08 08 59

API Contract

This portion of the application exposes 12 endpoints that allow our front-end application to access our app's database. The back-end app also acts as an intermediary between the front-end app and the Cities and Places micro-services. The responses adhere to the JSON:API v1.0 specifications.

  • GET /api/v1/excursions: gets excursions for a traveler to browse

    {
        "data": [
            {
                "id": "1",
                "type": "excursion",
                "attributes": {
                    "title": "Cabrini Bridge",
                    "description": "Great spot to enjoy a picnic",
                    "location": "Harding Dr, New Orleans, LA 70119",
                    "user_id": 1,
                    "place_id": null,
                    "nearest_city": "New Orleans, LA"
                }
            },
            {
                "id": "2",
                "type": "excursion",
                "attributes": {
                    "title": "Torchy's Tacos",
                    "description": "Get the breakfast tacos",
                    "location": "1085 N Broadway, Denver, CO 80203",
                    "user_id": 3,
                    "place_id": null,
                    "nearest_city": "Denver, CO"
                }
            },
            {
                "id": "3",
                "type": "excursion",
                "attributes": {
                    "title": "Buffalo Bill Museum",
                    "description": "Haunted museum",
                    "location": "987 1/2 Lookout Mountain Rd, Golden, CO 80401",
                    "user_id": 3,
                    "place_id": null,
                    "nearest_city": "Denver, CO"
                }
            }
        ],
        "meta": {
            "cities": [
                "Denver, CO",
                "New Orleans, LA"
            ]
        }
      }
    
  • GET /api/v1/excursions/:id: gets detailed information about an excursion

{
    "data": {
        "id": "8",
        "type": "excursion_details",
        "attributes": {
            "id": 8,
            "title": "Museum of Contemporary Art Denver",
            "description": "admission is 1 penny on Saturdays for Colorado residents",
            "updated_at": "2021-03-04T21:16:33.100Z",
            "place_id": "ChIJvcHQQcF4bIcRmDttJRd0FN4",
            "nearest_city": null,
            "formatted_address": "1485 Delgany St, Denver, CO 80202, USA",
            "name": "Museum of Contemporary Art Denver",
            "types": [
                "tourist_attraction",
                "museum",
                "point_of_interest",
                "establishment"
            ],
            "phone_number": "(303) 298-7554",
            "website": "http://www.mcadenver.org/",
            "business_status": "OPERATIONAL",
            "opening_hours": [
                "Monday: Closed",
                "Tuesday: 12:00 – 7:00 PM",
                "Wednesday: 12:00 – 7:00 PM",
                "Thursday: 12:00 – 7:00 PM",
                "Friday: 12:00 – 7:00 PM",
                "Saturday: 10:00 AM – 5:00 PM",
                "Sunday: 10:00 AM – 5:00 PM"
            ]
        }
      }
  }
Additional endpoints:
  • POST /api/v1/users/:id: adds a user to the database when a new user registers.
  • GET /api/v1/:user_id/excursions: gets all of the excursions created by the user
  • POST /api/v1/:user_id/excursions: creates a new excursion; this action includes a request from the back-end to the Cities micro-service to locate the nearest metropolitan area
  • PATCH /api/v1/:user_id/excursions: updates an existing excursion
  • DELETE /api/v1/:user_id/excursions: deletes an excursion
  • GET /api/v1/:user_id/favorites: gets all of the excursions which the user has marked as favorites
  • POST /api/v1/:user_id/favorites/:excursion_id: records an excursion as a user's 'favorite' by creating a record in the favorites table
  • DELETE /api/v1/:user_id/favorites/:excursion_id: removes an excursion from the user's favorites by deleting the record from the favorites table
  • GET /api/v1/place_search: passes a search request from the front-end to the Places micro-service, and returns the micro-service's response to the front-end
  • GET /api/v1/place_details: passes a request for detailed information about a business or location from the front-end to the Places micro-service, and returns the micro-service's response to the front-end

Technologies Used

  • Rails v. 5.2.4
  • Ruby v. 2.5.3
  • PostgreSQL
  • Heroku
  • Travis-CI
  • Dependencies:
    • Faraday
    • Fast JSON API
  • Testing tools:
    • RSpec
    • FactoryBot
    • Faker
    • SimpleCov
    • Webmock
    • VCR

Local Setup

To use the project in your local environment, please follow the instructions below:

  1. Clone the repository:
    git clone [email protected]:Team-Go-Local/go_local_backend.git cd go_local_backend
  2. Install gem packages
    bundle install
  3. Create the database
    rails db:{create,migrate}
  4. To launch a local server:
    rails s
    Once the server is running you can send requests to localhost:3000
    ex: http://localhost:3000/api/v1/excursions
  5. To run tests and view the test coverage report:
    bundle exec rspec
    open coverage/index.html

Learning Goals

  • Utilize a Service-Oriented Architecture with a front-end, a back-end, and at least one micro-service
  • Consume external APIs
  • Build APIs that return JSON responses
  • Use an external OAuth provider to authenticate users
  • Deploy a production-quality user interface
  • Implement an Agile workflow, including sprint planning & reviews and use of GitHub project management & code review tools

Authors

Statistics

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published