Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Book Store Inventory

Showcase Project
MIT License

A simple book store inventory backend built using the Gin framework and SQLite as the database.

💻 Tech Stack

  • Go : Programming language
  • Gin : Web framework
  • SQLite3 : A sqlite3 database driver

📖 How to Use / Run on Your Machine

I am using HttPie for API testing you can use any tool as per your requirement and curl is fine too :D

Important

I am using WSL (Ubuntu). I recommend using Linux/WSL or macOS.


📦 Keploy Installation

for detailed installation info visit https://keploy.io/docs/server/installation/#keploy-installation

 curl --silent -O -L https://keploy.io/install.sh && source install.sh

🧰 Setup Project Locally:

  • Clone the repository:
git clone https://github.com/keploy/samples-go.git
  • Navigate to the project directory:
cd book-store-inventory
  • Install dependencies:
go mod download
  • Generate Database with some default data:

Important

OPTIONAL STEP as I have already included the book_inventory.db

delete the book_inventory.db in DB/book_inventory.db and use below command to generate new one

go run migrations/migration.go
  • Building the Application Binary:
go build

🚀 You're all set! Now you have book-store-inventory


📥 Capture the test cases using Keploy

sudo -E keploy record -c "./book-store-inventory

Tip

If any error occur try above command without sudo -E


📡 Open the Postman/Httpie and Make Request

GET READ
PUT DELETE

📑 Available REST API End Points

Method Endpoint Description
GET http://localhost:9090/api/v1/books/ Get all books
GET http://localhost:9090/api/v1/book/id/:book_id Get a book by ID
POST http://localhost:9090/api/v1/book/add/ Add a new book
DELETE http://localhost:9090/api/v1/book/delete/ Delete a book
PATCH http://localhost:9090/api/v1/book/update/ Update a book
GET http://localhost:9090/api/test-api Test API (New Endpoint)

Tip

for now just call GET for http://localhost:9090/api/v1/books/

and record this test


🧩 Usage Examples

Important

Add these json value as body while making request

  • POST (Add New Book)

body of the request

{
  "title": "Gunaho ka Devta",
  "author": "Dharamvir Bharti",
  "price": 599.99,
  "published_date": "1949-01-01T00:00:00Z",
  "stock_quantity": 5
}
  • DELETE (Delete Book by ID)

body of the request

{
  "book_id": 6
}
  • PATCH (Update Book by ID)

body of the request

{
  "book_id": 6,
  "title": "Gunaho ka God (latest edition)",
  "author": "Dharamvir Bharti Ji",
  "price": 599.99,
  "published_date": "1949-01-01T00:00:00Z",
  "stock_quantity": 5
}
TEST API

🧪 Run the captured test case

Important

Stop the test capturing by pressing ctrl+c or ctrl+z

start the test using keploy

sudo -E keploy test -c  "./book-store-inventory" --delay 1
PUT DELETE

🌱 Todo / Future Improvements

  • Show All Books Data
  • Get Particular Book By ID
  • Add New Book Data
  • Delete Book Data
  • Update Book Data
  • UI for this Application (NextJS/Vite-React)

🧭 About

This project was created as a sample to understand the working of Keploy.