Skip to content

Repository files navigation

UIT-Go Microservices Backend

A non-modern, maybe-scalable microservices backend built with Go. Should support IaC, CI/CD and technically cloud-native.

TODO

  • Remove the replace directive from go.mod files and switch to go workspaces for local dev.
  • Add extra ingress ports with azapi provider.

Repo structure

Currently support per-service deployment in GitHub Actions.

Each service will have a folder inside service folder:

  • authentication-service
  • location-service
  • logger-service
  • trip-service
  • api-gateway: what it sounds like

And also:

  • common: common shared files between services
  • proto

Apart from services, the repo also hosts infrastructure code at infrastructure folder. This should be separated into its own repo, but for easier access it's also here.

The utils folder hosts misc files for development or deployment, like init scripts for databases.

Instructions for local development

To start developing (or running locally):

Dependencies

  • Podman (recommended) or Docker installed with Compose.
  • That's it. Plug and play!

Run

Use either docker or podman command here based on which you have installed and/or want to use.s

  1. Copy .env.example file and name it .env in the same root folder. Tweak it if needed.

  2. Run the Compose app with

docker compose build
docker compose up
  1. If you make any changes and want to see the result, docker compose down then run the app again.

  2. To "clean" the environment, run

docker compose down -v
  1. To clean everything, including built images, run:
docker compose down -v --rmi all

Or, use Golang toolchain in the individual service folders if you want to run bare-metal for faster development.

Notes

All volumes used are named volumes, not mounted volumes. This is to avoid permission errors when running on rootless or SELinux environment, etc. and for easier clean-up.

Development environment are managed through a docker-compose.yml file, and may drift from the production/staging environment deployed with opentofu and CD scripts. This is a trade-off for lightweight local environment with pure containers and Compose, and to utilize managed services (Postgres, Redis,...) provided by the cloud provider (in this case Azure).

Read more:

Instructions for deploying

There will be a infrastructure folder containing deployment files.

First, to deploy the infrastructure, install azure-cli on your machine. Then, login with az login.

After that, install either terraform or opentofu. From the opentofu folder, first create a .tfvars file containing all the needed variables. There will be an example file showing needed vars.

Also, to store tfstate remotely, make a storage account then put the details inside tfvars too.

Then, just run:

tofu init
tofu plan
tofu apply

This will create an ACR, build the apps with it, then use it to create the ACA. Chicken-and-egg problem.

more info

There should be a GitHub Actions pipeline in this repo to handle the rest (CI/CD)

Footnote

Entire deploy flow is made without or with minimal LLM footprint. All mistakes are my own.

About

For SE360 year end project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages