Skip to content

anilchowdary07/PDA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ AI-Powered Health Assistant# AI-Powered Personal Digital Assistant (PDA)

A comprehensive personal health management system with AI-powered insights, digital diary, face recognition, and smart event management.A comprehensive full-stack health and wellness application with AI-powered features for personal health management, journaling, and intelligent assistance.

✨ Features## 🎯 Overview

1. πŸ“” Digital Diary (Calendar Journal)PDA is a health-focused personal assistant featuring:

  • Calendar-based interface - Click any date to view entries for that day- AI Health Chat with dynamic response optimization

  • AI-powered daily summaries - Get comprehensive summaries of your day- AI Health Journal for conversational mood and symptom tracking

  • Monthly insights - Receive AI-generated monthly feedback and trends- Health Profile Management with smart onboarding

  • Mood tracking - Track your emotional wellbeing- Face Recognition for secure authentication

  • Activity logging - Record daily activities automatically- Health Records tracking and visualization

  • Smart conversations - Chat with AI to reflect on your day- Notifications & Reminders for medications and appointments

2. πŸ“… Smart Events & Schedule## πŸ“ Project Structure

  • Edit & Delete - Full CRUD operations on events

  • Status indicators - Urgent, Today, Tomorrow, Upcoming, Past```

  • Priority badges - High πŸ”₯, Medium ⚑, Low πŸ’šgen_ai/

  • Countdown timers - See exactly when events are happeningβ”œβ”€β”€ backend/ # Node.js + Express API

  • Tab navigation - Filter by All/Upcoming/Today/Pastβ”‚ β”œβ”€β”€ src/

  • AI suggestions - Get smart event recommendationsβ”‚ β”‚ β”œβ”€β”€ routes/ # API route definitions

β”‚ β”‚ β”œβ”€β”€ controllers/ # Request handlers

3. πŸ”” Notification Systemβ”‚ β”‚ β”œβ”€β”€ models/ # MongoDB models (User, HealthRecord, JournalEntry, etc.)

  • Auto-refresh - New notifications every 30 secondsβ”‚ β”‚ β”œβ”€β”€ services/ # Business logic (aiService, journalAIService, emailService)

  • Sidebar badge - Real-time unread countβ”‚ β”‚ β”œβ”€β”€ middleware/ # Auth, validation, error handling

  • Email notifications - Optional email alertsβ”‚ β”‚ β”œβ”€β”€ utils/ # Helper functions

  • Event reminders - 24h and 1h before eventsβ”‚ β”‚ └── config/ # Configuration files

  • Medication reminders - Daily at 8 AMβ”‚ β”œβ”€β”€ uploads/ # File uploads (health images, face recognition)

  • Weekly summaries - Every Monday at 9 AMβ”‚ └── tests/ # Backend tests

β”‚

4. πŸ₯ Health Profileβ”œβ”€β”€ frontend/ # React + Vite SPA

  • Complete health tracking - Medical conditions, medications, allergiesβ”‚ β”œβ”€β”€ src/

  • Emergency contacts - Quick access to important contactsβ”‚ β”‚ β”œβ”€β”€ components/ # React components

  • Doctor information - Primary physician detailsβ”‚ β”‚ β”œβ”€β”€ pages/ # Page components (Dashboard, Profile, Chat, Journal)

  • Blood type & vitals - Essential health informationβ”‚ β”‚ β”œβ”€β”€ services/ # API service layer

  • Health records - Upload and analyze medical documentsβ”‚ β”‚ β”œβ”€β”€ context/ # React context (AuthContext)

β”‚ β”‚ β”œβ”€β”€ hooks/ # Custom React hooks

5. πŸ‘€ Face Recognitionβ”‚ β”‚ └── assets/ # Static assets

  • Register faces - Add family members and caregiversβ”‚ └── public/ # Public files

  • Secure identification - Enhanced security featuresβ”‚

  • Relationship tracking - Remember who's who└── README.md

  • Image gallery - View all registered faces```

6. πŸ’¬ AI Chat Assistant## πŸš€ Getting Started

  • Health queries - Ask health-related questions

  • Personalized responses - Context-aware AI assistance### Prerequisites

  • Conversation history - Review past conversations- Node.js (v16+)

  • Multiple conversations - Organize by topic- MongoDB (local or Atlas)

  • Google Gemini API Key


Backend Setup

πŸš€ Getting Started1. Navigate to backend: cd backend

  1. Install dependencies: npm install

Prerequisites3. Create .env file:

  • Node.js (v14 or higher)```env

  • MongoDBPORT=5000

  • Google Gemini API keyMONGODB_URI=mongodb://localhost:27017/pda

JWT_SECRET=your-secret-key

InstallationGEMINI_API_KEY=your-gemini-api-key

EMAIL_USER=your-email@gmail.com

  1. Clone the repositoryEMAIL_PASS=your-app-password

    bash

    git clone 4. Start server: npm run dev

    cd gen_ai

    
    
  2. Navigate to frontend: cd frontend

  3. Install backend dependencies2. Install dependencies: npm install

    ```bash3. Create .env file:

    cd backend```env

    npm installVITE_API_URL=http://localhost:5000/api

    
    
  4. Start dev server: npm run dev

  5. Install frontend dependencies

    
    cd ../frontend
    
    npm install### 1. **AI Health Chat with Dynamic Responses**
    
    ```The AI chat intelligently adjusts response length based on question complexity:
    
    
    
    
  6. Set up environment variables- Minimal (1-2 sentences): "hi", "thanks", "ok"

    • Brief (2-3 sentences): "what is X?", simple questions

    Create backend/.env:- Concise (3-5 sentences): "how does X work?", explanations

    
    PORT=5000- **Detailed** (2-4 paragraphs): comprehensive guides, step-by-step explanations
    
    MONGODB_URI=your_mongodb_connection_string
    
    JWT_SECRET=your_jwt_secret**Implementation:**
    
    GEMINI_API_KEY=your_gemini_api_key- `backend/src/services/aiService.js` - Smart complexity detection
    
    EMAIL_SERVICE=gmail- Dynamic prompt engineering based on question type
    
    EMAIL_USER=your_email@gmail.com- Conversation history context
    
    EMAIL_PASSWORD=your_email_password
    
    FRONTEND_URL=http://localhost:5173### 2. **AI Health Journal**
    
    ```Conversational journaling with AI that extracts structured health data:
    
    
    
    Create `frontend/.env`:**Templates:**
    
    ```env- Daily Check-in (mood, energy, wellbeing)
    
    VITE_API_BASE_URL=http://localhost:5000/api- Symptom Tracker (health symptoms, severity)
    
    ```- Medication Log (medications, side effects)
    
    
  • Gratitude Journal (practice gratitude)
  1. Start the backend server- Food Diary (meals, nutrition)

    
    cd backend
    
    node src/server.js**Features:**
    
    ```- Natural conversation with AI
    
    
  • Automatic data extraction (mood, symptoms, activities)
  1. Start the frontend development server- Pattern detection and insights

    
    cd frontend- Weekly summaries
    
    npm run dev- Export to PDF
    
    

API Endpoints:

  1. Open your browser- POST /api/journal/entries - Start new entry

    ```- POST /api/journal/entries/:id/messages - Add message

    http://localhost:5173- POST /api/journal/entries/:id/complete - Save entry

    ```- GET /api/journal/entries - List entries

  • GET /api/journal/insights - Get AI insights

Components:

πŸ“– Usage Guide- frontend/src/pages/JournalChat.jsx - Conversational interface

  • frontend/src/pages/JournalHistory.jsx - Timeline & insights

Digital Diary

3. Smart Health Onboarding

  1. Navigate to Journal - Click "Journal" in the sidebarFirst-time onboarding that appears only once:

  2. View Calendar - See all your entries marked on calendar

  3. Click a Date - View all entries and activities for that dayUser Flow:

  4. New Entry - Click "New Entry" button to start writing1. New user registers β†’ Onboarding appears automatically

  5. Chat with AI - Tell the AI about your day2. User completes OR skips β†’ Never shows again

  6. Save Entry - Click "Save Entry" when done3. All data editable later in Profile > Health tab

  7. Monthly Insights - Click "Get Monthly Insights" for AI analysis

Implementation:

Events Management- hasSeenOnboarding flag in User model

  • POST /api/users/mark-onboarding-seen - Skip endpoint
  1. Add Event - Click "Add Event" button- Skip shows toast: "Complete health profile anytime from Settings"

  2. Fill Details - Title, date, time, type, priority- Profile page has full health editing capabilities

  3. Edit Event - Click edit button on any event card

  4. Delete Event - Click delete button to remove eventTracked Data:

  5. Filter Events - Use tabs to filter by status- Demographics (age, gender, height, weight, blood type)

  6. AI Suggestions - Enter what you need and get smart suggestions- Medical (conditions, medications, allergies)

  • Lifestyle (activity, sleep, diet, smoking, alcohol)

Notifications- Emergency contacts

  • Doctor information

Automatic Reminders:- Health goals

  • Hourly: System checks for upcoming events

  • 24h before event: First reminder sent### 4. Health Records Management

  • 1h before event: Urgent reminder sentTrack and manage health records with file uploads:

  • Daily 8 AM: Medication reminders

  • Monday 9 AM: Weekly health summaryFeatures:

  • Upload medical documents, lab results, prescriptions

View Notifications:- Image attachments for health records

  • Check sidebar badge for unread count- Categorization and tagging

  • Navigate to Notifications page- Search and filtering

  • Filter by type or status- Timeline view

  • Mark as read or delete

API Endpoints:

Health Profile- POST /api/health-records - Create record

  • GET /api/health-records - List records
  1. Complete Onboarding - Fill in health information on first use- PUT /api/health-records/:id - Update record

  2. Update Profile - Go to Profile β†’ Edit health details- DELETE /api/health-records/:id - Delete record

  3. Upload Records - Upload medical documents for AI analysis

  4. View History - See all uploaded health records### 5. Face Recognition Authentication

Secure face-based authentication:


Features:

πŸ—οΈ Architecture- Face registration during signup

  • Face login alternative

Backend- Multiple face images per user

  • Framework: Node.js with Express- Secure image storage

  • Database: MongoDB with Mongoose

  • AI: Google Gemini 2.0 FlashAPI Endpoints:

  • Authentication: JWT tokens- POST /api/face/register - Register face

  • File Storage: Local filesystem- POST /api/face/login - Face login

  • Email: Nodemailer- GET /api/face/images - List registered faces

  • Scheduling: node-cron- DELETE /api/face/:id - Remove face

Frontend### 6. Notifications & Reminders

  • Framework: React 18 with ViteEmail notifications for health events:

  • Routing: React Router v6

  • Styling: Tailwind CSSFeatures:

  • Icons: Lucide React- Medication reminders

  • Notifications: React Hot Toast- Appointment notifications

  • HTTP Client: Axios- Health alerts

  • Event reminders

Project Structure


gen_ai/- `backend/src/services/emailService.js` - Nodemailer integration

β”œβ”€β”€ backend/- Configurable notification preferences

β”‚   β”œβ”€β”€ src/

β”‚   β”‚   β”œβ”€β”€ controllers/      # Request handlers## πŸ› οΈ Technologies

β”‚   β”‚   β”œβ”€β”€ models/           # MongoDB schemas

β”‚   β”‚   β”œβ”€β”€ routes/           # API routes### Backend

β”‚   β”‚   β”œβ”€β”€ services/         # Business logic- **Runtime:** Node.js + Express.js

β”‚   β”‚   β”œβ”€β”€ middleware/       # Auth, error handling- **Database:** MongoDB + Mongoose

β”‚   β”‚   β”œβ”€β”€ utils/            # Helper functions- **Authentication:** JWT + bcrypt

β”‚   β”‚   └── server.js         # Entry point- **AI:** Google Gemini 2.0 Flash

β”‚   β”œβ”€β”€ uploads/              # File storage- **File Upload:** Multer

β”‚   └── package.json- **Email:** Nodemailer

β”‚- **Validation:** express-validator

β”œβ”€β”€ frontend/

β”‚   β”œβ”€β”€ src/### Frontend

β”‚   β”‚   β”œβ”€β”€ components/       # Reusable components- **Framework:** React 18 + Vite

β”‚   β”‚   β”œβ”€β”€ pages/            # Page components- **Routing:** React Router v6

β”‚   β”‚   β”œβ”€β”€ services/         # API calls- **HTTP Client:** Axios

β”‚   β”‚   β”œβ”€β”€ context/          # React context- **Styling:** Tailwind CSS

β”‚   β”‚   β”œβ”€β”€ hooks/            # Custom hooks- **Icons:** Lucide React

β”‚   β”‚   └── styles/           # CSS files- **Notifications:** react-hot-toast

β”‚   └── package.json- **State Management:** React Context API

β”‚

└── README.md## πŸ“‘ API Documentation

Authentication

---- POST /api/auth/register - User registration

  • POST /api/auth/login - User login

πŸ”§ API Endpoints- GET /api/auth/me - Get current user

Authentication### Users

  • POST /api/auth/register - Register new user- GET /api/users/profile - Get user profile

  • POST /api/auth/login - Login user- PUT /api/users/profile - Update profile

  • GET /api/auth/me - Get current user- PUT /api/users/health-profile - Update health profile

  • POST /api/users/mark-onboarding-seen - Mark onboarding as seen

Journal

  • POST /api/journal/entries - Create entry### AI Chat

  • GET /api/journal/entries - Get all entries- POST /api/ai/chat - Send message to AI

  • GET /api/journal/entries/:id - Get single entry- GET /api/ai/history - Get chat history

  • POST /api/journal/entries/:id/messages - Add message

  • POST /api/journal/entries/:id/complete - Complete entry### Health Journal

  • GET /api/journal/daily-summary - Get daily summary- POST /api/journal/entries - Start new journal entry

  • GET /api/journal/monthly-insights - Get monthly insights- POST /api/journal/entries/:id/messages - Continue conversation

  • POST /api/journal/entries/:id/complete - Complete entry

Events- GET /api/journal/entries - List all entries

  • GET /api/events - Get all events- GET /api/journal/insights - Get AI insights

  • POST /api/events - Create event

  • PUT /api/events/:id - Update event### Health Records

  • DELETE /api/events/:id - Delete event- POST /api/health-records - Create health record

  • POST /api/events/suggest - Get AI suggestions- GET /api/health-records - List health records

  • PUT /api/health-records/:id - Update health record

Health- DELETE /api/health-records/:id - Delete health record

  • GET /api/users/health-profile - Get health profile

  • PUT /api/users/health-profile - Update health profile### Face Recognition

  • POST /api/upload/health-record - Upload health record- POST /api/face/register - Register face

  • POST /api/face/login - Login with face

Notifications- GET /api/face/images - Get registered faces

  • GET /api/notifications - Get all notifications

  • POST /api/notifications - Create notification### Notifications

  • PUT /api/notifications/:id/read - Mark as read- POST /api/notifications - Send notification

  • PUT /api/notifications/read-all - Mark all as read- GET /api/notifications - Get user notifications

  • DELETE /api/notifications/:id - Delete notification

πŸ” Environment Variables

Faces

  • GET /api/faces - Get all faces### Backend (.env)

  • POST /api/faces/register - Register new face```env

  • DELETE /api/faces/:id - Delete face# Server

PORT=5000

---NODE_ENV=development

πŸ” Security# Database

MONGODB_URI=mongodb://localhost:27017/pda

  • JWT Authentication - Secure token-based auth

  • Password Hashing - bcrypt for password security# Authentication

  • CORS Protection - Configured for frontend originJWT_SECRET=your-secret-key-here

  • Input Validation - Mongoose schema validationJWT_EXPIRE=7d

  • File Upload Limits - Restricted file sizes

  • Environment Variables - Sensitive data in .env# AI Service

GEMINI_API_KEY=your-gemini-api-key


Email Service

πŸ“Š Notification ScheduleEMAIL_USER=your-email@gmail.com

EMAIL_PASS=your-app-password

| Type | Frequency | Time | Condition |EMAIL_FROM=PDA Health noreply@pda.com

|------|-----------|------|-----------|

| Event Reminders | Every hour | On the hour | Events in next 24h |# File Upload

| Medication Reminders | Daily | 8:00 AM | Has medications |MAX_FILE_SIZE=5242880

| Weekly Summary | Weekly | Monday 9:00 AM | Has activity |UPLOAD_PATH=./uploads


---

### Frontend (.env)

## 🎨 Features in Detail```env

VITE_API_URL=http://localhost:5000/api

### Calendar JournalVITE_APP_NAME=Personal Digital Assistant

What makes it special:

  • Calendar interface - See your life at a glance## 🎨 Key Components

  • Daily summaries - AI combines all activities for the day

  • Monthly feedback - Get insights on patterns and trends### Frontend Pages

  • Mood tracking - Visual mood indicators- Dashboard.jsx - Main dashboard with health overview

  • Activity integration - Combines journal + events + health- Profile.jsx - User profile and health settings

  • Chat.jsx - AI health chat interface

How it works:- JournalChat.jsx - Conversational journaling

  1. Write journal entries through chat interface- JournalHistory.jsx - Journal timeline and insights

  2. Entries are marked on calendar- HealthRecords.jsx - Health records management

  3. Click any date to see that day's summary

  4. Request monthly insights for trend analysis### Backend Services

  5. AI analyzes mood, activities, and patterns- aiService.js - AI chat with dynamic response optimization

  • journalAIService.js - Journal conversation and data extraction

Smart Events- emailService.js - Email notifications

  • userService.js - User management

Enhancements:

  • βœ… Edit events after creation### Key Features Implementation

  • βœ… Delete unwanted events

  • βœ… Status-based filtering#### AI Response Optimization

  • βœ… Visual priority indicators```javascript

  • βœ… Time countdowns// Automatically detects question complexity

  • βœ… AI-powered suggestionsconst complexity = determineQuestionComplexity(question);

// Adjusts response length accordingly

Notificationsconst prompt = buildContextualPrompt(question, complexity);


**Types:**

- πŸ”” General - System updates#### Health Onboarding

- πŸ₯ Health - Health-related alerts```javascript

- πŸ’Š Medication - Medicine reminders// Shows only if never seen AND not completed

- πŸ“… Appointment - Doctor visitsif (!healthProfile?.hasSeenOnboarding && !healthProfile?.isProfileComplete) {

- 🎯 Event - Calendar events  // Show onboarding

- ⚠️ Alert - Urgent notifications}

Delivery:

  • In-app notifications (always)#### Journal AI Extraction

  • Email notifications (optional)```javascript

  • Auto-refresh every 30s// Extracts structured data from conversation

  • Sidebar badge with countconst data = extractStructuredData(conversation);

// Contains: mood, moodScore, symptoms, activities, etc.

---```

πŸ› Troubleshooting## πŸ“Š Database Models

Backend won't start### User

  • Check MongoDB connection string- Authentication (email, password)

  • Verify Gemini API key is valid- Profile (name, age, gender)

  • Ensure port 5000 is available- Health Profile (medical, lifestyle, goals)

  • Check all environment variables- Onboarding tracking (hasSeenOnboarding, isProfileComplete)

Frontend won't connect### HealthRecord

  • Verify backend is running- Type, title, description

  • Check VITE_API_BASE_URL in .env- Date, category, tags

  • Clear browser cache- File attachments

  • Check browser console for errors- User reference

Notifications not working### JournalEntry

  • Check email credentials in .env- Conversation messages

  • Verify user has notifications enabled- Extracted data (mood, symptoms, activities)

  • Check MongoDB connection- AI insights

  • Review backend logs for errors- Template type

Calendar not loading### Face

  • Check journal entries exist- User reference

  • Verify API endpoints are working- Image path

  • Clear browser cache- Registration date

  • Check date filtering logic

πŸ§ͺ Testing


Manual Testing Checklist

πŸš€ Recent Updates- [ ] User registration and login

  • Health onboarding (first-time only)

Latest Features (December 2024)- [ ] Skip onboarding functionality

  • βœ… Calendar-based journal interface- [ ] AI chat with various question types

  • βœ… Daily AI summaries- [ ] Journal entry creation with all templates

  • βœ… Monthly AI insights- [ ] Health record upload

  • βœ… Edit & delete events- [ ] Face registration and login

  • βœ… Fixed health profile updates- [ ] Profile editing

  • βœ… Auto-refreshing notifications- [ ] Email notifications

  • βœ… Sidebar notification badge

  • βœ… Enhanced event status system## 🚧 Roadmap

---- [x] AI Health Chat with dynamic responses

  • AI Health Journal system

πŸ“ TODO / Future Enhancements- [x] Health onboarding optimization

  • Face recognition

High Priority- [x] Notifications & Reminders

  • Real-time WebSocket notifications- [ ] Health trends visualization (charts/graphs)

  • Browser push notifications- [ ] Emergency contact integration

  • Custom medication reminder times- [ ] Enhanced chatbot with scheduling

  • Notification snooze feature- [ ] Multi-device sync

  • Mobile responsive improvements- [ ] Role-based access (caregivers)

  • Two-factor authentication

Medium Priority- [ ] Health goals & gamification

  • Export journal as PDF

  • Voice input for journal entries## πŸ“ License

  • Integration with health devices

  • Multi-language supportMIT License

  • Dark mode

πŸ‘€ Author

Low Priority

  • Social features (share entries)Anil Chowdary

  • Third-party calendar sync

  • Advanced analytics dashboard## πŸ™ Acknowledgments

  • Machine learning predictions

  • Mobile app (React Native)- Google Gemini AI for intelligent conversation

  • MongoDB for flexible data storage

---- React team for amazing frontend framework

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License.


πŸ‘₯ Contact & Support

For issues, questions, or suggestions:


πŸ™ Acknowledgments

  • Google Gemini AI - Powering intelligent conversations
  • MongoDB - Reliable database solution
  • React - Building interactive UIs
  • Tailwind CSS - Beautiful styling
  • Open Source Community - Various libraries and tools

Version: 2.0
Last Updated: December 2024
Status: Production Ready βœ…


Quick Start Commands

# Start backend
cd backend && node src/server.js

# Start frontend
cd frontend && npm run dev

# Access application
http://localhost:5173

Happy Journaling! πŸ“”βœ¨

Releases

Packages

Contributors

Languages