Skip to content

RohanGottipati/CareSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CareSync

AI-powered care coordination platform for Personal Support Workers (PSWs), family members, and care coordinators. Built for the Canadian home care context with a focus on data residency, 24/7 availability, and intelligent handoff between shifts.

Architecture

Frontend (Vercel)          Backend (Vultr VPS)            External Services
┌──────────────────┐       ┌──────────────────────┐       ┌─────────────────┐
│  React + Vite    │──────▶│  Node/Express        │──────▶│  Backboard.io   │
│  Auth0 SPA       │ /api  │  PM2 process manager │       │  (AI agents)    │
│  Tailwind CSS    │ proxy │  node-cron (nightly)  │       ├─────────────────┤
└──────────────────┘       └──────────┬───────────┘       │  Auth0          │
                                      │                    │  (identity)     │
                                      ├───────────────────▶├─────────────────┤
                                      │                    │  Vultr Object   │
                                      │                    │  Storage (S3)   │
                                      ├───────────────────▶├─────────────────┤
                                      │                    │  Vultr Managed  │
                                      │                    │  PostgreSQL     │
                                      └───────────────────▶├─────────────────┤
                                                           │  Resend (email) │
                                                           └─────────────────┘

Features

  • Pre-visit Briefings — AI-generated shift briefings via Backboard Handoff agent, giving incoming PSWs context on the client's history, medications, and recent visits.
  • Visit Logging — PSWs log visits with notes and session type; entries are written to the database and to the client's Backboard memory for continuity.
  • Medication Sentinel — Nightly 2 AM cron job reviews all clients' medications and conditions via AI, flags risks, and emails the coordinator.
  • Family Portal — Daily summaries generated by the Family agent, emailed to family members and viewable in the portal.
  • Document Management — Upload care plans (PDF, DOCX, images) to Vultr Object Storage with optional background Backboard RAG indexing via Bull queue.
  • Role-based Access — Auth0 with custom claims (psw, family, coordinator) enforced on both frontend routes and backend middleware.
  • Coordinator Dashboard — Client CRUD, PSW shift assignments, sentinel flag review, and admin role management via Auth0 Management API.

Project Structure

caresync/
├── backend/                    # Node.js + Express API
│   ├── server.js               # Entry point, CORS, route mounting, PM2
│   ├── schema.js               # Auto-creates all PostgreSQL tables on boot
│   ├── db.js                   # PostgreSQL pool + all data access functions
│   ├── cron.js                 # Nightly Sentinel (2 AM) + Family Summaries (1 AM)
│   ├── queue.js                # Bull queue (optional, requires Redis)
│   ├── middleware/auth.js      # Auth0 JWT validation + role enforcement
│   ├── routes/
│   │   ├── briefings.js        # GET /api/briefings/:clientId
│   │   ├── visits.js           # POST /api/visits
│   │   ├── family.js           # POST /api/family/draft, GET /api/family/summaries
│   │   ├── documents.js        # POST /api/documents/upload, GET /api/documents
│   │   ├── clients.js          # GET/POST/PUT/DELETE /api/clients
│   │   └── admin.js            # Auth0 user/role management
│   ├── services/
│   │   ├── backboard.js        # Backboard.io API (threads, agents, memory, docs)
│   │   ├── vultrStorage.js     # S3-compatible upload/download/signed URLs
│   │   └── email.js            # Resend: family updates + coordinator alerts
│   ├── workers/
│   │   └── documentWorker.js   # Bull worker for async Backboard RAG indexing
│   └── scripts/
│       ├── seed-margaret-chen.js   # Demo data: Margaret Chen profile + visits
│       └── run-schema.js           # Standalone schema migration runner
│
├── frontend/                   # React + Vite SPA
│   ├── src/
│   │   ├── App.jsx             # Router, role-based rendering
│   │   ├── auth0-provider.jsx  # Auth0 React provider
│   │   ├── useApi.js           # Authenticated fetch hooks (fetchWithAuth, uploadWithAuth)
│   │   ├── pages/
│   │   │   ├── LandingPage.jsx
│   │   │   ├── PSWDashboard.jsx
│   │   │   ├── FamilyPortal.jsx
│   │   │   └── CoordinatorDashboard.jsx
│   │   └── components/
│   │       ├── NavBar.jsx
│   │       ├── BriefingCard.jsx
│   │       ├── VisitLogger.jsx
│   │       ├── DocumentUpload.jsx
│   │       ├── FamilyMessageDraft.jsx
│   │       └── MedicationFlags.jsx
│   └── vercel.json             # SPA rewrites + API proxy to backend

Local Development

Prerequisites

  • Node.js 18+
  • PostgreSQL (or use the Vultr Managed DB connection string)

Backend

cd caresync/backend
cp .env.example .env    # Fill in Auth0, Backboard, Vultr, Resend credentials
npm install
npm run dev             # Starts with nodemon on port 4000

The server auto-creates all database tables on first boot via initSchema().

To seed demo data:

node scripts/seed-margaret-chen.js

Frontend

cd caresync/frontend
cp .env.example .env.local   # Fill in VITE_AUTH0_*, VITE_API_URL
npm install
npm run dev                  # Vite dev server on port 5173

Production Deployment

Backend — Vultr VPS

The backend runs on a Vultr VPS with PM2. Redis is optional (Bull queue for background document processing is skipped when REDIS_URL is not set).

# On the VPS
cd /app/backend
npm install
pm2 start server.js --name caresync-api
pm2 startup && pm2 save

Key production .env settings:

  • NODE_ENV=production (enables nightly cron jobs)
  • CORS_ORIGIN=https://your-vercel-url.vercel.app
  • DATABASE_URL=postgresql://... (Vultr Managed PostgreSQL)
  • Omit REDIS_URL if Redis is not available

Frontend — Vercel

The frontend deploys to Vercel. API requests are proxied through Vercel rewrites (vercel.json) to avoid mixed-content issues (HTTPS frontend to HTTP backend).

Vercel environment variables (set via vercel env add):

  • VITE_AUTH0_DOMAIN
  • VITE_AUTH0_CLIENT_ID
  • VITE_AUTH0_AUDIENCE
  • VITE_BACKBOARD_API_KEY

VITE_API_URL is intentionally not set in production — useApi.js defaults to /api, which Vercel proxies to the backend.

Environment Variables

See caresync/backend/.env.example for the full list with descriptions of where to find each value.

Variable Where Purpose
AUTH0_DOMAIN Backend Auth0 tenant domain
AUTH0_AUDIENCE Backend Auth0 API identifier
AUTH0_M2M_CLIENT_ID Backend Machine-to-machine app for admin ops
AUTH0_M2M_CLIENT_SECRET Backend M2M secret
BACKBOARD_API_KEY Backend Backboard.io API key
BACKBOARD_*_AGENT_ID Backend Handoff, Sentinel, Family assistant IDs
VULTR_STORAGE_* Backend S3-compatible object storage credentials
DATABASE_URL Backend PostgreSQL connection string
REDIS_URL Backend Optional — enables Bull queue for async doc processing
RESEND_API_KEY Backend Email delivery
VITE_AUTH0_DOMAIN Frontend Auth0 domain for SPA
VITE_AUTH0_CLIENT_ID Frontend Auth0 SPA client ID
VITE_AUTH0_AUDIENCE Frontend Must match backend AUTH0_AUDIENCE
VITE_API_URL Frontend Local dev only (http://localhost:4000); omit in production

Database

PostgreSQL with 7 tables, all auto-created on server boot:

  • clients — patient profiles
  • client_threads — Backboard thread IDs per client per agent type
  • visits — PSW visit logs
  • assignments — PSW-to-client shift assignments
  • client_sentinel_results — latest overnight medication sentinel results
  • family_daily_summaries — nightly family-friendly care updates
  • documents — uploaded document metadata

License

Private — Hackathon project.

About

AI-powered care coordination platform for Personal Support Workers (PSWs), family members, and care coordinators.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages