Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prototype of referral system in console #142

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

travis
Copy link
Member

@travis travis commented Oct 25, 2024

Summary

This PR spikes out a referral system that stores data in Cloudflare's D1. It allows anonymous or logged-in users to create referral codes associated with their email addresses, and records the referral code a user used to sign up for an account. It does not implement the discounts and other rewards associated with the referral system - these are expected to be handled manually in the first released version and implemented as automated systems later, so are a non-goal of this PR.

Referral System Design

We use Cloudflare's D1 database for simplicity, since we already deploy this application via Cloudflare Pages. Two tables are used: users and referrals. users is used to store refcodes for users (identified by email address). referrals is used to record the refcode used by a user (identified by email address) during signup. Separate tables are used to avoid mutating rows in the database - a simple, immutable system is generally easier to maintain and reason about and while immutability of database tables isn't a hard requirement, it is a property this design strives to maintain.

Operational Notes

In order to use D1 in development, the app must be run using @cloudflare/next-on-pages. The pages:dev script already used this. Unfortunately, this does not support hot-reloading, so we've added pages:build to that step to ensure the latest code is always used when pages:dev is run.

Developers who are NOT working on the referrals system should continue to use the dev script rather than the pages:dev script as it provides a better user experience.

We also introduce a set of scripts prefixed with referrals:db:local that make it relatively simple to maintain a local D1 database for development.

User Experience

We are working with a UX designer toward professional designs and user experience - the UI and UX as currently implemented are temporary and do not need feedback yet.

Screenshot 2024-10-26 at 12 05 38 AM Screenshot 2024-10-26 at 12 07 08 AM Screenshot 2024-10-26 at 12 08 53 AM

TODOs

  • document referrals system development process
  • document referrals system design
  • integrate designs from UX designer

use server actions for now
server actions are confusing and weren't working properly
@travis travis deployed to preview-142/merge October 25, 2024 10:25 — with GitHub Actions Active
@travis travis marked this pull request as draft October 25, 2024 10:26
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant