Skip to content

Repository files navigation

💤 Sleep Tracker App

A full-stack Sleep Tracking application built with modern technologies to help users track and visualize their sleep patterns effectively.

📌 Overview

Sleep Tracker is a Next.js 15-based application where users can:

  • 📝 Add daily sleep records
  • 🔥 View best and worst sleep durations
  • 📊 Visualize their sleep data through interactive charts
  • 🗑️ Delete or manage existing records
  • 🔐 Access their data securely using Clerk authentication

This app empowers users to understand their sleeping habits and mood impact with a sleek UI and data-driven insights.


🚀 Features

  • ✅ User Authentication with Clerk
  • ✅ Add / View / Delete Sleep Records
  • ✅ Get Best and Worst Sleep Days
  • ✅ Mood Tracking After Sleep
  • ✅ Charts and Visualizations with react-chartjs-2
  • ✅ Data persistence using Neon DB (PostgreSQL)
  • ✅ ORM with Prisma
  • ✅ API Routes with Next.js App Router
  • ✅ Fully typed with TypeScript

🛠️ Tech Stack

Technology Purpose
Next.js 15 Frontend & Backend framework
TypeScript Type safety
Neon DB Serverless PostgreSQL database
Prisma ORM to interact with the database
Clerk User authentication
Chart.js Data visualization
Tailwind CSS Styling the UI

📷 Screenshots

Screenshot 2025-06-05 162449 Screenshot 2025-06-05 214146


ChatGPT Image Aug 13, 2025, 03_22_11 PM

⚙️ Setup Instructions

  1. Clone the repository
git clone https://github.com/your-username/sleep-tracker.git
cd sleep-tracker
  1. Install dependencies
npm install
  1. Set up environment variables

Create a .env file with the following:

DATABASE_URL=your_neon_db_url
CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/
  1. Push Prisma schema and seed DB
npx prisma db push
  1. Run the app
npm run dev

🐛 Known Issues / Debug Notes

  • ❗ While setting up Clerk, importing from @clerk/nextjs in client components can throw:

    'server-only' cannot be imported from a Client Component module.
    

    🔧 Fix: Ensure that only server code uses server-only modules and isolate logic accordingly.

  • ❗ When integrating Framer Motion or other libraries with export * in Next.js 15 app router, you might hit:

    It's currently unsupported to use "export *" in a client boundary.
    

    🔧 Fix: Use named exports instead of wildcard exports in components.


📈 Sleep Charting

Using react-chartjs-2, the app renders:

  • 📅 Daily sleep hours bar chart
  • 😊 Mood vs Sleep correlation chart

Users can track patterns and understand how well-rested they feel over time.


🧑‍💻 Author

Made with ❤️ by Rohit Gawande


📃 License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages