Not maintained.
Mynt is a web-application for personal finance. This repository contains the backend code that powers the frontend, mynt-frontend.
- Install go
- Install sql-migrate
- Install golangci-lint
- Install pre-commit
- Install vscode
- Install the go vscode extension
- Install docker
- Run
pre-commit install
in the root of the repository (see this guide for more details) - Create a
.env
file similar to.env.sample
.JWT_SIGNING_SECRET
can be whatever you want. For theGOOGLE_AUTH_CLIENT*
variables, you need to visist the Google API Console to obtain Oauth 2.0 credentials. Follow this guide with application typeWeb application
and addhttp://localhost:8080/auth/callback
to _Authorized redirect URIs. - Run
docker-compose up
in the root of the repository to run a local development database. - Run
go run main.go
to start the application.
- GIN_MODE: release
- ORIGIN: https://mynt.daae.dev
- PORT: 80
- CALLBACK_URL: https://api.mynt.daae.dev/auth/callback
- REDIRECT_TO_FRONTEND: https://mynt.daae.dev/authenticated/transactions
- REDIRECT_TO_FRONTEND_SIGNOUT: https://mynt.daae.dev
- COOKIE_DOMAIN: daae.dev
- JWT_SIGNING_SECRET
- GOOGLE_AUTH_CLIENT_ID
- GOOGLE_AUTH_CLIENT_SECRET
- POSTGRES_HOST
- POSTGRES_PORT
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
- POSTGRES_SSL
- We currently use google for authentication.
- To authenticate a client:
- Redirect the client to
/redirect
(in this application) - The client will be redirected to the google conscent page
- When the client has authenticated on the conscent page, google will redirect the client to
/callback
(in this application) - After this, the
/callback
endpoint will redirect the client to whatever is in theREDIRECT_TO_FRONTEND
environment variable. - The endpoint also sets a cookie with a jwt-token that can be used to make authenticated requests to this application. The only thing you have to do in javascript is to set the credentials flag in fetch to include.
- Redirect the client to
- This flow was configured following these guides:
- We use sql-migrate for managing database updates.
- To make a new database update, run
sql-migrate new replace-with-a-description-of-the-update
. - The application will make sure that all the migrations are up to date when starting (which means that you don't have to do these updates manually in other environments), but you can run them locally with
sql-migrate up
. - You can test that the
down
version of your migration works withsql-migrate redo
. - Always be carefull with database migrations, we generally don't want to do anything else than creating new tables and new fields. But if you have to, consider doing these things manually instead.