RonRaifer / RTB

RTB (Real-Time-Biding) API. A service which loads and serves REST API requests.

Home Page:https://ronraifer.github.io/RTB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RTB Task, Ron Raifer.

Given By Start.io

This assignment was given to me by Start.io, to test my capabilities.
I have been asked to implement a service which loads the given csv files and serves REST API requests.
During the implementation, I reviewed the given data and looked for the most relevant tools to accomplish the best results. It was a great opportunity to learn new technologies!.

Tech

RTB uses a number of open source projects to work properly:

  • Python - the programming language
  • FastAPI - fast (high-performance), web framework for building APIs with Python 3.6+
  • DASK - provides advanced parallelism for analytics
  • pydantic - enforces type hints at runtime, and provides user friendly errors when data is invalid
  • uvicorn - a lightning-fast ASGI server implementation, using uvloop and httptools
  • pytest - framework makes it easy to write small tests

Installation

This project requires Python v3.6+ to run.

Clone the project or download it directly:

git clone https://github.com/RonRaifer/RTB.git
cd RTB

Install the dependencies, using pip, via running the next command:

 pip install -r requirements.txt

Running the App

RTB Application works in two ways: running main.py, or via terminal using uvicorn. This section will guide you and explain how to run the app in each mode.

!Run\Debug main.py

  • Make sure you have Insomnia or equivalent.
  • Next, through your IDE or CMD, run main.py
  • The API is now reachable through http://127.0.0.1:8000
  • Open Insomnia, and add GET requests as your wish.
  • Now tick the 'Send' button, and review the response.
  • Example "degifted" below

how_to_debug

!Run Via Terminal

Via terminal (IDE/cmd), enter the following:

uvicorn main:app --reload 

Next, open your browser (or Insomnia), and navigate to:

http://127.0.0.1:8000

Then, navigate to the desired request, with the relevant arguments:

http://127.0.0.1:8000/keepalive
http://127.0.0.1:8000/userStats/?user_id=YOUR_USER_ID
http://127.0.0.1:8000/sessionId/?session_id=YOUR_SESSION_ID

Swagger

To access the interactive API documentation, make sure the app is running, and then navigate to:

http://127.0.0.1:8000/docs

how_to_docs

Further Improvements

Tests

  • Add more test cases to cover all the possibilities.
  • Add tests to the session data.

Tech

Redis might be a good idea to use.

It is possible to keep the Pivots data in Redis. By that, the data is loaded into the Cache, and we can use it as a key value storage. This allows us to maintain the data in Real-Time, instead of loading the whole data each time (locally).

Contact Info

Mail me: ronraifer@gmail.com

About

RTB (Real-Time-Biding) API. A service which loads and serves REST API requests.

https://ronraifer.github.io/RTB


Languages

Language:Python 100.0%