A Node.js backend for the FallGuardian system - a healthcare application that connects patients with nurses, featuring fall detection and communication tools.
- User Management: Patient, nurse, and admin roles
- Patient-Nurse Communication: Secure message threads through forms
- Fall Detection: Alert system for patient falls
- AI Integration: Text generation and support
- Node.js (v18 or higher)
- MongoDB (local or MongoDB Atlas)
- Google OAuth credentials
- Docker (for containerized deployment)
Create a .env file in the root directory with:
# Server Configuration
PORT=3000
NODE_ENV=development # Use 'production' in production environments
# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/database
# Session
SESSION_SECRET=your_session_secret_key_here
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id_here
GOOGLE_CLIENT_SECRET=your_google_client_secret_here
GOOGLE_CALLBACK_URL=http://localhost:3000/api/auth/google/callback
LOGOUT_REDIRECT_URL=/
# SMS/Notifications
TELESIGN_CUSTOMER_ID=your_telesign_customer_id
TELESIGN_API_KEY=your_telesign_api_key
# AI API
NEBIUS_API_KEY=your_nebius_api_key
DEEPGRAM_API_KEY=your_deepgram_api_key-
Install dependencies:
npm install
-
Run in development mode:
npm run dev
# Build the Docker image
docker build -t fallguardian-backend .
# Run the container
docker run -p 3000:3000 --env-file .env fallguardian-backendThe project includes GitHub Actions workflows for:
- Automated testing
- Building and pushing Docker images
- Deployment to Azure Container Instances
See DEPLOYMENT.md for detailed deployment instructions.
Swagger API documentation is available at /api-docs when the server is running.
{
name: String, // User's full name
email: String, // Email address (unique)
googleId: String, // Google OAuth ID
age: Number, // User's age (0-120)
role: String, // 'patient', 'nurse', or 'admin'
phoneNumber: String, // Phone number (E.164 format)
nurseId: ObjectId, // For patients: assigned nurse
assignedPatients: [ObjectId], // For nurses: list of patients
createdAt: Date // Account creation timestamp
}{
title: String, // Form title
patient: ObjectId, // Patient reference
nurse: ObjectId, // Nurse reference
status: String, // 'pending', 'in-progress', 'resolved', 'cancelled'
resolved: Boolean, // Whether form is resolved
resolvedBy: ObjectId, // User who resolved the form
resolvedAt: Date, // When the form was resolved
messages: [{
sender: ObjectId, // Message sender
body: String, // Message content
attachment: String, // Optional attachment URL
createdAt: Date // Message timestamp
}],
createdAt: Date, // Form creation timestamp
updatedAt: Date // Last update timestamp
}GET /api/auth/google: Google OAuth loginGET /api/auth/dashboard: Authentication dashboardGET /api/auth/logout: Logout
GET /api/users: Get all usersGET /api/users/me: Get current user profilePUT /api/users/me: Update current user profile
GET /api/nurse/me/patients: Get nurse's patientsPOST /api/nurse/me/patients/:patientId/assign: Assign patient to nurseDELETE /api/nurse/me/patients/:patientId: Remove patient from nurse
GET /api/patient/me/nurse: Get patient's nursePOST /api/patient/me/fall: Alert nurse about patient fall
POST /api/forms: Create new formGET /api/forms/me: Get user's formsGET /api/forms/:id: Get specific formPOST /api/forms/:id/messages: Add message to formPOST /api/forms/:id/resolve: Mark form as resolved
The application follows a layered architecture:
- Models: Database schemas (MongoDB/Mongoose)
- Services: Business logic
- Controllers: Request handling
- Routes: API endpoint definitions
- Middleware: Authentication, validation, error handling