Giter Site home page Giter Site logo

stockdemo's Introduction

Build Status

A simple stock demo

This is a project created within a couple of hours to demonstrate how a simple REST based service can be implemented that manages an imaginary stock of articles.

The outline of the service was specified as follows:

The task is to develop a stock management as a Rest-Microservice in Scala. A stock management maintains the current
stock amount for a product. The stock can be increased (refill) or decreased (client buys a product). The stock
should be maintained on a per-product basis. If you are quick you can also implement a "reserve product" mechanism,
that blocks a product in the stock until the client actually buys it (similar to the seat reservation system for
flight tickets). However this is optional.

The project should be checked into a public code repository of your choice like Github, Bitbucket or Gitlab.
It must contain tests and run out of the box, i.e. it should not require manual installation of other components.
Use a build system of your choice (e.g. Maven, SBT, Gradle).

Technical Details

  • The build system used for the example is SBT 1.1.1

  • The technical stack for the REST service is Akka HTTP for the REST interface and an Actor bases in memory backend for the Stock Manager

  • The specification above has been transformed into a specification based on ScalaTest, first for the backend and then the same test cases for the REST interface.

  • Reservations can be made for available quantities of products for a given amount of time. After that time the reservation can’t be fulfilled any longer.

  • A fulfilled reservation is deducted from the stock without modification of the quantity.

Running and Building

  1. A local installation of SBT is required to execute the project.

  2. Simply checkout the project from github

  3. Switch to the checkout directory and

    1. run sbt test to execute the tests.

    2. run sbt run to execute the server mainline.

Note

The server will start to listen on port 9999 by default. This port can be configured by changing the file src/main/resources/application.conf without modifying the code.

Limitations

  • Exerything runs in memory without any preservation of state across server restarts.

  • The documentation should be improved to document the complete REST interface with JSON document examples. So far, the JSON is created implicitly in the test case for the REST service using the JSON marshalling support.

  • The project is missing a UI, a standard UI for testing REST services can be used, for example Postman


Have fun

Andreas

stockdemo's People

Contributors

atooni avatar

Stargazers

MyselfPiyush avatar

Watchers

 avatar James Cloos 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.