A sophisticated, science-based menstrual cycle tracking and guidance application built with Next.js 14, featuring password-protected profiles, adaptive recommendations, and elegant UI design.
- Framework: Next.js 14 (App Router) + TypeScript
- Styling: Tailwind CSS with custom premium design system
- Animations: Framer Motion
- Data Visualization: Recharts
- Storage: Local-first with localStorage (optional Supabase sync)
- Security: PBKDF2 password hashing + AES encryption
-
Cycle Engine (
src/lib/cycleEngine.ts)- Maps any cycle length (25-35 days) to relative ovulation days (O-14 to O+13)
- Calculates phases dynamically
- Validates cycle data
-
Prediction System (
src/data/predictions.ts)- Phase-specific guidance for mood, energy, training, work, relationships
- Personalizes based on profile attributes
- Adapts to daily log data
-
Profile Service (
src/lib/profileService.ts)- Manages profile CRUD operations
- Generates cycle calendars
- Handles daily logging
- Export/import functionality
-
Security Service (
src/lib/security.ts)- Password hashing with PBKDF2 (10,000 iterations)
- AES encryption for sensitive data
- Session management (30-minute expiry)
phased-app/
├── src/
│ ├── app/ # Next.js app router pages
│ │ ├── page.tsx # Landing page
│ │ ├── layout.tsx # Root layout
│ │ ├── globals.css # Global styles
│ │ ├── profile/
│ │ │ ├── page.tsx # Profile picker
│ │ │ └── create/ # Profile creation wizard
│ │ ├── calendar/ # Calendar views
│ │ ├── insights/ # Analytics dashboard
│ │ └── learn/ # Theory & sources
│ │
│ ├── components/
│ │ ├── ui/ # Reusable UI components
│ │ │ ├── Header.tsx
│ │ │ ├── PasswordModal.tsx
│ │ │ └── ...
│ │ ├── wizard/ # Questionnaire components
│ │ ├── calendar/ # Calendar components
│ │ └── dashboard/ # Analytics components
│ │
│ ├── lib/ # Core business logic
│ │ ├── cycleEngine.ts # Cycle calculations
│ │ ├── profileService.ts # Data management
│ │ └── security.ts # Encryption & auth
│ │
│ ├── data/ # Static data & configs
│ │ ├── predictions.ts # Phase-based guidance
│ │ └── questionnaire.ts # Questionnaire config
│ │
│ └── types/ # TypeScript definitions
│ └── index.ts
│
├── public/ # Static assets
├── tailwind.config.js
├── next.config.js
├── tsconfig.json
└── package.json
- Node.js 18+
- npm or yarn
- Clone and install dependencies:
cd phased-app
npm install- Run development server:
npm run dev- Open browser:
Navigate to
http://localhost:3000
# Build image
docker build -t phased-app .
# Run container
docker run -p 3000:3000 phased-appnpm run build
npm start- Create: Dynamic questionnaire with smart branching
- Security: Password-protected with PBKDF2 hashing
- Privacy: Data stored locally, encrypted sensitive fields
- Multiple Profiles: Support for tracking multiple cycles
- Relative Day Mapping: Adapts to any cycle length (25-35 days)
- Phase Detection: Automatic phase assignment based on O± days
- Personalized Predictions:
- Physical & social energy
- Emotional state
- Cognitive function
- Training recommendations (high/low energy options)
- Work capacity
- Relationship dynamics
- Mood (1-10 scale + tags)
- Energy levels
- Sleep (hours + quality)
- Stress levels
- Physical symptoms
- Training completed
- Free-form notes
The system adjusts recommendations based on:
- Profile symptoms (PMS intensity, heat sensitivity, etc.)
- Recent sleep quality
- Stress levels
- Training volume
- Actual vs. predicted patterns
- Energy patterns by phase
- Symptom peaks
- Best training windows
- Pattern recognition
- Export capabilities (PDF, CSV)
{
id: string;
name: string;
cycleLength: number; // 25-35 days
bleedingLength: number;
bleedingIntensity: 'light' | 'medium' | 'heavy';
pmsIntensity: 'none' | 'mild' | 'moderate' | 'strong';
// Lifestyle
averageSleep: number;
sleepQuality: string;
stressLevel: string;
trainingPreference: string;
trainingFrequency: number;
heatSensitive: boolean;
// Symptoms
symptoms: {
cramps: boolean;
bloating: boolean;
// ... etc
};
// Security
passwordHash: string;
encryptedData: string;
// Metadata
lastPeriodDate: Date;
createdAt: Date;
lastUpdated: Date;
}{
cycleDay: number; // CD1-CD35
relativeDay: number; // O-14 to O+13
date: Date;
phase: PhaseInfo;
predictions: DayPredictions;
actualLog?: DayLog;
}The application implements the dataset from dataset.md which maps cycle physiology to 7 distinct phases:
- O-14 to O-10: Menstrual / Early Follicular
- O-9 to O-6: Mid Follicular (ascending)
- O-5 to O-3: High Follicular
- O-2 to O+1: Ovulatory Window
- O+2 to O+7: Early Luteal
- O+8 to O+10: Mid Luteal
- O+11 to O+13: Late Luteal / Premenstrual
Each phase includes baseline predictions for:
- Energy (physical & social)
- Emotional state
- Cognition
- Self-perception
- Libido
- Training recommendations
- Work capacity
- Relationship needs
- Common risks
- Display: Cormorant Garamond (elegant, sophisticated)
- Headings: Playfair Display (refined, editorial)
- Body: Inter (clean, readable)
- Cream:
#FAF9F6(primary background) - Charcoal:
#2B2B2B(primary text) - Gold:
#B8985F(accents, hover states) - Soft Gray:
#E8E6E3(borders, secondary elements) - Deep Burgundy:
#6B3E4A(alerts, emphasis)
- Generous whitespace
- Minimal, intentional animations
- Premium, "Vogue-like" aesthetic
- Gender-neutral, professional tone
- Accessibility-first approach
- Local-first: All data stored in browser localStorage by default
- Encryption: Sensitive fields encrypted with AES using user password
- No server dependency: Works completely offline
- Passwords never stored in plaintext
- PBKDF2 with 10,000 iterations + unique salt per profile
- Session timeout: 30 minutes of inactivity
- Export all data as JSON
- Import/restore from backup
- Complete user control
- Install Supabase client (already in package.json)
- Create environment variables:
NEXT_PUBLIC_SUPABASE_URL=your_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_key- Create tables:
CREATE TABLE profiles (
id UUID PRIMARY KEY,
user_id UUID REFERENCES auth.users,
encrypted_data TEXT,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
CREATE TABLE logs (
id UUID PRIMARY KEY,
profile_id UUID REFERENCES profiles,
log_data JSONB,
date DATE,
created_at TIMESTAMP
);- Enable Row Level Security (RLS)
- Add Bluetooth API for temperature tracking devices
- Integrate with ovulation test readers
- Auto-adjust ovulation day based on actual detection
- Extract all strings to i18n files
- Add language selector
- Translate phase descriptions
- Add service worker
- Implement reminder system for:
- Daily logging
- Cycle phase transitions
- Symptom alerts
- ML-based pattern recognition
- Symptom clustering
- Cycle length prediction
- Anomaly detection
This application:
- ✅ Provides educational information
- ✅ Helps track and understand patterns
- ✅ Offers evidence-based guidance
This application does NOT:
- ❌ Diagnose medical conditions
- ❌ Replace medical advice
- ❌ Provide contraceptive reliability
- ❌ Treat or cure any condition
Users should consult healthcare providers for:
- Severe symptoms (PMDD, endometriosis, PCOS, etc.)
- Contraception needs
- Fertility planning
- Any medical concerns
Educational use only. See LICENSE file for details.
Built following the theoretical foundation provided in:
theoretical-foundation.mddataset.md
Based on peer-reviewed research on menstrual cycle physiology and hormonal fluctuations.