GO-WAREHOUSE-API
GO-WAREHOUSE-API is a project built to meet the challenge of the Senior Back End Engineer Take Home Test. This repository implements a simplified warehouse management system using Go, designed to demonstrate key back-end engineering skills, including handling real-world scenarios such as stock tracking, inventory management, and building APIs.
Key Features:
-
User Service: Simple authentication system allowing users to log in using either phone or email.
-
Product Service: API to list products, including stock availability, retrieving product information from the database.
-
Order Service:
- Checkout and Stock Deduction: Manages the checkout process, reserving product stock and ensuring stock isn’t oversold.
- Stock Release: A mechanism to release reserved stock if payment is not completed within a specified time frame, implemented via a background job or timer.
-
Shop Service: Each shop can manage one or more warehouses.
-
Warehouse Service:
- Stock Management: Manages stock quantities per warehouse.
- Transfer Products: Allows stock transfers between warehouses, ensuring accurate updates to stock levels.
- Active/Inactive Warehouses: Tracks warehouse statuses, excluding inactive warehouses from available stock counts.
Common Considerations:
- Concurrency and Locking: Implemented to ensure data consistency when multiple users access and modify stock simultaneously.
- Monitoring and Logging: Tracks system activities and logs errors for better system oversight.
- Error Handling: Robust error handling to gracefully manage failures.
- Testing: Includes comprehensive unit, integration, and end-to-end tests.
- Scaling: Designed with horizontal scaling in mind to handle increased traffic and data volumes.
- Deployment and Containerization: Uses containerization techniques (e.g., Docker) and can be managed using orchestration tools like Kubernetes.
Architecture
High-Level Design (HLD)
Database Schema
Running the Service
To get the GO-WAREHOUSE-API up and running on your local machine, follow the steps below:
1. Clone the Repository
Start by cloning the repository:
git clone https://github.com/bearaujus/go-warehouse-api.git go-warehouse-api
2. Navigate to the Project Directory
Move into the project directory:
cd go-warehouse-api
3. Set Up Environment Variables
You need to create a copy of the .env.example
file and name it .env
in the etc/files/
directory:
cp etc/files/.env.example etc/files/.env
4. (Optional) Customize Environment Variables
Feel free to adjust the environment variables to suit your needs. You can modify the .env
file using your favorite text editor:
nano etc/files/.env
5. (Optional) Install Makefile
If you haven’t installed Make yet, you can install it using the following commands:
sudo apt update
sudo apt install make
6. Run the Application
Finally, you can run the application using make
commands:
- To start the application in the background:
make up
make down
7. Debugging
After you started the service, you can see the log files at:
build/log/postgres-master.log
build/log/postgres-replica-1.log
build/log/postgres-replica-2.log
build/log/postgres-replica-3.log
build/log/redis.log
build/log/service-order.log
build/log/service-product.log
build/log/service-shop.log
build/log/service-user.log
build/log/service-warehouse.log
Using the Service
You can explore the API via Postman. Full API documentation is available here: API Spec.
Made with ❤️ by bearaujus © 2024