BookHaven is a web application built for the Turing School of Software and Design's Mod 4 Capstone project.
Read more about project requirements here.
Check out our deployed website!
Table of Contents
Welcome to Bookhaven! We have designed this software to streamline the inventory management of Little Free Libraries. We aim to connect books to readers in the most efficient way possible. Our application allows you to keep track of books in your library and explore the books in libaries near you, ensuring that each story finds a reader. For more information about Little Free Library, visit them at LittleFreeLibrary.org.
Check out our front end repository:
Response
Status: 200
{
"data": [
{
"id": 1,
"type": "library",
"attributes": {
"name": "Jen & Eric's Library",
"address": {
"street": "3410 W 98th Dr",
"city": "Westminster",
"state": "CO",
"zip": "80210"
},
"location": {
"latitude": 39.7392,
"longitude": -104.9903
},
"book_count": 12
}
},
{
"id": 2,
"type": "library",
"attributes": {
"name": "Tom and Jerry's Library",
"address": {
"street": "123 S Street",
"city": "Littleton",
"state": "CO",
"zip": "80209"
},
"location": {
"latitude": 39.7392,
"longitude": -104.9903
},
"book_count": 15
}
}
]
}
Response
Status: 200 OK
{
"data": {
"id": 1,
"type": "library",
"attributes": {
"name": "Jen & Eric's Library",
"address": {
"street": "3410 W 98th Dr",
"city": "Westminster",
"state": "CO",
"zip": "80123"
},
"location": {
"latitude": 39.7392,
"longitude": -104.9903
},
"book_count": 12
}
}
}
Status: 404 Not Found
{
"errors": [
{
"status": "404",
"title": "Library not found",
"detail": "The library with id 1 does not exist."
}
]
}
Response
Status: 200 OK
{
"data": [{
"id": 1,
"type": "book",
"attributes": {
"isbn": "9781101883082",
"book_image": "http://books.google.com/books/content?id=wg0dDgAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api",
"description": "NEW YORK TIMES BESTSELLER - One million copies sold! Inspired by the life of a real World War II heroine, this remarkable debut novel reveals the power of unsung women to change history in their quest for love, freedom, and second chances. 'Extremely moving and memorable . . . This impressive debut should appeal strongly to historical fiction readers and to book clubs that adored Kristin Hannah's The Nightingale and Anthony Doerr's All the Light We Cannot See.'",
"title": "Lilac Girls",
"author": "Martha Hall Kelly",
"genre": "Fiction",
"library_id": 1
}
},
{
"id": 2,
"type": "book",
"attributes": {
"isbn": "9781680680324",
"book_image": "http://books.google.com/books/content?id=c28RMQAACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"description": "Bob Johansson has just sold his software company and is looking forward to a life of leisure. There are places to go, books to read, and movies to watch. So it's a little unfair when he gets himself killed crossing the street.Bob wakes up a century later to find that corpsicles have been declared to be without rights, and he is now the property of the state. He has been uploaded into computer hardware and is slated to be the controlling AI in an interstellar probe looking for habitable planets. The stakes are high: no less than the first claim to entire worlds. If he declines the honor, he'll be switched off, and they'll try again with someone else. If he accepts, he becomes a prime target. There are at least three other countries trying to get their own probes launched first, and they play dirty.The safest place for Bob is in space, heading away from Earth at top speed. Or so he thinks. Because the universe is full of nasties, and trespassers make them mad - very mad.",
"title": "We Are Legion (We Are Bob)",
"author": "Dennis E. Taylor",
"genre": "Fiction",
"library_id": 1
}
},
{
"id": 3,
"type": "book",
"attributes": {
"isbn": "9780451524935",
"book_image": "http://books.google.com/books/content?id=ocNGwgEACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api",
"description": "Written more than 70 years ago, 1984 was George Orwell's chilling prophecy about the future. And while 1984 has come and gone, his dystopian vision of a government that will do anything to control the narrative is timelier than ever... - Nominated as one of America's best-loved novels by PBS's The Great American Read - 'The Party told you to reject the evidence of your eyes and ears. It was their final, most essential command.' Winston Smith toes the Party line, rewriting history to satisfy the demands of the Ministry of Truth. With each lie he writes, Winston grows to hate the Party that seeks power for its own sake and persecutes those who dare to commit thoughtcrimes. But as he starts to think for himself, Winston can't escape the fact that Big Brother is always watching... A startling and haunting novel, 1984 creates an imaginary world that is completely convincing from start to finish. No one can deny the novel's hold on the imaginations of whole generations, or the power of its admonitions-a power that seems to grow, not lessen, with the passage of time.",
"title": "1984",
"author": "George Orwell",
"genre": "Fiction",
"library_id": 1
}
}
]
}
Request
{
"isbn": "12345"
}
Response
Status: 201 Created
{
"data": {
"id": 1,
"type": "books",
"attributes": {
"isbn": "12345",
"book_image": "https://img.freepik.com/free-photo/book-composition-with-open-book_23-2147690555.jpg?w=1380&t=st=1688765682~exp=1688766282~hmac=6e996dd47de09ce70e8aa6e4cb31495d8773ce0bb860ce8869d09b8657fb3166",
"description": "Books is good",
"summary": "Books is good",
"title": "Slacking 101",
"author": "Jacob",
"genre": "Educational",
"library_id": 1
}
}
}
Status: 422 Unprocessable Entity
{
"errors": [
{
"status": "422",
"title": "Book not created",
"detail": "Book could not be created because ISBN not found."
}
]
}
Response
Status: 200 OK
{
"data": {
"id": 1,
"detail": "The book with id 1 was deleted."
}
}
Status: 404 Not found
{
"errors": [
{
"status": "404",
"title": "Book not found",
"detail": "The book with id -1 does not exist."
}
]
}
-
Step 1: Install PostgreSQL with HomeBrew
- Follow these instructions.
-
Step 2: Create a new user in the PostgreSQL interactive terminal
Note: If you would like to immediately utilize this repository without altering database code follow the instructions below. If you would like to use your own username/password skip to step 3.
- Open the PostgreSQL interactive terminal.
- In a terminal window type
psql
. - You should see:
psql (14.8 (Homebrew)) username=#
- In a terminal window type
- Next create a new username and password and give this new user access to create a database.
username=# CREATE USER bookhaven WITH PASSWORD 'password'; username=# ALTER USER bookhaven CREATEDB;
- Open the PostgreSQL interactive terminal.
-
Step 3: Create the database
- Exit out of the interactive terminal by entering
\q
. - If you followed the steps above enter:
createdb -U bookhaven -W book_haven
- It should ask you for your password which will be
password
.
- It should ask you for your password which will be
- If you want to use your own username and custom database name enter:
createdb <name_of_database>
- Check to make sure the database was created.
- Open the PostgreSQL interactive terminal with
psql
. - Enter
\l
to show the list of all databases where you should seebook_haven
or the name you chose listed.
- Open the PostgreSQL interactive terminal with
- Exit out of the interactive terminal by entering
- Follow these instructions.
- Step 1: In a terminal window, navigate to a directory where you would like the project to live.
- Step 2: Run
git clone [email protected]:BookHaven/BookHaven-BE.git
- Step 1: In a terminal window, navigate just outside of the project directory.
- Step 2: Create an environment.
- run
python3 -m venv <name_of_environment>
- run
- Step 3: Activate environment.
- run
source <name_of_environment>/bin/activate
- In your terminal you should now see something like
(<name_of_environment>) /Users/<username>
- In your terminal you should now see something like
- run
- Step 4: install dependencies
- With the virtual environment still running navigate inside of the BookHaven directory
- run
pip install -r requirements.txt
- all dependencies and versions will be loaded into your virtual environment.
Note: If you followed 'Setting up a local Postgresql database' completely continue to step 2. If you used the default user to create the local database continue to step 1.
- Step 1: Update the settings file with your database credentials
- Open the repository in your code editor of choice and navigate to 'book_haven/settings.py'
- Scroll down to 'DATABASES' and change the following in the 'os.getenv('DJANGO_TEST')' section.
- Change 'NAME' to the database name you created.
- change 'USER' to your username and change 'PASSWORD' to be an empty string
''
- Step 2: migrate the database schema to link and create the tables in your local database
- In your terminal with the virtual environment running and inside of the BookHaven directory run:
python manage.py migrate
- A list of
OK
's should display - Your local database is now connected and populated with the required tables.
- A list of
- In your terminal with the virtual environment running and inside of the BookHaven directory run:
- Follow these instructions to obtain a google API key
- In the root project directory create a file named
.env
- Within that file paste this
MY_API_KEY='<google_api_key>'
and replace google_api_key with your google api key
- Within that file paste this
- Run test suite to verify everything was set up correctly
- In your terminal with the virtual environment active and while inside the BookHaven directory run:
export DATABASE_PASSWORD='1' export DJANGO_TEST=True pytest
- You should have 8 passing tests
- In your terminal with the virtual environment active and while inside the BookHaven directory run:
To run the test suite, run pytest
in the terminal. You should have 8 passing tests.
All tests are passing at time of writing.
Alec Kapicak | Andrew Bingham | Grace Joh | Thomas Hawley |
Developer | Developer | Developer | Developer |
Tiala Young | Sara Park | Judson Stevens | Jamison Ordway |
---|---|---|---|
Front End | Front End | Project Mentor | Project Manager |