Fibonacci API is a lightweight service designed to compute and serve Fibonacci numbers through a RESTful interface. It enables users to retrieve specific Fibonacci values, access paginated sequences, and manage a blacklist of restricted numbers.
Django
: Backend framework for exposing Fibonacci and Blacklisting APIs.MySQL
: Database for storing blacklisted Fibonacci numbers.
Python 3.13
(recommended way of installation is throughpyenv
, refer to the pyenv installation page)docker
(refer to the docker engine installation page)docker-compose
(refer to the docker compose installation page)direnv
(automatic environment setup tool, refer to the direnv installation page) Note: Don't forget to add the following block to the ~/.bashrc file:if command -v -- direnv > /dev/null 2>&1; then eval "$(direnv hook bash)" fi
pipenv
(python dependency and virtualenv management tool, install by runningpython -m pip install pipenv
) Note: Direnv automatically creates a virtual environment in the repository and installs the required Python dependencies, provided it has been correctly configured.
Note: Make sure you are in the project root directory
-
Allow direnv to load environment variables and create python virtual environment with required python dependencies:
direnv allow
-
Start the services: Note: This step will automatically build the Docker image for the Django app using the ./Dockerfile and start the necessary side services!
docker-compose up -d
-
Check the status of the services to ensure they are up and running:
docker-compose ps
-
Access the web app at
http://localhost:8000
.
A total of 16 tests have been implemented. To run them, use the following command:
docker-compose exec -it web python manage.py test
Method | Endpoint | Description |
---|---|---|
GET | /api/v1/fibonacci/<number>/ |
Get the Fibonacci sequence value for the given number. |
GET | /api/v1/fibonacci/list/<number>/ |
Get a paginated list of Fibonacci sequence values up to the given number. |
POST | /api/v1/fibonacci/blacklist/<number>/ |
Add a Fibonacci number to the blacklist. |
DELETE | /api/v1/fibonacci/blacklist/<number>/ |
Remove a Fibonacci number from the blacklist. |