A web application that helps you track, analyze, and improve your sleep patterns.
The "Sleep Debt Calculator" is a web-based tool designed to help users monitor and assess their sleep patterns throughout the week. This interactive application allows individuals to input the number of hours they have slept each day of the week, and it calculates whether they are accumulating a sleep deficit or oversleeping.
- Track sleep hours for each day of the week
- Calculate sleep debt based on ideal sleep hours
- Visualize sleep patterns with an interactive chart
- Rate your sleep quality with a 5-star system
- Get personalized sleep recommendations
- View and track your sleep history
- User authentication with Supabase
- Dark/light theme toggle
- Local and cloud data storage
- Intuitive Interface: The application features a calming background color and a clean layout to enhance the user experience.
- Input Fields: Enter the number of hours you slept for each day of the week (Monday through Sunday), with inputs limited to values between 0 and 24 hours.
- Result Display: After calculation, a results section displays the outcome with a customized message based on your sleep habits for the week, informing you if you have no sleep debt, need more sleep, or have slept more than required.
- Visual Appeal: The application is aesthetically pleasing, with a responsive design that adapts to different screen sizes and devices.
If you want to use environment variables for Supabase credentials:
npm installThis will install the dotenv package for environment variables.
For better security, you can use environment variables to store your Supabase credentials:
- Create a
.envfile in the root directory - Add the following variables:
SUPABASE_URL=your_supabase_project_url SUPABASE_ANON_KEY=your_supabase_anon_key
- Go to Supabase.com and sign up for a free account
- Create a new project
- In your project, go to "SQL Editor" and run the SQL commands from
supabase-setup.sql - Go to "Authentication" > "Providers" and make sure "Email" is enabled
- Go to "Authentication" > "URL Configuration" and add the following authorized redirect URLs:
http://localhost:3000/auth.html(for local development)- Your production URL if you have one
- Get your API keys from "Project Settings" > "API" and add them to your
.envfile
npm startstart-server.batConfigure your web server to serve the project files, making sure to handle redirects properly for the authentication flow.
If you're having trouble with email confirmation links:
- Make sure the redirect URLs in Supabase match exactly how you're accessing the application
- Check that you're using the same protocol (http/https) and domain
- If a confirmation link has expired, use the "Resend confirmation email" link on the login page
- Check your spam folder for confirmation emails
If you see a 400 error when trying to authenticate:
- Check that your Supabase API keys are correct in your
.envfile orsupabase-config.js - Ensure the email confirmation process is completed before trying to log in
- Try clearing your browser cache and cookies
All sleep data is stored:
- Locally in your browser's localStorage (for guest mode)
- In your Supabase database (for authenticated users)
No data is shared with third parties.
The project is hosted on GitHub: https://github.com/nuel232/sleepDeptCalculator
MIT License