-
Folder Structure
- app
- api
- db
- docker
-
Add necessary environment variables
# api env path: ./.env
REFCODE_POSTGRES_DB_HOST=postgres
REFCODE_POSTGRES_DB_PORT=5432
REFCODE_POSTGRES_DB_USER=admin
REFCODE_POSTGRES_DB_PASSWORD=admin
REFCODE_POSTGRES_DB_NAME=refcode
POSTGRES_USER=admin
POSTGRES_PASSWORD=admin
PG_DATA=/var/lib/postgresql/data
HOST_IP=
JWT_SECRET=
# app env path: ./app/.env
REACT_APP_CONSUMER_KEY=
REACT_APP_CONSUMER_SECRET=
REACT_APP_BASE_API_URL=
REACT_APP_GOOGLE_CLIENT_ID=
REACT_APP_URL=-
Once env are added run following command
- ports are exposed as following
- app : 5174
- api : 3018
- postgres : 5432
- pgadmin: 5050
- ports are exposed as following
-
Run the schema from db/main.sql on pgadmin/cli postgres
-
NGINX config is set by forwarding the mentioned ports
docker compose up- Authorize the app for the first time using consumer key and secret
- Authenticate the next time
- Retrieve the oauth token with oauth verifier (oauth1.0)
- Verify Credentials to get user details such as email id
- With Client Id fetch users
- Select User to fetch oauth2 token
- Fetch user info using that token
- Provider Call from ether object available from global browser context
- Fetch Selected Account address
- Fetch any transactional data
- User can signup with/without referral code
- Wallet authorization allows to check generate and score page
- One to many relations from user to auth providers
- Registering through any above will generate refresh token with expiry of 7 days
- Login gives AccessToken with 1hr of expiration
- Guards are added on required authenticated routes such as /referral and /score page details
- Referral code can be generated any number of times but previously generated code are invalidated
- Referral code have expiry of 1hr