Giter Club home page Giter Club logo

tryriot-chall's Introduction

TryRiot Backend Challenge

Build a metric logging and reporting service that sums metrics by time window for the most recent hour. You will build a lightweight web server that implements the two main APIs defined below.

I've been doing for fun the TryRiot Backend Challenge which wants to :

  1. Create an expressJS app which will have multiple endpoints :

    • GET /metrics/{key}/sum (returns the sum of a given key over the past hour)
    • POST /metrics/{key} (post a new key with a given value)

    In order to build this API, I'll store the data directly in the app. The data will be stored in an object activeUsers. Here's an example :

    POST ​/metrics/​active_visitors { ​"value"​ = ​4​ }
    // activeUsers : {active_visitors: [{value: 4, time: currentTime}]} 
    POST ​/metrics/​active_visitors { ​"value"​ = 6​ }
    // activeUsers : {active_visitors: [{value: 4, time: currentTime}, {value: 6, time: currentTime}]} 
    

    For each new value added for a metric, we store the time as well.

    Why are we storing the time ?

    Because we use a cron job which is executed every 10seconds that filters if there are any values that need to be deleted from the object (currentTime - timeStored).

    What packages did I use ?

     - express
     - node-cron (to run the method every 10seconds)
     - moment (to compute the difference between two times)
    
  2. Build a SQL database schema based on this screenshot: image

    The diagram is available here

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.