Coder Social home page Coder Social logo

bankingstats's Introduction

BankingStats Rest-API with spring Challenge

important:

  1. I kept modifying and enhacing the design (on the same concepts) even after the deadline , please feel free to browse through the history of commits.

Getting Started

  1. In the base directory of banking folder run maven command: mvn package
  2. run maven Command: mvn spring-boot:run

Notes:

  1. To achieve O(1) for the /transactions endpoint I had to choose the LinkedList because ArrayList can't guarantee a O(1) for each insertion at the end of it (since it has to automatically double it's size once the array is full).
  2. TO achieve O(1) for the /statistics endpoint I have used a class StatisticService that holds the values in Statistics object and updates it once a transaction was added or removed
  3. Although TreeMap would give log(n) performance for most procedures, I did't use it since it would make the /transaction endpoint execute in long(n) and not O(1) like appending to the beginning of a LinkedList.
  4. To keep the state of Statistics up to date, a thread is run in parallel once the spring server starts and the container loads, The thread is controlled by ScheduledExecutorService that wakes it up every 50 Millsecond (instead of an expensive infinite while loop)to preform an update to Statistics which removes the transactions that are older than 60 sec.

Testing:

  1. Unit tests for the TransactionStatistics functions.
  2. Integration test for StatisticsUpdater that its working properly it takes 8 sec because time is involved.
  3. Integration test for controller end-points.

bankingstats's People

Contributors

memoalfa avatar memon26 avatar

Watchers

James Cloos avatar

Forkers

phiras maksodf

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.