A comprehensive AI-powered wellness application that helps you track your mood, manage tasks, build habits, and achieve goals through intelligent journaling and analytics.
- π£οΈ Daily AI Conversations - Chat with your AI companion about your day
- π Mood Tracking - Automatic mood analysis with interactive charts
- β Task Management - Create, track, and manage tasks with priorities
- π― Goal Setting - Set long-term goals with milestones and progress tracking
- β‘ Habit Tracker - Build positive habits with streak counting
- π Analytics Dashboard - AI-powered insights and correlations
- πΎ Data Export - Export all your data in JSON or CSV format
- π Dark/Light Mode - Seamless theme switching
- π± Fully Responsive - Works perfectly on all devices
- Mood detection from journal entries
- Personalized insights and recommendations
- Pattern recognition across mood, tasks, and habits
- Smart task/goal/habit suggestions from conversations
- Correlation analysis (e.g., "Your mood is higher on days you exercise")
- Runtime: Node.js + Express.js
- Database: MongoDB with Mongoose (with in-memory fallback)
- AI: Google Gemini AI for intelligent conversations
- Authentication: JWT-based auth with bcrypt password hashing
- Security: Rate limiting, helmet, CORS, input validation
- Framework: React 18 with modern hooks
- Styling: TailwindCSS with custom design system
- Routing: React Router v6
- Charts: Recharts for mood visualizations
- HTTP Client: Axios with interceptors
- Notifications: React Hot Toast
- Icons: Lucide React
- Node.js 18+ and npm
- MongoDB URI (optional - uses in-memory storage if not provided)
- Google Gemini API key
git clone <repository-url>
cd PersonalFriendAIcd backend
npm installCreate .env file:
# Required
GEMINI_API_KEY=your_gemini_api_key_here
JWT_SECRET=your_secret_key_here
# Optional (uses in-memory storage if not provided)
MONGODB_URI=mongodb://localhost:27017/ai-friend
# Optional Configuration
PORT=5002
NODE_ENV=development
JWT_EXPIRES_IN=7d
BCRYPT_ROUNDS=12Start backend:
npm run devcd frontend
npm install
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:5002
PersonalFriendAI/
βββ backend/
β βββ middleware/
β β βββ auth.js # Authentication middleware
β βββ routes/
β β βββ auth.js # Auth routes (modular)
β βββ utils/
β β βββ helpers.js # Utility functions
β βββ models.js # MongoDB schemas
β βββ storage.js # Storage abstraction layer
β βββ server.js # Express app & routes
β βββ .env # Environment variables
β βββ package.json
β
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Navbar.jsx # Navigation with hamburger menu
β β β βββ LoadingSpinner.jsx
β β βββ contexts/
β β β βββ AuthContext.jsx # Authentication state
β β β βββ ThemeContext.jsx # Theme management
β β βββ pages/
β β β βββ Dashboard.jsx # Main dashboard
β β β βββ Chat.jsx # Conversational journal
β β β βββ Tasks.jsx # Task management
β β β βββ Goals.jsx # Goal tracking
β β β βββ Habits.jsx # Habit building
β β β βββ Mood.jsx # Mood analytics
β β β βββ Login.jsx # Authentication
β β β βββ Register.jsx
β β βββ utils/
β β β βββ api.js # API helper functions
β β βββ App.jsx # Main app component
β β βββ index.css # Global styles
β βββ package.json
β
βββ README.md # This file
POST /api/auth/register # Create account
POST /api/auth/login # Sign in
GET /api/auth/me # Get current user
POST /api/ai/analyze # Analyze text and detect mood
POST /api/ai/speak # Text-to-speech (browser-based)
GET /api/dashboard # Get dashboard data with AI insights
GET /api/journal # Get journal entries
POST /api/journal # Create journal entry
GET /api/tasks # Get all tasks
POST /api/tasks # Create task
PUT /api/tasks/:id # Update task
DELETE /api/tasks/:id # Delete task
GET /api/goals # Get all goals (filter by status)
POST /api/goals # Create goal
PUT /api/goals/:id # Update goal (progress, milestones)
DELETE /api/goals/:id # Delete goal
GET /api/habits # Get all habits (filter by active)
POST /api/habits # Create habit
PUT /api/habits/:id # Update habit
POST /api/habits/:id/complete # Mark habit as completed
DELETE /api/habits/:id # Delete habit
GET /api/mood/analytics # Get mood data (weekly/monthly)
GET /api/export?format=json # Export all data as JSON
GET /api/export?format=csv # Export journal as CSV
- Chat interface for daily reflections
- AI detects mood from your writing
- Suggests actionable tasks, goals, or habits
- One-click to add suggestions to your lists
- Persistent chat history (daily-based)
- Browser text-to-speech for AI responses
- AI-generated insights based on your data
- Correlations (e.g., "High mood correlates with task completion")
- Quick stats: streak, mood, goals, habits
- Today's habits with completion tracking
- Active goals with progress bars
- Upcoming tasks with due dates
- Recent journal entries
- Create tasks with title, description, due date, priority
- Smart task suggestions based on time of day
- One-click task completion
- Link tasks to goals (optional)
- Delete with completion confirmation
- Set goals with categories (Health, Career, Personal, etc.)
- Add milestones to break down goals
- Visual progress bars (0-100%)
- Track completion status
- Filter by active/completed/abandoned
- Create daily, weekly, or custom habits
- Automatic streak calculation
- Visual 7-day completion history
- Prevent duplicate completions
- Gamification with fire emoji for streaks
- Weekly and monthly mood charts
- Average mood calculation
- Trend analysis
- Correlation with habits and tasks
- Password Security: bcrypt hashing with 12 rounds
- Authentication: JWT tokens with configurable expiration
- Rate Limiting: Separate limits for auth, AI, and general routes
- Input Validation: Server-side validation for all inputs
- CORS: Configured for frontend origin
- Helmet: Security headers
- Data Isolation: User-specific data filtering
- Persistent data storage
- Scalable and reliable
- Automatic indexing for performance
- No MongoDB required
- Perfect for testing
- Data resets on server restart
- Automatically used if
MONGODB_URIis not provided
GEMINI_API_KEY=<your-gemini-api-key>
JWT_SECRET=<random-secret-string>MONGODB_URI=<mongodb-connection-string> # Uses in-memory if not set
PORT=5002 # Default: 5002
NODE_ENV=development # development | production
JWT_EXPIRES_IN=7d # Token expiration
BCRYPT_ROUNDS=12 # Password hashing rounds-
Gemini API Required: You need a Google Gemini API key for AI features
- Get it from: https://makersuite.google.com/app/apikey
-
MongoDB Optional: App works without MongoDB using in-memory storage
- Perfect for development and testing
- Use MongoDB for production to persist data
-
Browser Compatibility:
- Speech recognition works best in Chrome/Edge
- Text-to-speech uses browser's native synthesis
-
Data Persistence:
- In-memory mode: Data lost on restart
- MongoDB mode: Data persists permanently
-
Port Configuration:
- Backend: 5002 (configurable)
- Frontend: 3000 (Vite default)
- Hamburger Menu: Mobile navigation with slide-down menu
- Touch-Friendly: Optimized tap targets (44x44px minimum)
- Responsive Text: Scales from mobile to desktop
- Adaptive Layouts: 1-4 column grids based on screen size
- No Horizontal Scroll: Content fits all screen widths
# Check if port 5002 is in use
lsof -i :5002
# Kill process if needed
kill -9 <PID>
# Check environment variables
cat backend/.env# Verify backend is running
curl http://localhost:5002/api/auth/me
# Check CORS settings in server.js
# Ensure frontend URL is allowed# Test MongoDB connection
mongosh <your-mongodb-uri>
# Or use in-memory mode
# Remove MONGODB_URI from .env# Verify Gemini API key
echo $GEMINI_API_KEY
# Test API key
curl -H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"Hello"}]}]}' \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOUR_API_KEY"- Create database model in
models.js - Add storage methods in
storage.js - Create API routes in
server.js(or new route file) - Add API helper in
frontend/src/utils/api.js - Create frontend page/component
- Add route in
App.jsx - Update navigation in
Navbar.jsx
- Use ES6+ features
- Async/await for promises
- Functional components with hooks
- TailwindCSS for styling
- Meaningful variable names
- Comments for complex logic
This project is for personal use and learning purposes.
- Google Gemini AI - For intelligent conversation capabilities
- MongoDB - For reliable data storage
- React - For building the user interface
- TailwindCSS - For beautiful styling
- Lucide React - For clean, modern icons
For issues or questions:
- Check the Troubleshooting section above
- Review the code comments
- Check console logs for errors
- Verify environment variables are set correctly
Built with β€οΈ for personal wellness and productivity