Liquidity Planning
We are planning to add Mailpit for local e-mail testing and replace fixer.io with a local mock
- Copy the .env.example into the same directory and name it
.env
- Set your credentials for MariaDB
- Copy the backend/.env.example into the same directory and name it
.env
- The
WEB_HOST
is set to http://localhost:3000 and works for local dev - THE
JWT_KEY
can be anything for local development but make sure to set it for production - Set your credentials for MariaDB and make sure they match .env.example
- Set your Token for SendGrid
- This requires you to have an account with SendGrid
- Create an API key here
- You also need to have a Dynamic Template and get the ID
- The template for LiquiSwiss looks like this:
- The values to submit can be found in this model
- You can find the usage in the SendgridService
- This requires you to have an account with SendGrid
- Set your credentials for Fixer
- This requires you to have an account with Fixer
- Copy the API key that you find in the Dashboard
- The
- Copy the fronted/.env.example into the same directory and name it
.env
- The
NUXT_API_HOST
works fine for local dev but must be changed for production
- The
We are using phpMyAdmin with Docker to provide an interface to the database.
- Check out the .env.example to see the values you can set (all starting with
PMA_
). You can find more information here - You can check out your database (locally) at: http://localhost:8082/
Look at the Nuxt 3 documentation to learn more.
Make sure you are in the frontend directory for all the following actions
npm install
npm run dev or npm run dev-host (to expose host and be able to connect from another device)
Make sure you are in the backend directory for all the following actions
go get OR go mod tidy
- Install Air:
go install github.com/air-verse/air@latest
air
- Install Goose:
go install github.com/pressly/goose/v3/cmd/goose@latest
We differentiate between static and dynamic migrations whereas static migrations are all migrations that actually hold data later and a migration down would lead to data loss such as table creation or alterations.
Dynamic migrations are stored functions, views or triggers, basically things that can be removed entirely and reapplied.
The placeholder must either be replaced by "static" or "dynamic" (without quotes)
- Create Migration:
goose --dir internal/db/migrations/<directory> create <name-of-migration> sql
- Follow up with:
goose --dir internal/db/migrations/<directory> fix
to apply sequential numbering
- Follow up with:
We run auto migrations on each app start. Since "air" will restart the app on any changes also in the .sql files the migrations will apply automatically but it might be helpful sometimes to rollback and reapply.
- Apply Migration:
goose --dir internal/db/migrations/<directory> mysql liquiswiss:password@/liquiswiss up
- Rollback Migration:
goose --dir internal/db/migrations/<directory> mysql liquiswiss:password@/liquiswiss down
- Or check out the Makefile
Optional step
You can fixtures from the fixtures directory if you desire. The dynamic migrations insert a minimal set of data required to make the app work properly. You can check out the minimal inserted data in 10000_apply_minimal_fixtures.sql
Make sure you are in the backend directory
Make sure you spin up the test database with
docker compose up
- Install Mockgen with
go install go.uber.org/mock/mockgen@latest
to generate mocks- There are
go generate
commands already in the files so you can simply dogo generate ./...
- There are
- You can run all tests with
go test ./...
locally - Locally the .env.local.testing is used
- For the Github Action the .env.github.testing is used
- Check out the ci.yml and check for the service used in the test-backend job
- The environment variable
TESTING_ENVIRONMENT
determines which .env file to use
For production make sure you define the proper values for your envs (no matter in which way you provide them)
WEB_HOST
- Reflects your Frontend URL (eg. https://yourdomain.com)JWT_KEY
- Should be a long and secure passwordNUXT_API_HOST
- Reflects your Backend URL (eg https://api.yourdomain.com)