A modern, secure menstrual cycle tracking application built with Next.js 14, featuring Google authentication, personalized cycle predictions, and health recommendations.
Luna helps users:
- Track their menstrual cycle securely and privately
- Get personalized health recommendations based on cycle phase
- Monitor cycle regularity and patterns
- Receive nutrition and exercise guidance aligned with their cycle
- Manage health information with a user-friendly interface
-
Secure Authentication
- Google Sign-In integration
- Protected user data
- Personalized dashboard access
-
Cycle Tracking
- Cycle phase prediction
- Period tracking
- Cycle length monitoring
- Irregularity tracking
-
Health Recommendations
- Phase-specific nutrition advice
- Customized exercise suggestions
- Personalized wellness tips
- Allergy awareness integration
-
User Experience
- Clean, intuitive interface
- Mobile-responsive design
- Personalized dashboard
- Easy data input
src/
├── app/ # Main application pages and API routes
│ ├── api/ # Backend API endpoints
│ │ ├── auth/ # Authentication endpoints
│ │ └── user/ # User management endpoints
│ ├── dashboard/ # Protected dashboard page
│ └── page.tsx # Homepage
├── components/ # Reusable React components
│ ├── auth-buttons.tsx # Login/Logout buttons
│ ├── cycle-status.tsx # Cycle tracking display
│ └── user-details-form.tsx # Profile setup
├── lib/ # Utility functions and configurations
│ ├── auth.ts # Authentication setup
│ └── mongodb.ts # Database connection
│ └── cycle-helpers.ts # Cycle calculations
└── models/ # Database models
└── user.ts # User data structure
- Next.js 14
- React 18
- Tailwind CSS
- shadcn/ui components
- TypeScript
- MongoDB (user data storage)
- NextAuth.js (authentication)
- Google OAuth2
CycleStatusCard: Displays current cycle phase and recommendationsUserDetailsForm: Collects user cycle informationDashboardContent: Main user interface
-
User Authentication Flow:
- User clicks "Sign in with Google"
- Google authentication window appears
- After successful login, user info is saved to MongoDB
- User is redirected to dashboard
-
Data Storage:
- User email, name, and profile picture are stored
- Information is updated each time user logs in
- Unique Google ID is used to identify users
-
Protected Routes:
- Dashboard page checks if user is logged in
- Unauthorized users are redirected to homepage
- Logged-in users can view their profile
-
Install dependencies:
npm install
-
Create a
.env.localfile with:AUTH_SECRET="your-auth-secret" GOOGLE_ID="your-google-client-id" GOOGLE_SECRET="your-google-client-secret" MONGODB_URI="your-mongodb-connection-string" -
Get Google OAuth credentials:
- Go to Google Cloud Console
- Create a new project
- Enable Google+ API
- Create OAuth credentials
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google
-
Set up MongoDB:
- Create a MongoDB Atlas account
- Create a new cluster
- Get your connection string
- Update MONGODB_URI in
.env.local
-
Run the development server:
npm run dev
auth-buttons.tsx: Login/Logout button componentsdashboard/page.tsx: Protected user dashboard
api/auth/[...nextauth]/route.ts: Authentication endpointsapi/user/route.ts: User data managementmodels/user.ts: MongoDB user schema
lib/auth.ts: Authentication setuplib/mongodb.ts: Database connectionmiddleware.ts: Route protection
Each folder in the project has a specific purpose:
app/: Contains all pages and API routescomponents/: Reusable UI componentslib/: Helper functions and configurationsmodels/: Database schemas