A REST API to manage books and authors data. It was based on this challenge by Olist company.
This project was deployed on Heroku and is available here.
Before you start, install Git and Poetry. Optionally, if you want to dockerize this application, install Docker and Docker Compose.
- Clone this repository
git clone [email protected]:diogo-alves/library-manager.git
- Go to project directory
cd library-manager
- Install the requirements
poetry install
- Activate virtualenv
poetry shell
- Update the database structure
python manage.py migrate
- Start the web server
python manage.py runserver
- Start web server and database services
docker-compose up -d
- Update the database structure
docker-compose exec web python manage.py migrate
With the web server running access the API at http://localhost:8000/api/
pytest
docker-compose exec web pytest
This project implements the OpenAPI Specification (formerly Swagger Specification). The full documentation can be accessed at http://localhost:8000/api/
.
Action | HTTP VERB | Endpoint |
---|---|---|
List authors | GET |
api/authors/ |
Search author by name | GET |
api/authors/?search={name} |
Paginate authors list | GET |
api/authors/?page={number} |
Action | HTTP VERB | Endpoint |
---|---|---|
List books | GET |
api/books/ |
Filter books by name | GET |
api/books/?name__icontains={name} |
Filter books by publication year | GET |
api/books/?publication_year={year} |
Filter books by editon | GET |
api/books/?edition={edition} |
Filter books by author name | GET |
api/books/?authors__name__icontains={name} |
Create a book | POST |
api/books/ |
Retrieve book | GET |
api/books/{id}/ |
Update/Replace book | PUT |
api/books/{id}/ |
Update/Modify book | PATCH |
api/books/{id}/ |
Delete book | DELETE |
api/books/{id}/ |
A django management command was created to import a CSV file with authors names. The file must follow the format:
name
Luciano Ramalho
Osvaldo Santana Neto
David Beazley
Chetan Giridhar
Brian K. Jones
J.K Rowling
To import run:
python manage.py import_authors authors.csv
# or
docker-compose exec web python manage.py import_authors authors.csv
This project is licensed under the terms of the MIT License.