How do i make referral system for game?

hello guys
i work on a game and i want to make an referral system , i have users using Firebase so i want to each user can invite someone else ans people they invite , save their usernames in Firebase

would you please put me in right direction?

is there anyone to help me please?