Skip to content

Rafiqdevhub/Next.js_15_Sleep_Track_Application

Repository files navigation

SleepWise - Sleep Tracker Application

SleepWise

A modern web application built with Next.js that helps users track and analyze their sleep patterns. Users can log their sleep duration, quality, and view insights about their sleep habits over time.

Features

  • 📊 Visual sleep pattern analysis with interactive charts
  • 🔐 Secure authentication with Clerk
  • 💤 Track sleep duration and quality
  • 📈 View average sleep statistics
  • 🏆 Track best and worst sleep records
  • 📱 Responsive design for all devices
  • 📅 Historical sleep record management

Tech Stack

Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Clerk account for authentication

Environment Variables

Create a .env file in the root directory with the following variables:

DATABASE_URL="your-postgresql-connection-string"
NEXT_PUBLIC_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="/"

Installation

  1. Clone the repository:
git clone ....
  1. Install dependencies:
npm install
  1. Set up the database:
npx prisma generate
npx prisma migrate dev
  1. Start the development server:
npm run dev

The application will be available at http://localhost:3000

Project Structure

  • /app - Next.js App Router pages and layouts
  • /components - Reusable React components
  • /actions - Server actions for data operations
  • /lib - Utility functions and database configuration
  • /types - TypeScript type definitions
  • /prisma - Database schema and migrations

Database Schema

User Model

  • id: String (UUID)
  • clerkUserId: String (Unique)
  • email: String (Unique)
  • name: String (Optional)
  • imageUrl: String (Optional)
  • createdAt: DateTime
  • updatedAt: DateTime

Record Model

  • id: String (UUID)
  • text: String (Sleep quality description)
  • amount: Float (Hours of sleep)
  • date: DateTime
  • userId: String (Foreign key to User)
  • createdAt: DateTime

Features in Detail

Sleep Records

  • Add new sleep records with duration and quality description
  • View history of sleep records
  • Delete individual records
  • Visual representation of sleep patterns

Analytics

  • Calculate average sleep duration
  • Track best and worst sleep records
  • View sleep trends over time
  • Personal insights dashboard

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

A next.js 15 Sleep Tracking Application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages