GithubHelp home page GithubHelp logo

under-svc's Introduction

undersvc

undersvc is a backend service for under. It's primary function is to act as a global source of truth for:

  • user ratings
  • travel group status

Information is served as JSON over a REST API.

How to start the undersvc application

  1. Run ./gradlew shadowJar for Linux and 'gradlew.bat shadowJar' for Windows to build an uber-JAR containing all dependencies.
  2. Either:
  • Run directly: java -jar build/libs/undersvc-0.0.1-all.jar server config.yml
  • Or run via docker-compose: docker-compose up --build --detach
  1. Visit http://localhost:8081/healthcheck to verify the application is running and healthy.

Note: If you get an error while loading on step-2 then check the config.yml file for the database and use the one which is not being used while commenting the one that is in use.

Deployment

Builds and deployment are done automatically via Gitlab CI (see: .gitlab-ci.yml).

The application is run in Google Kubernetes Engine (see: deployment.yml).

Production secrets are stored in Kubernetes and mounted as a volume at runtime (again, see deployment.yml).

All you need to do is git push origin master and everything should happen automatically.

Talking to it

To list active groups:

curl http://$HOST:$PORT/groups

Example:

$ curl http://localhost:8080/groups \
[{"groupState":"Forming","points":"MULTIPOINT ((37.516455 126.721757))","memberUUIDs":["64656164-6265-6566-2d64-6561642d6265"],"createTime":0,"depTime":1000,"restrictions":{"MaxPeople":3}}]

To create a new group:

curl -XPOST http://$HOST:$PORT/groups -H 'Content-Type: application/json' --data '$GROUP_JSON'

Example for Creating a new group (Use curl commands)

$ curl -XPOST http://localhost:8080/groups \
    -H 'Content-Type: application/json' \
    --data '{"groupState":"Forming","points":"MULTIPOINT ((37.516455 126.721757))","memberUUIDs":["64656164-6265-6566-2d64-6561642d6265"],"createTime":0,"depTime":1000,"restrictions":{"MaxPeople":3}}'

curl -XPOST http://localhost:8080/groups \
    -H 'Content-Type: application/json' \
    --data '{"groupState":"Forming","points":"MULTIPOINT ((30.23 12.77))","memberUUIDs":["deadbeef-cafe-babe-dead-deadcafebabe"],"createTime":0,"depTime":1000,"restrictions":{"MaxPeople":3}}'

Example for getting a group by ID

$ curl http://localhost:8080/groups/1

Example for updating a group by ID (added 2 members in groupID-1)

$ curl -XPOST http://localhost:8080/groups/1 \
    -H 'Content-Type: application/json' \
    --data '{"groupState":"Forming","points":"MULTIPOINT ((37.516455 126.721757))","memberUUIDs":["64656164-6265-6566-2d64-6561642d6265","deadbeef-cafe-babe-dead-deadcafebabe","dead1728-1111-2222-3333-deadcafebabe"],"createTime":0,"depTime":1000,"restrictions":{"MaxPeople":3}}'

Example for deleting a group by ID (deleting groupID-2)

$ curl http://localhost:8080/groups/2
$ curl -XDELETE http://localhost:8080/groups/2
$ curl http://localhost:8080/groups/2

Example User RATINGS for inserting:

$ curl -XPOST http://localhost:8080/ratings/64656164-6265-6566-2d64-6561642d6265?rating=2

$ curl -XPOST http://localhost:8080/ratings/64656164-6265-6566-2d64-6561642d6265?rating=4

Example User RATINGS for getting

$ curl http://localhost:8080/ratings/64656164-6265-6566-2d64-6561642d6265

Example: You can check on the browser by hitting http://localhost:8080/groups to check if the Json loads on the browser.

Database Stuff

To create the database locally, run:

$ java -jar undersvc.jar db migrate config.yml

Currently you need to do the same thing in production manually if changes need to be made to the schema. This could possibly be automated by adding an init container to the Kubernetes deployment manifest.

under-svc's People

Contributors

johnstcn avatar kanikaghiloria avatar paritoshkc avatar piyushmankad 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.