This project provides a books API that will allow users to add, retrieve, reserve and edit books on a database.
Before you begin, ensure you have the following installed:
- Python 3: Version 3.7 or newer is recommended. You can download it from python.org.
- pip: Python's package installer. It usually comes with Python installations.
- make: A build automation tool. Pre-installed on macOS/Linux. Windows users may need to install it (e.g., via Chocolatey or WSL).
- Docker
- Colima (for Mac/Linux users)
- mongosh (MongoDB shell client)
- (Optional) MongoDB Compass (GUI client)
This project uses a Makefile to automate setup and common tasks.
-
Clone the repository:
git clone [email protected]:methods/NandS_BookAPIV.2.git cd NandS_BookAPIV.2
-
View available commands: To see a list of all available commands, run:
make help
This project requires MongoDB to be running locally. We recommend using Docker and Colima for a lightweight, consistent environment.
colima startdocker pull mongodb/mongodb-community-server:latestdocker run --name mongodb \
-p 27017:27017 \
-d mongodb/mongodb-community-server:latestdocker container ls
Look for a container named mongodb with port 27017 exposed.
mongosh
This opens an interactive shell. You should see a connection string like:
mongodb://localhost:27017
Open MongoDB Compass
Paste the connection string from mongosh:
mongodb://localhost:27017
Use Compass to explore, import JSON/CSV data, and manage your database visually.
The Makefile will automatically create a virtual environment (venv) and install dependencies the first time you run a command.
To run the Flask application in debug mode:
make runThe API will be available at http://127.0.0.1:5000.
This project uses Pylint to check code quality and style.
To run the linter, run the following command:
make lintThis project uses coverage.py to measure code coverage.
To run the test suite and see the coverage report:
make testIf old data is persisting, you can use an explicit
coverage erasecommand to clean out the old data.
To remove the virtual environment and Python cache files:
make cleanThis is useful if you want to start with a fresh environment.
This project is licensed under the MIT License - see the LICENSE.md file for details.