####Design Document
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.
- Make sure you have
docker-compose
anddocker
installed on your machine (don't want to use docker? See below!) - Clone the repo using
git clone https://github.com/wakawaka54/ReturnPath-Go.git
- Enter into the repo
cd ReturnPath-Go
- 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
- Run
docker-compose up
- This should start up both images
- The frontend should be mapped to
http://localhost:1400
- The backend should be mapped to
http://localhost:1337
Well, you don't have to use Docker! 🙆♀️
- You will need one of the latest versions of Go. I used
go1.7
for this particular project. - Find the
src/
folder that goes along with your installation ofGo
. If you don't know what I am talking about, Go follow the guide. No pun intended. - You can
git clone https://github.com/wakawaka54/ReturnPath-Go.git
directly into the /src folder cd ReturnPath-Go.git
thencd rpapi
to get into the rpapi directory.- Run
go get
to fetch all the dependencies and usego install
to generate the binary into the /bin folder of your Go installation - 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 theGO_HOME
environment variable
- You can now
cd ..
andcd rpfrontend
and usego get
to fetch all the dependencies andgo install
to generate the binary - 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
inconfig.json
in the rpfrontend directory to the correct rpapi address on your machine.
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 idsentence
- get sentences that contains sentencetags
- 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.
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
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
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