Skip to content

yashaswi-kohli/BasicAPI-with-GoFr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💡 Library Management System

This is a simple and user-friendly REST API for managing a library's book collection. The API provides endpoints to perform various operations, such as retrieving all books, fetching a particular book by ISBN or author, updating existing book information, creating new books, and deleting books from the library. Implemented in Go with GoFr framework and MongoDB, the system showcases CRUD operations, and seamless database integration.

Getting Started

  1. Clone the repository:

    git clone https://github.com/yashaswi-kohli/BasicAPI-with-GoFr
    
    cd BasicAPI-with-GoFr
  2. Download Dependencies:

    go mod download
  3. Verify Dependencies:

    cat go.sum
  4. Run Project

    go run main.go
  5. Open Server

    http://localhost:8000/books

This will show all the books present in your database.

API Requests made using postman

1.🚀 GET Request

  • Get all Books

    • Endpoint:

      • GET /books
    • Description:

      • Retrieves a list of all books.
    • Response:

image

  • Get all Books of a Author

    • Endpoint:

      • GET /books/author/AUTHOR
    • Description:

      • AUTHOR: Obtains a list of all books with the author's name.
    • Response:

image

  • Get a book

  • Endpoint:

    • GET /books/isbn/ISBN
  • Description:

    • Retrieves a book with the isbn.
    • ISBN: It is the unique identifier for the book.
  • Response:

image

2.➕ POST Request

  • Add a new book

  • Endpoint:

    • POST /books
  • Description:

    • Create a Book and add to database
  • Response:

image

3.🔄 PUT Request

  • To update the book

  • Endpoint:

    • PUT /books/ISBN

    • Description:

      • Update the existing book in the database
    • Response:

image

4.🗑️ DELETE Request

  • To delete the book

  • Endpoint:

    • DELETE /books/ISBN

    • Description:

      • Delete the book in the database, if it exist
    • Response:

    image

UML Diagrams

  • Sequence Diagram

  • image

Database 🛢️

The project utilizes a MongoDB database to store books. For MongoDB you can use both Atlas or Compass

For Atlas

Go to website, make a cluster and set up a database, then copy the Database link. Then go to mongo folder and there in mongo.go file paste the link in connectionString and fillUP the dbName and collectionName.

For Compass

First install Compass make a database and collection and remember the name, Then install mongosh, if it is already then run it in terminal by typing

mongosh

image

Copy the link from 'Connecting to:' and then go to mongo folder and there in mongo.go file paste the link in connectionString and fillUP the dbName and collectionName.

⚡️ RUN

  • Now simply run the following command in your terminal to run the application:
go run cmd/main.go

About

Basic API with Go and GOFR

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages