Skip to content

marquesds/url_counter

Repository files navigation

URL Counter

API to count the number of hits in given URLs.

Installation

Just run docker compose to start the application. The endpoint should be available at http://localhost:5000.

$ docker-compose up -d

Testing

To run the tests (unit and integration), just run the following command:

$ make test

Checking and Fixing Python Code Style

Mypy:

$ make check-mypy

Flake8:

$ make check-flake8

ISort:

$ make check-isort
$ make fix-isort

Black:

$ make check-black
$ make fix-black

The coverage will also run. This project has around 98% coverage.

Design and Architecture Decisions

  • The application is organized following the Clean Architecture. The main idea is to separate the business logic from the framework and infrastructure;
  • The Docker is organized in a way that the build is multi-stage. This way is easier to rerun builds from succeeded checkpoints;
  • I'm separating the unit tests from the integration tests. Basically, the difference is that the integration tests connect to the database;
  • To increment the values, I chose to use the Redis Sorted Set data structure. According to the documentation, it has more fit to solve the problem of counting strings. Also, most of the operations has time complexity of O(log(N)), which is good for this kind of problem;
  • The application is using the uwsgi as WSGI server. It can handle multiple requests from more than one source at the same time;
  • If I had more time, I'd like to add a pagination feature, so the user can get the top 10, 20, 30, etc. URLs;

More Information

I took around 3h30 to 4h to complete this test.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published