Giter Club home page Giter Club logo

returnpath-go's Introduction

Return Path with Go Build Status

Image of Yaktocat

####Design Document

Live Demo

Live API Running

Building this Repo

ReturnPath-Go is made up of two Go packages, rpfrontend and rpapi. In order to launch both of these packages, I have facilated a docker-compose file which should make it very easy to launch both of these.

  1. Make sure you have docker-compose and docker installed on your machine (don't want to use docker? See below!)
  2. Clone the repo using git clone https://github.com/wakawaka54/ReturnPath-Go.git
  3. Enter into the repo cd ReturnPath-Go
  4. Run docker-compose build
  • This should build both images, depending on how you have docker-compose configured, you may need to run this as sudo
  1. Run docker-compose up
  • This should start up both images
  1. The frontend should be mapped to http://localhost:1400
  2. The backend should be mapped to http://localhost:1337

What if I don't want to use Docker?

Well, you don't have to use Docker! 🙆‍♀️

  1. You will need one of the latest versions of Go. I used go1.7 for this particular project.
  2. Find the src/ folder that goes along with your installation of Go. If you don't know what I am talking about, Go follow the guide. No pun intended.
  3. You can git clone https://github.com/wakawaka54/ReturnPath-Go.git directly into the /src folder
  4. cd ReturnPath-Go.git then cd rpapi to get into the rpapi directory.
  5. Run go get to fetch all the dependencies and use go install to generate the binary into the /bin folder of your Go installation
  6. You can now rpapi to run the binary if you have your $PATH variable modified to include the /bin folder
  • If you don't run rpapi from inside the rpapi directory, you will get some configuration errors. You can fix these by setting the rpapi directory path to the GO_HOME environment variable
  1. You can now cd .. and cd rpfrontend and use go get to fetch all the dependencies and go install to generate the binary
  2. Again, if you have the $PATH variable modified correctly, you should be able to run rpfrontend to begin the frontend.
  • If you don't see any data showing up, this is probably because the port mappings are changed on your machine. Set the ApiAddress in config.json in the rpfrontend directory to the correct rpapi address on your machine.

API Endpoints

Sentences

GET /api/sentences

      Returns a paginated list of sentences in database.

      Supported Query String Parameters:

  • limit - limits response to certain number of sentences (default is 20)
  • offset - offsets the results by a certain number of sentences (default is 0)
  • id - get sentence by id
  • sentence - get sentences that contains sentence
  • tags - get sentences that contain tags

      Reponse:

      Headers

      X-Total-Count - Total number of sentences

[
  {
    "id": 0,
    "sentence": "why is this great",
    "tags": [
      "why",
      "great"
    ]
  },
  {
    "id": 1,
    "sentence": "why is this great",
    "tags": [
      "why",
      "great"
    ]
  }
]

      Status Codes

      200 - OK - Everything worked

      500 - Internal Server Error - Couldn't parse a JSON response for some reason.

POST /api/sentences

      Creates a sentence object in the database and assigns cooresponding tags.

      Example Request:

{
  "sentence":"this is really amazing if you think about it"
}

      Status Codes

      201 - Created - New sentence was created

      409 - Conflict - Issue parsing request JSON data

DELETE /api/sentences/{id}

      Deletes a sentence object in the database

      Example Url: /api/sentences/8520

      Status Codes

      202 - Accepted - Sentence was deleted

      404 - Not Found - Sentence with ID was not found

GET /api/sentences/statistics

      Retrieves the top 15 tags and their frequency counts on the entire current dataset.

      Example Response:

[
  {
    "tag": "great",
    "count": 30
  },
  {
    "tag": "why",
    "count": 30
  }
]

      Status Codes

      200 - OK - Everything worked, statistics was sent back

      500 - Internal Server Error - There was an issue parsing JSON data back to you

returnpath-go's People

Contributors

wakawaka54 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.