A simple book store inventory backend built using the Gin framework and SQLite as the database.
-
- Install Go (version >= 1.23.3): https://golang.org/dl/
- API Testing Tool
I am using HttPie for API testing you can use any tool as per your requirement and
curlis fine too :D
Important
I am using WSL (Ubuntu). I recommend using Linux/WSL or macOS.
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- 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
sudo -E keploy record -c "./book-store-inventoryTip
If any error occur try above command without sudo -E
| 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
Important
Add these json value as body while making request
body of the request
{
"title": "Gunaho ka Devta",
"author": "Dharamvir Bharti",
"price": 599.99,
"published_date": "1949-01-01T00:00:00Z",
"stock_quantity": 5
}body of the request
{
"book_id": 6
}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
}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- 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)
This project was created as a sample to understand the working of Keploy.






