A modern React application to manage team's weekly treating schedule, focusing on Thursdays.
- Personnel Management: Add, remove, and manage team members
- Automatic Scheduling: Generate balanced treating schedules
- Smart Allocation: Prioritize members with fewer treating counts
- Thursday Highlights: Special focus on Thursdays as treating days
- Email Notifications: Send reminders to team members via Resend API
- Fair Distribution System: Uses hostOffset mechanism to ensure fairness when new members join
- Team Information Management: Create and manage team information
- User Authentication: Secure login and registration with Supabase Auth
- Debug Mode: Special debug controls for testing
- React + TypeScript
- Vite as build tool
- Supabase for backend database and authentication
- Tailwind CSS for styling
- @internationalized/date for date handling
- Resend API for email notifications
The application uses Supabase Authentication for user management:
- Email/password authentication
- Password reset functionality
- Protected routes requiring authentication
- User profile management
The application uses the following tables in Supabase:
-
personnel
table:id
: UUID (primary key)name
: Stringemail
: Stringphone
: String (optional)hostingCount
: Integer (number of times treated)lastHosted
: Timestamp with timezone (when the person last treated)hostOffset
: Integer (offset value for fair scheduling when joining mid-cycle)userId
: UUID (foreign key to teams table)
-
host_schedule
table:id
: UUID (primary key)personnelId
: UUID (foreign key to personnel)date
: Date stringteamNotified
: BooleanhostNotified
: Booleancompleted
: BooleanuserId
: UUID (foreign key to teams table)
-
teams
table:userId
: UUID (primary key)teamName
: StringcreatedAt
: Timestamp with timezone
-
email_templates
table:id
: UUID (primary key)template_type
: Stringtemplate_name
: Stringsubject
: Stringhtml_content
: Stringtext_content
: Stringcreated_at
: Timestamp with timezoneupdated_at
: Timestamp with timezoneuserId
: UUID (foreign key to teams table)
The system implements a fair treating distribution algorithm using a hostOffset
mechanism:
- Each person has two values:
hostingCount
(actual number of times they've treated) andhostOffset
(an offset value) - When determining treating order, the system uses a "calculated value" =
hostingCount + hostOffset
- New members receive a
hostOffset
equal to the minimum "calculated value" of all existing members - This ensures that new members don't get unfair advantage by joining mid-cycle
- It also ensures they aren't immediately burdened with treating duties upon joining
Example scenario:
- Team has members A, B, and C with hosting counts of 3, 2, and 1 respectively (all joined at the beginning with
hostOffset = 0
) - When new member D joins, the minimum "calculated value" is 1 (from member C)
- Member D gets assigned
hostOffset = 1
andhostingCount = 0
- In the ordering calculation, members are ranked:
- A: 3 + 0 = 3
- B: 2 + 0 = 2
- C: 1 + 0 = 1
- D: 0 + 1 = 1
- Members C and D have equal priority (both have calculated value 1), followed by B, then A
- This creates a balanced and fair rotation system for everyone
- Node.js 14+ and npm
- Supabase account and project with tables set up as described above
- Resend API account (for email notifications)
- Clone this repository
git clone [repository-url]
cd thursday-treating-calendar
- Install dependencies
npm install
- Set up environment variables
cp .env.example .env
Then edit the .env
file to add your credentials:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
RESEND_API_KEY=your_resend_api_key
-
Set up the database tables
-
Start the development server
npm run dev
- Create Team: Start by creating a team with name and email
- Add Team Members: Add personnel with their name, email, and optional phone number
- Generate Schedule: Choose between name-based or random scheduling
- View Calendar: Browse the calendar to see treating assignments
- Send Notifications: Notify team members about upcoming treating duties
- Test Emails: Test email notifications through the Email Test panel
- Automatic Weekly Notifications: The system sends automatic notifications every Monday at 8:00 AM to remind team members about the upcoming Thursday treating session
The application uses two scheduling methods with the fairness mechanism:
- Name-based: Sorts team members alphabetically by name, but uses the calculated value (hostingCount + hostOffset) to ensure fair rotation
- Random: Randomly sorts members but prioritizes those with the lowest calculated value
Both methods ensure fair rotation by keeping track of each person's treating count and applying appropriate offsets for new members.
You can easily deploy this application to Vercel by following these steps:
- A Vercel account
- Git repository with your project code
-
Push your code to a Git repository (GitHub, GitLab, or Bitbucket)
-
Log in to your Vercel account and click "New Project"
-
Import your Git repository
-
Configure the project:
- Framework Preset: Vite
- Build Command:
npm run build
- Output Directory:
dist
- Install Command:
npm install
-
Add Environment Variables:
- VITE_SUPABASE_URL: your_supabase_url
- VITE_SUPABASE_ANON_KEY: your_supabase_anon_key
- RESEND_API_KEY: your_resend_api_key
- VITE_APP_URL: your_production_url (e.g., https://your-app-domain.com)
-
Click "Deploy"
-
After the deployment is complete, you can access your application at the provided Vercel URL