Git Product home page Git Product logo

eded's Introduction

Pokemon Data Store

Welcome to the Pokemon Data Store. This repo defines how the pokemon data is stored.

The project structure is as follows:

utils: Stores the helper files and functions
static: static files (right now it has only the api documentation json)
routes: contains the API routes of the application
db: defines and declares the cache store used in the application and the associated functions
api_schemas: Defines the schema of the payload passed to the API's
run.py: Starting point of the application.

Cache

For the purpose of implementing the cache we have used a ordered dictionary. In this dictionary we store the pokemons records in the sorted order of their latest access. In the case when the elements already inserted into the cache are equal to the capacity of the cache and we try to insert a new element, we remove the the pokemon record that was least used in the past. This way we ensure only the newest record remain in the system. The key for this cache is the name of the pokemon.

We also implemented a reverse dictionary by the name id_to_name. The key of this dictionary is the id of the pokemon and the value is the name of the corresponding pokemon. We use this dictionary to instantaneously get the the name of the pokemon from it's id for further processing.

API endpoints

These are three API endpoints: GET /api/pokemon/name/<pokemon_name> GET /api/pokemon/id/<pokemon_id> POST /api/pokemon/ DELETE api/pokemon/delete/<pokemon_id>

Full documentation of these API can be found on swagger along with the payload.

Test Cases

Unit test cases are written using monkeypatch and pytest. All the test cases are written inside the file test_cache.py To run the test cases, we can give the command pytest test_cache.py

Techincal Specifications

  1. Python and Flask used for the application
  2. Swagger used for API documentation
  3. Gunicorn used for production deployment
  4. Marshmallow used for serialization of the API payload

Local usage

To run this application locally:

  1. Clone this repo
  2. cd into the backend-take-home-smdgoq folder
  3. Give the command gunicorn run:app from the root of this repo
  4. Access the app at http://127.0.0.1:8000 (Port might change if 8000 is already in use)

eded's People

Contributors

amritansh22 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.