Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 3.09 KB

README.md

File metadata and controls

63 lines (44 loc) · 3.09 KB

Challenge

This challenge is divided between the main task and additional stretch goals. All of those stretch goals are optional, but we would love to see them implemented. It is expected that you should be able to finish the challenge in about 1.5 hours. If you feel you are not able to implement everything on time, please, try instead describing how you would solve the points you didn't finish.

And also, please do not hesitate to ask any questions. Good luck!

gistapi

Gistapi is a simple HTTP API server implemented in Flask for searching a user's public Github Gists. The existing code already implements most of the Flask boilerplate for you. The main functionality is left for you to implement. The goal is to implement an endpoint that searches a user's Gists with a regular expression. For example, I'd like to know all Gists for user justdionysus that contain the pattern import requests. The code in gistapi.py contains some comments to help you find your way.

To complete the challenge, you'll have to write some HTTP queries from Gistapi to the Github API to pull down each Gist for the target user. Please don't use a github API client (i.e. using a basic HTTP library like requests or aiohttp or urllib3 is fine but not PyGithub or similar).

Stretch goals

  • Implement a few tests (using a testing framework of your choice)
  • In all places where it makes sense, implement data validation, error handling, pagination
  • Migrate from requirements.txt to pyproject.toml (e.g. using poetry)
  • Implement a simple Dockerfile
  • Implement handling of huge gists
  • Set up the necessary tools to ensure code quality (feel free to pick up a set of tools you personally prefer)
  • Document how to start the application, how to build the docker image, how to run tests, and (optionally) how to run code quality checkers
  • Prepare a TODO.md file describing possible further improvements to the archtiecture:
    • Can we use a database? What for? SQL or NoSQL?
    • How can we protect the api from abusing it?
    • How can we deploy the application in a cloud environment?
    • How can we be sure the application is alive and works as expected when deployed into a cloud environment?
    • Any other topics you may find interesting and/or important to cover

How to start the application

The easiest way to start the application is to use the provided docker-compose.yml file with next command:

docker compose up

This will build a new web server image for Docker, mapping the project directory to an /app directory in a container, and start the application on port 9876 in development mode with enabled debugging support. You can then use the following command to test it:

curl -H "Content-Type: application/json" -d '{"username": "justdionysus", "pattern": "import requests"}' http://0.0.0.0:9876/api/v1/search

How to run tests

To run tests, you can use the following command:

pytest

To run tests with coverage report in terminal, you can use the following command:

pytest --cov-report term-missing --cov-branch --cov=gistapi/ tests/