Table of Contents
Sample demonstration project that is about serving promotions data from a backend service. The prject built on top of the REST architecture. Used Go (Gin, GORM) for code. Postgres as a storage. AWS (EC2, Security Group, Load Balancer) for deployment and handling the high load,Docker for containerization and Prometheus for metrics collection.
Live Demo
Project also uses Go program for Bulk data inserting into Postgres.
Before jumping into project cloning make sure to have
- Go > 1.17
Download from here https://go.dev/dl/
- Postgres
Download from here https://www.postgresql.org/download/
- Docker
Download from here https://www.docker.com/
- Make
Download from here https://www.gnu.org/software/make/ (Not Mandatody)
- Curl
Download from here https://www.gnu.org/software/make/ (Not Mandatody)
Instructions for setting up and running the project
- Clone the repo
git clone https://github.com/p44dev/Promotions-API.git
- Configure variables in .env file or export them
For reference: .env.sample
- Go to the Promotions-API/Bulk directory and run command below for bulk insert
make insert
- Go to the Promotions-API directory and run commands below for running app as a container
(Not a mandatory option, for testing you can just run -> go run main.go)
make dockerize make run-container
- Fetch the data from the backend server.
curl http://localhost:1321/promotions/1
- See Prometheus Logs
curl http://localhost:9091/metrics
- Use AWS EC2 more powerful Instace or deploy into Beanstalk (Now using 1 cpu from free tier)
- Add Cron Job for inserting bulk data every 30 minutes and swap tables.
- Add POST | PATCH | DELETE etc.. requests into REST service
- Containerize bulk inserting application and postgres
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Anton - @LinkedIn - antonpapazian@gmail.com
Project Link: https://github.com/p44dev/Promotions-API