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.
- 📊 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
- Framework: Next.js 15 with App Router
- Authentication: Clerk
- Database: PostgreSQL with Prisma ORM
- Styling: Tailwind CSS
- Charts: Chart.js with react-chartjs-2
- Fonts: Geist Sans & Geist Mono
- Node.js 18+
- PostgreSQL database
- Clerk account for authentication
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="/"
- Clone the repository:
git clone ....
- Install dependencies:
npm install
- Set up the database:
npx prisma generate
npx prisma migrate dev
- Start the development server:
npm run dev
The application will be available at http://localhost:3000
/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
id
: String (UUID)clerkUserId
: String (Unique)email
: String (Unique)name
: String (Optional)imageUrl
: String (Optional)createdAt
: DateTimeupdatedAt
: DateTime
id
: String (UUID)text
: String (Sleep quality description)amount
: Float (Hours of sleep)date
: DateTimeuserId
: String (Foreign key to User)createdAt
: DateTime
- Add new sleep records with duration and quality description
- View history of sleep records
- Delete individual records
- Visual representation of sleep patterns
- Calculate average sleep duration
- Track best and worst sleep records
- View sleep trends over time
- Personal insights dashboard
Contributions are welcome! Please feel free to submit a Pull Request.