A full-stack diabetes prevention and care platform with role-based access for admins, patients (infected), and prevention users (non-infected).
Health Guardian Hub combines:
- A modern React frontend for dashboards, education, diet, activity, medications, and notifications
- A PHP REST API with JWT auth and role-based authorization
- A MySQL database with seeded demo content and test users
- Optional scheduled jobs for medication reminders and missed-dose automation
- Role-aware experience for
admin,infected, andnon-infectedusers - Authentication flows: register, login, refresh token, logout, forgot/reset password, email verification
- Medication management with schedule tracking and adherence statistics
- Glucose logging with trends and daily summaries
- Nutrition and recipe browsing with diabetes-friendly metadata
- Exercise catalog and activity logging
- Education content management and progress tracking
- In-app notifications and notification preferences
- Admin analytics and user/content management
- React 18 + TypeScript
- Vite
- Tailwind CSS + shadcn/ui
- TanStack Query
- React Router
- Vitest + Testing Library
- PHP 8+ (PDO)
- MySQL 8+ / MariaDB 10.5+
- JWT (access + refresh tokens)
React (Vite/TS) -> PHP API Router (api/index.php) -> MySQL
- Frontend services in
src/services/*map to backend endpoints underapi/index.php - JWT access token is attached to API requests and automatically refreshed when needed
.
|- src/ # React app (pages, components, services, context)
|- api/ # PHP REST API (controllers, models, middleware, utils)
| |- config/ # App and DB configuration
| |- database/ # Schema, seed data, and SQL migrations
| |- cron/ # Scheduled jobs for reminders and missed medications
|- public/ # Static frontend assets
|- SETUP_GUIDE.md # Extended integration reference
- Node.js 18+ and npm (or Bun)
- PHP 8.0+
- MySQL 8.0+ or MariaDB 10.5+
- Apache/XAMPP (optional) or PHP built-in server
npm install
cp .env.example .env
npm run devFrontend runs at http://localhost:5173 by default.
- Create/import database:
CREATE DATABASE diabetes_app CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;mysql -u root -p diabetes_app < api/database/schema.sql
mysql -u root -p diabetes_app < api/database/seed.sql
mysql -u root -p diabetes_app < api/database/migration_email_verification.sql
mysql -u root -p diabetes_app < api/database/migration_password_reset.sql
mysql -u root -p diabetes_app < api/database/migration_reminder_log.sql- Configure backend env values (or edit defaults in
api/config/config.php). - Start API:
cd api
php -S localhost:8000- Point frontend to API in
.env:
VITE_API_URL=http://localhost:8000If using XAMPP and serving API from htdocs/diabetes-api/api, use:
VITE_API_URL=http://localhost/diabetes-api/api- Built-in PHP server:
http://localhost:8000/health - Apache path-based setup:
http://localhost/diabetes-api/api/health
| Variable | Required | Example | Description |
|---|---|---|---|
VITE_API_URL |
Yes | http://localhost:8000 |
Base URL for API requests (no trailing slash recommended). |
| Variable | Default | Description |
|---|---|---|
APP_ENV |
development |
App environment (development or production) |
DB_HOST |
localhost |
Database host |
DB_NAME |
diabetes_app |
Database name |
DB_USER |
root |
Database user |
DB_PASS |
`` | Database password |
JWT_SECRET |
your-super-secret... |
JWT signing secret (change in production) |
API_BASE_URL |
http://localhost/api |
API base URL metadata |
FRONTEND_URL |
http://localhost:5173 |
Used for email action links |
SMTP_HOST / SMTP_PORT |
smtp.gmail.com / 587 |
SMTP server config |
SMTP_USERNAME / SMTP_PASSWORD |
empty | SMTP credentials |
SMTP_ENCRYPTION |
tls |
tls or ssl |
MAIL_FROM_ADDRESS |
noreply@diabetescare.com |
Sender email |
MAIL_FROM_NAME |
DiabetesCare |
Sender display name |
Imported from api/database/seed.sql:
- Admin:
admin@diabetescare.com/password123 - Patient:
patient@example.com/password123 - Prevention user:
user@example.com/password123
Primary route groups:
POST /auth/*,GET /auth/meGET|PUT|DELETE /users*(admin)GET|POST|PUT|DELETE /medications*GET|POST|DELETE /glucose*GET|POST|PUT|DELETE /recipes*GET /exercises*,GET|POST|DELETE /activity*GET|POST|PUT /education*GET|PUT|POST|DELETE /notifications*GET /analytics/*(admin)
See SETUP_GUIDE.md for detailed endpoint mapping.
For production reminder workflows:
api/cron/medication_reminders.php: sends medication reminder emailsapi/cron/mark_missed_medications.php: marks overdue pending doses as missed
Example cron schedule from script headers:
- Every 5 minutes: medication reminders
- Every 15 minutes: mark missed doses
Frontend scripts from package.json:
npm run dev- Start Vite dev servernpm run build- Production buildnpm run preview- Preview production buildnpm run lint- ESLint checksnpm run test- Run Vitest oncenpm run test:watch- Run Vitest in watch mode
Latest local test status:
npm run testpassed (1test,1test file)
- Set
APP_ENV=productionin backend environment - Use a strong
JWT_SECRET - Configure production database credentials and SMTP settings
- Restrict CORS origins in
api/config/config.php - Ensure API is served behind HTTPS
- Replace all default passwords and seed accounts before go-live
- Rotate JWT and SMTP secrets
- Disable verbose error output in production
- Enforce least-privilege DB users
- Review allowed CORS origins regularly
- Full setup and integration guide: SETUP_GUIDE.md
- Backend-specific setup notes: api/README.md
No license file is currently included. Add a LICENSE file to define usage terms.