The Order Processing System is a simple backend solution for managing customers, products, and orders in an e-commerce application. It is built in Golang using PostgreSQL as the database, GORM for ORM, and Gin for handling API requests.
Setup Instructions
Clone the Repository:
git clone https://github.com/lakshay88/lakshay_OrderProcessingSystem.git
Set Up Configuration Variables:
Open config.yaml file update configuration according to your flexiblity else leave it as it is.
Install Dependencies:
go mod tidy
Build Docker Image:
docker-compose up -d
Run application
go run main.go
API Endpoints
/api/customers GET Retrieve all customers.
/api/customers/{id} GET Retrieve details for a specific customer, including their orders.
/api/orders POST Create a new order for a customer by specifying customer ID and product IDs.
/api/orders/{id} GET Retrieve order details, including the total price.
/api/products POST to add products.
/api/customers POST create customers.
PostMan Collection
In repo you will find order-serving-system.postman_collection.json It is a Post man collecation of all the API. Import if in yoyr system and test it.
Features
Data Models: Customer, Product, and Order models represent the core entities, with relationships established using GORM.
Database: PostgreSQL is used with GORM for object-relational mapping and database migrations.
API Endpoints: RESTful API endpoints for creating, updating, and retrieving data on customers, products, and orders.
Business Logic: Includes validation rules, such as preventing a customer from placing a new order if a previous one is unfulfilled.
Condiguration Based system: It is having a config.yaml file where you can step up your system config.
Gateway service: It implement server configuration
Multiple Database support: You can add different database into your system by defining its methods in database configuration.
Docker: Currently system is can be run using docker no need to install SQL in system.
Future Improvements
Add user authentication and authorization.
Add test case(currently not)
Improve validation and error handling with more detailed messages.
We can segirigate each service in microservice.
Add asynchronous processing for order-related tasks.
We can create a central logging so all the logs will be update properly. This logger can we run on differnt go routine to my main there will not be busy.