NeWomen is an AI-powered personal growth platform featuring an emotionally intelligent AI companion called "NewMe". The platform provides culturally sensitive, speech-to-speech conversations with persistent memory and comprehensive wellness features.
- AI Companion: Emotionally intelligent AI with persistent memory and context awareness
- Speech-to-Speech: Real-time audio conversations using WebRTC and voice recognition
- Balance Wheel Assessment: Life balance evaluation across 8 key areas
- Gamification System: Points, levels, achievements, and daily challenges
- Wellness Resources: Curated content from licensed professionals
- Community Features: Partner connections, group challenges, anonymous sharing
- Cultural Sensitivity: Adapts to user's cultural context and preferences
- Narrative Exploration: AI-powered analysis and transformation roadmaps
- Framework: Next.js 14+ with React 18+ and TypeScript
- Styling: Tailwind CSS with custom glassmorphic components
- Animations: Framer Motion for smooth interactions
- PWA: Service workers with next-pwa for offline functionality
- State Management: React Context API for auth and global state
- Runtime: Node.js with TypeScript
- API: Next.js API routes with custom middleware
- Database: PostgreSQL with direct pg client (no ORM)
- Caching: Redis for session and data caching
- Vector DB: Pinecone for AI embeddings and memory storage
- LLM: OpenAI GPT-4 with Anthropic Claude fallback
- Speech: WebRTC for real-time audio, OpenAI Whisper (STT), ElevenLabs (TTS)
- Processing: Custom prompt engineering with context management
- Node.js 18+ and npm
- Docker and Docker Compose (for local development)
- PostgreSQL 14+
- Redis 6+
-
Clone the repository:
git clone https://github.com/yourusername/NeWomen-platform.git cd NeWomen-platform
-
Run the setup script to install dependencies and set up the development environment:
./setup.sh
-
Create a
.env
file based on the.env.example
template and fill in your API keys and configuration. -
Start the development server:
./dev.sh # or npm run dev
-
Open http://localhost:3000 in your browser to see the application.
# Type checking
npm run type-check
# Linting
npm run lint
# Run tests
./test.sh
# or specific test types
npm run test # Unit tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
npm run test:integration # Integration tests
npm run test:e2e # E2E tests
NeWomen-platform/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── api/ # API routes organized by feature
│ │ ├── (pages)/ # Page components
│ │ ├── layout.tsx # Root layout
│ │ └── globals.css # Global styles
│ ├── components/ # React components
│ │ ├── ui/ # Reusable UI components (Glass*)
│ │ ├── audio/ # Audio-related components
│ │ ├── chat/ # Chat interface components
│ │ ├── gamification/ # Gamification components
│ │ ├── navigation/ # Navigation components
│ │ └── [feature]/ # Feature-specific components
│ ├── lib/ # Business logic and services
│ │ ├── [service]/ # Service implementations
│ │ ├── types/ # TypeScript type definitions
│ │ ├── hooks/ # Custom React hooks
│ │ └── utils.ts # Utility functions
│ ├── styles/ # CSS files
│ └── middleware.ts # Next.js middleware
├── public/ # Static assets
├── database/ # Database migrations and schema
├── docs/ # Documentation
├── tests/ # Test files organized by type
├── e2e/ # End-to-end tests
└── scripts/ # Utility scripts
The NeWomen platform uses a Build-Runtime Separation Pattern to ensure successful deployments across different environments. Database operations are deferred to runtime initialization to avoid build-time connectivity issues.
# Core Application
NODE_ENV=production
NEXTAUTH_SECRET=your-nextauth-secret-here
JWT_SECRET=your-jwt-secret-here
# Database & Caching
DATABASE_URL=postgresql://user:password@host:port/database
REDIS_URL=redis://user:password@host:port
# AI Services
OPENAI_API_KEY=sk-your-openai-key
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
ELEVENLABS_API_KEY=your-elevenlabs-key
PINECONE_API_KEY=your-pinecone-key
# Payment Processing
PAYPAL_CLIENT_ID=your-paypal-client-id
PAYPAL_CLIENT_SECRET=your-paypal-client-secret
# Public URLs (for Vercel/production)
NEXT_PUBLIC_APP_URL=https://your-domain.com
# Additional AI Providers
GOOGLE_AI_API_KEY=your-google-ai-key
# Monitoring & Analytics
SENTRY_DSN=your-sentry-dsn
ANALYTICS_ID=your-analytics-id
# Development Only
SKIP_ENV_VALIDATION=true # Only for development
-
Setup Environment:
cp .env.example .env # Edit .env with your configuration
-
Install Dependencies:
npm ci --legacy-peer-deps
-
Start Services:
docker-compose up -d # Start PostgreSQL and Redis
-
Initialize Database:
npm run db:init:local
-
Start Development Server:
npm run dev
The production build is optimized to avoid database connectivity during build time:
# Validate build environment (no database required)
npm run env:validate:build
# Build application (static assets only)
npm run build:production
Database operations occur during application startup:
# Validate runtime environment (database required)
npm run env:validate:runtime
# Start production server (includes runtime DB initialization)
npm run start:production
The platform is configured for Vercel deployment with the following key settings:
- Build Command:
npm run build:vercel
(database-free build) - Install Command:
npm ci --legacy-peer-deps
- Start Command: Automatic (Next.js runtime)
- Runtime Initialization: Automatic on first request
- Go to your Vercel project settings
- Navigate to "Environment Variables"
- Add all required environment variables listed above
- Ensure
DATABASE_URL
points to your production database - Set
NODE_ENV=production
- Connect Repository: Link your GitHub repository to Vercel
- Configure Build Settings:
- Framework Preset: Next.js
- Build Command:
npm run build:vercel
- Install Command:
npm ci --legacy-peer-deps
- Set Environment Variables: Add all required variables
- Deploy: Push to main branch or trigger manual deployment
# Check application health
curl https://your-domain.com/api/health
# Verify database initialization
curl https://your-domain.com/api/health/detailed
# Build production image
docker build -f Dockerfile.production -t newomen-platform:latest .
# Run with environment file
docker run --env-file .env.production -p 3000:3000 newomen-platform:latest
# Start all services
docker-compose -f docker-compose.production.yml up -d
# Check service health
docker-compose -f docker-compose.production.yml ps
# Apply production configurations
kubectl apply -f k8s/production/
# Check deployment status
kubectl get pods -l app=newomen-platform
# View logs
kubectl logs -l app=newomen-platform --tail=100
The platform provides comprehensive health check endpoints:
-
Basic Health:
GET /api/health
- Returns 200 if application is running
- No database dependency
-
Detailed Health:
GET /api/health/detailed
- Returns comprehensive system status
- Includes database, Redis, and AI service connectivity
- Shows initialization status
{
"status": "healthy",
"timestamp": "2024-01-01T00:00:00.000Z",
"services": {
"database": "connected",
"redis": "connected",
"initialization": "completed"
},
"version": "0.1.0"
}
Issue: Build fails with database connection errors
Error: connect ECONNREFUSED 127.0.0.1:5432
Solution: Ensure you're using the correct build command that skips database operations:
# Use this for Vercel/production builds
npm run build:vercel
# NOT this (includes database operations)
npm run build:local
Issue: Missing environment variables during build
Error: Environment validation failed: Missing required variables
Solution: Check that build-time environment variables are set:
# Required for build
NODE_ENV=production
NEXT_PUBLIC_APP_URL=https://your-domain.com
# Optional for build (will use defaults)
DATABASE_URL=postgresql://...
Issue: Application fails to start with database errors
Error: Database initialization failed
Solution:
-
Verify database connectivity:
# Test database connection psql $DATABASE_URL -c "SELECT 1;"
-
Check database permissions:
# Ensure user has necessary permissions GRANT ALL PRIVILEGES ON DATABASE your_db TO your_user;
-
Verify environment variables:
npm run env:validate:runtime
Issue: Migration failures during startup
Error: Migration failed: relation "users" already exists
Solution:
-
Check migration status:
npx prisma migrate status
-
Reset migrations if needed:
npx prisma migrate reset --force npm run db:seed
Issue: Vercel build times out
Error: Build exceeded maximum duration
Solution:
-
Optimize build command in
vercel.json
:{ "buildCommand": "npm run build:vercel", "installCommand": "npm ci --legacy-peer-deps --prefer-offline" }
-
Check for large dependencies or unnecessary build steps
Issue: Vercel function timeout during initialization
Error: Function execution timed out
Solution:
-
Increase function timeout in
vercel.json
:{ "functions": { "src/app/api/**/*.ts": { "maxDuration": 60 } } }
-
Optimize database initialization for faster startup
Issue: Environment variables not loading
Error: Cannot read properties of undefined
Solution:
- Check variable naming (must start with
NEXT_PUBLIC_
for client-side) - Verify
.env
file location (root directory) - Restart development server after changes
- For Vercel, ensure variables are set in dashboard
Issue: Database URL format errors
Error: Invalid DATABASE_URL format
Solution: Use correct PostgreSQL URL format:
# Correct format
DATABASE_URL="postgresql://username:password@hostname:port/database?schema=public"
# With SSL (required for most cloud providers)
DATABASE_URL="postgresql://username:password@hostname:port/database?schema=public&sslmode=require"
Issue: Slow application startup
Warning: Initialization taking longer than expected
Solution:
- Check database connection latency
- Optimize database queries in initialization
- Consider connection pooling configuration
- Monitor resource usage
Issue: High memory usage during build
Error: JavaScript heap out of memory
Solution:
-
Increase Node.js memory limit:
NODE_OPTIONS="--max-old-space-size=4096" npm run build
-
Optimize bundle size and dependencies
-
Check Logs: Always start by checking application logs
# Local development npm run dev # Production logs docker logs container-name kubectl logs pod-name
-
Health Checks: Use health endpoints to diagnose issues
curl https://your-domain.com/api/health/detailed
-
Environment Validation: Verify your configuration
npm run env:validate:runtime
-
Database Status: Check database connectivity
npm run db:status # If available psql $DATABASE_URL -c "SELECT version();"
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for GPT-4 API
- Anthropic for Claude API
- ElevenLabs for TTS API
- The Next.js team for the amazing framework