Skip to content

methods/NandS_BookAPIV.2

Repository files navigation

NandS_BookAPIV.2

Project Overview

This project provides a books API that will allow users to add, retrieve, reserve and edit books on a database.

Prerequisites

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)

Getting Started

This project uses a Makefile to automate setup and common tasks.

  1. Clone the repository:

    git clone git@github.com:methods/NandS_BookAPIV.2.git
    cd NandS_BookAPIV.2
  2. View available commands: To see a list of all available commands, run:

    make help

MongoDB Setup with Docker and Colima

This project requires MongoDB to be running locally. We recommend using Docker and Colima for a lightweight, consistent environment.

Step 1: Start Colima

colima start

Step 2: Pull the MongoDB Docker Image

docker pull mongodb/mongodb-community-server:latest

Step 3: Run the MongoDB Container

docker run --name mongodb \
  -p 27017:27017 \
  -d mongodb/mongodb-community-server:latest

Step 4: Verify MongoDB is Running

docker container ls

Look for a container named mongodb with port 27017 exposed.

Step 5: Connect via mongosh

mongosh

This opens an interactive shell. You should see a connection string like:

mongodb://localhost:27017

Step 6 (Optional): Use MongoDB Compass GUI

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.

Common Commands

The Makefile will automatically create a virtual environment (venv) and install dependencies the first time you run a command.

How to Run the API

To run the Flask application in debug mode:

make run

The API will be available at http://127.0.0.1:5000.

How to Run Linting

This project uses Pylint to check code quality and style.

To run the linter, run the following command:

make lint

How to Run Tests and Check Coverage

This project uses coverage.py to measure code coverage.

To run the test suite and see the coverage report:

make test

If old data is persisting, you can use an explicit

coverage erase

command to clean out the old data.

Clean the Project

To remove the virtual environment and Python cache files:

make clean

This is useful if you want to start with a fresh environment.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •