Giv Effektivt is a regranting charity organisation enabling Danish users to donate to highly effective charities around the world and get a tax deduction (hopefully in a few months.) There is no easily adjustable and good-looking donation platforms available on the Danish market. This projects enables the charity organisation giveffektivt.dk to collect donations with a custom made payment system.
The front end and back end are developed with NextJS framework and deployed using Vercel. The database is hosted on AWS.
To install, follow https://docs.docker.com/engine/install/ubuntu/.
dbmate
is used to apply migrations from db/migrations
directory. You can use it to apply migrations to your local database for testing.
dbmate
uses DATABASE_URL
, most likely you can put exactly this in .envrc
:
export DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@$PGHOST:5432/$PGDATABASE?sslmode=disable&search_path=giveffektivt
or, if you are not using direnv
, you can specify the url like that:
dbmate -u "postgres://postgres:password@localhost:5432/giveffektivt?sslmode=disable&search_path=giveffektivt" migrate
The -u
just after dbmate
is used to set a flag for the dbmate
not migrate
To install, follow https://github.com/amacneil/dbmate
docker-compose up
to get the local database.dbmate migrate
to apply the migrations. Rundbmate -u "postgres://postgres:password@localhost:5432/giveffektivt?sslmode=disable&search_path=giveffektivt" migrate
if you are not using- Optionally, to fill local DB with a copy of data from DEV:
pg_dump postgres://<dev-connection-string> --data-only --exclude-table schema_migrations --exclude-schema cron | psql
psql
required. Check section database tools docker-compose down
to shut it down preserving the local data (add-v
to also clear the data).
- Clone the app.
- Run
yarn install
to install dependencies. - Spin up the database with
docker-compose up
and (if you haven't done that) apply migrations withdbmate migrate
(check spinning up the database) - Create a file
.env
and copy contents of.env.example
to it. - Swap value of email username and email password with real values.
- Set
PAYMENT_GATEWAY
to a preferred payment gateway (supported values are listed inpayment_gateway
enum in database). - Set values for corresponding payment gateways (leave
QUICKPAY_CALLBACK_URL
empty unless you want Quickpay to send you a callback). - and
yarn dev
to run the app.
All of those tools are optional!
We use direnv to save us some time from typing the connection strings, users and passwords every time we want to use dbmate
, pgcli
or psql
. Direnv will set your env variables based on .envrc
when you enter the donation platform directory and unset them when you leave it.
To install, follow instructions here https://direnv.net/. After that have a look at .envrc.example
and copy contents to .envrc
.
psql is used to dump data from dev instance on AWS to local database.
sudo apt-get update
sudo apt-get install postgresql-client
pgcli can be used to run queries from the terminal.
sudo apt-get update
sudo apt-get install pgcli
psql
and pgcli
use the PGHOST
, PGDATABASE
, PGPORT
, PGUSER
and PGPASSWORD
environment variables. Default values set in .envrc.example
will enable you to connect to local database spun up with docker compose, but you need direnv
to make it work! Otherwise check documentation..
Adminer is a gui tool that makes the database management easier. It will be automatically available on port 8080 when you run docker-compose up
Use giveffektivt-db:5432
as the ip address when logging in to access local database. giveffektivt-db:5432
is the ip address that points towards giveffektivt-db from inside of adminer container. The other credentials are in docker-compose.yml file. Leave the database field empty.
There are integration tests validating database logic, which can be executed using yarn test
. The tests require database to be present, as per documentation above. The tests will run in a separate database called test
, which is fully recreated on every run.
- How to test the payment gateway?
There is no way to test the payment gateway locally, but for a development environment:
- For Quickpay, use Quickpay test cards and these transactions would automatically be treated as test transactions.
- For Scanpay, you can ask them for a test account. Then use
4111 1111 1111 1111
as the card number.
Thanks to @maximbaz, @noverby, @lindeloev and @alimony for helping me to create this app :)