I have implemented subscription renewals in my app and now want to integrate a referral system. Each user should receive a unique referral code that they can share with others. When a new user signs up using a referral code, both the referrer and the referred user should receive a bonus.
What is the best approach to implementing this feature efficiently?