Categorygithub.com/RalphTan37/inventory-crud-api
modulepackage
0.0.0-20240927033536-dd45fc5844ca
Repository: https://github.com/ralphtan37/inventory-crud-api.git
Documentation: pkg.go.dev

# README

Inventory System CRUD API Application Project

Developing a CRUD API for an inventory management system using Golang.
This is my first official Golang project after learning the theory in the Summer of 2024.
The purpose of this personal project to deepen my understanding of web development and database interaction.
CRUD, which stands for Create, Read, Update, and Delete forms the foundation of applications that manage data.

Running the Application:

To run the application, type go run main.go into the terminal.
Open another terminal and there are several commands that can be typed.

To add a new item in the inventory, type
curl -X POST localhost:3000/inventory -d '{ "item_ID": "123e4567-e89b-12d3-a456-426614174000", "name": "Example Item", "category": "Category A", "quantity": 10, "price": 19.99, "supplier": "Supplier Inc.", "location": "Warehouse 1", "status": "Available", "expiration_date": "2025-12-31T00:00:00Z" }'
To list all items in the inventory, type curl localhost:3000/inventory/.
To get an item from the inventory by ID, type curl -X GET localhost:3000/inventory?cursor=0.
To update an item in the inventory by ID, type curl -X PUT localhost:3000/inventory/123e4567-e89b-12d3-a456-426614174000.
To delete an item in the inventory by ID, type curl -X DELETE localhost:3000/inventory/123e4567-e89b-12d3-a456-426614174000.

Notes:
-X - specifies the HTTP method
Can add -v at the end of the command line to fully view the HTTP headers
-d stands for data and used to send data as part of an HTTP request

In the first terminal, to terminate the server, press Crtl + C.

Third-Party Dependency:

Using Go-Chi to manage HTTP requests and the middleware package for logging HTTP requests and responses.
Go-Chi is a lightweight, idiomatic and composable router for building Go HTTP services.
To install Go-Chi, type: go get -u github.com/go-chi/chi/v5 in the terminal. An entry should be added to the go.mod file.
Note: go.sum file now exists - used to ensure consistency across package versions in case they are updated

Using Go-Redis as primary data storage.
Go-Redis is an in-memory data structure store - which makes it fast. The downside if that the data stored only usually lasts for a short time. Not as safe as PostgreSQL (probably the better chocie for this project).
To install Go-Redis, type: go get github.com/redis/go-redis/v9 in the terminal.

*Using Docker to install Redis.
Docker is an open-source platform that automates the deployment, scaling, and management of applications using containerization - lightweight, standalone, and executable software packages.

docker ps lists the running containers on Docker host.
sudo service redis-server stop stops any current Redis servers running.
docker run -p 6379:6379 redis:latest will download and run the latest Redis img and bing the system 6379 port to the docker container 6379 port. To check the redis is running, type redis-cli in a second terminal and 127.0.0.1:6379 prompt is returned- can enter KEYS * to retrieve all keys in selected database.

Using Google's UUID Package for assigning unique IDs to items.
To install, type: go get github.com/google/uuid.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author