Referral system where user earn points for every 3 friends that:
- uses their referral code to register
- transfers over 200 points
- Docker and docker-compose
- Make (Optional)
- Migrate - used to manage the migrations and seeders. Optionally, you can
source
the sql files in the.sql
directory.
- Copy the example environment file (
.env.example
) to.env
i.e.,
$ cp .env.example .env
and fill the .env
file with your actual credentials.
- Start the application with:
$ docker-compose up --build
This will start the PostgreSQL server on http://localhost:5432
and the API server on http://localhost:8000
The migration files needed to setup the database are stored in the sql
folder. Run the make command below to apply them:
$ make migrate-up
The command above will:
- create a users table to store users
- create a transactions table to store transactions
- create a wallets table to store user wallet information
- create a payouts table to store referral payouts that are due.
- insert a seed transaction for the user with id 1 (since no user would have enough balance to make a transfer initially).
Signs up a new user
username=[String]
: Username of the user. Will return an error if the username already existspassword=[String]
: The user's passwordreferrer=[String]
: Optional. Referral code of the user that referred this user.
Initiates a P2P transfer
sender_id=[Number]
: user ID of the sender.recipient_id=[Number]
: user ID of the recipientamount=[Number]
: Amount to be transferred.description=[String]
: Optional. Description of the transaction