The backend handles users' requests to list their financial transactions and provide analysis. It connects to brokers selected by the users to retrieve their assets and transactions.
- Makefile is used to run commands
sudo apt-get install make # If using WSL or any Linux distribution
choco install make # If using Powershell (not recommended, some commands may not work)-
Install gRPC here.
-
Goose is used for database migrations. Install it with the following command:
go install github.com/pressly/goose/v3/cmd/goose@latest- Swagg is used to generate the swagger file. Install it with the following command:
go install github.com/swaggo/swag/cmd/swag@latest- Gomock is used to generate mocks. Install it with the following command:
go install go.uber.org/mock/mockgen@latestThis project is using Docker. Get started here.
- Create a
.envfile to override any variables fromconfig/fihub-backend.tomlthat you need. - Please note that each variable you wish to override must have the
FIHUB_prefix. - Don't forget to override the
FIHUB_APP_ENVvariable todevelopment.
To build the project, you can use either of the following commands:
make build
make build-plain # build with verbose output progress=plainIf you only need to run the databases, you can use the following command:
make dbTo start the whole project, you can use either of the following commands:
make dev
make dev-d # detached mode
make dev-b # build on top
make dev-bd # detached & build on topIncludes Air for hot-reloading.
We recommend you to look into the Running with Docker - Databases section above to run only the required databases for debugging.
We recommend you to use GoLand as it is more convenient, especially for debugging. See Run/debug configuration.
- Start by creating a new
Go buildconfiguration. - Set the
Package pathtogithub.com/Zapharaos/fihub-backend/cmd/api.- If you want to run another service, simply change
apito the service you want to run.
- If you want to run another service, simply change
- Enable
Run after build. - Set the
Working directoryto the root of the projectfihub-backend. - Add
Environment variablesto override any config variables that you need.
Note regarding environment variables:
- Any service might require different environment variable, so please check the
config/fihub-<service>.tomlfile to see which one you need to set. - Please note that each variable you wish to override must have the
FIHUB_prefix. - Don't forget to override the
FIHUB_APP_ENVvariable todevelopment.
You can run the api with the following command:
FIHUB_APP_ENV=development go run ./cmd/api- If you want to run another service, simply change
apito the service you want to run. - Any service might require different environment variable, so please check the
config/fihub-<service>.tomlfile to see which one you need to set. - Please note that each variable you wish to override must have the
FIHUB_prefix. - Don't forget to override the
FIHUB_APP_ENVvariable todevelopment.
When editing the proto files, you need to regenerate the Go files. To do this, run the following command:
make proto-genWhen editing the code (proto, repository, ...), you may need to regenerate the mocks. To do this, run the following command:
make mocksGenerate the swagger file (reused by frontend).
make swaggerTo create a new migration file
goose create file_name sqlTo apply the migrations
goose -dir migrations postgres "host=localhost port=5432 user=postgres password=postgres dbname=fihub sslmode=disable" upWork in progress.
- Create a
.envfile to override any variables fromconfig/fihub-backend.tomlthat you need. - Please note that each variable you wish to override must have the
FIHUB_prefix. - Don't forget to comment any override of the
FIHUB_APP_ENVvariable.
make prod-bd # detached & build on top