How iaxcel-ai/gaia works
Gaia connects rural health facilities through resource visibility and a referral workflow. Staff log in, inspect facility resources, create referrals, and receiving facilities accept, decline, or complete them; district administrators review reports and manage staff. The frontend also receives referral events in real time, while the backend records referral activity and falls back to a logged SMS stub when no receiving-facility socket is present. The graph preserves documented capabilities, but several route implementations and report details are represented only by their indexed paths; their internal interactions are omitted where evidence is limited.
Main entry points: App.jsx Page routing · admin.js Account administration · db.js PostgreSQL access · auth.js Authentication routes
Components 28
Staff web app
- Page routing
client/src/App.jsx - Login state
client/src/context/AuthContext.jsx - Resource dashboard
client/src/pages/Dashboard.jsx - Resource display
client/src/components/ResourceCard.jsx - Referral creation
client/src/pages/ReferralForm.jsx - Referral actions
client/src/pages/Referrals.jsx - Referral API client
client/src/api/referrals.js - Live event listener
client/src/context/SocketContext.jsx - District reports
client/src/pages/DistrictReports.jsx - Staff accounts
client/src/pages/AdminUsers.jsx - Authentication API
client/src/api/auth.js - Facility API client
client/src/api/facilities.js - Reports API client
client/src/api/reports.js
Referral services
- Authentication routes
server/src/routes/auth.js - Facility resources
server/src/routes/facilities.js - Referral workflow
server/src/routes/referrals.js - District reporting
server/src/routes/reports.js - Account administration
server/src/routes/admin.js - Token and passwords
server/src/services/authService.js - Authentication guard
server/src/middleware/requireAuth.js - Role guard
server/src/middleware/requireRole.js
Persistence and alerts
- Audit logging
server/src/services/auditService.js - Referral notifications
server/src/services/notificationService.js - Socket rooms
server/src/socket.js - PostgreSQL access
server/src/db.js
Other components
- Facility staff
- District admin
- SMS stub
Connections 44
- Facility staff → Page routing: uses
client/src/App.jsx - District admin → Page routing: uses
client/src/App.jsx - Page routing → Login state: provides auth
client/src/App.jsx - Page routing → Resource dashboard: routes to
client/src/App.jsx - Page routing → Referral creation: routes to
client/src/App.jsx - Page routing → Referral actions: routes to
client/src/App.jsx - Page routing → District reports: admin route
client/src/App.jsx - Page routing → Staff accounts: admin route
client/src/App.jsx - Login state → Authentication API: requests login
client/src/context/AuthContext.jsx - Resource dashboard → Facility API client: loads resources
client/src/pages/Dashboard.jsx - Resource dashboard → Resource display: renders resources
client/src/pages/Dashboard.jsx - Referral creation → Facility API client: loads facilities
client/src/pages/ReferralForm.jsx - Referral creation → Referral API client: creates referral
client/src/pages/ReferralForm.jsx - Referral actions → Referral API client: loads and responds
client/src/pages/Referrals.jsx - Referral actions → Live event listener: refreshes on event
client/src/pages/Referrals.jsx - Live event listener → Login state: uses token
client/src/context/SocketContext.jsx - District reports → Facility API client: loads facilities
client/src/pages/DistrictReports.jsx - District reports → Reports API client: loads report
client/src/pages/DistrictReports.jsx - Staff accounts → Facility API client: loads facilities
client/src/pages/AdminUsers.jsx - Staff accounts → Account administration: manages accounts
client/src/pages/AdminUsers.jsx - Referral API client → Referral workflow: HTTP requests
- Authentication API → Authentication routes: HTTP requests
- Facility API client → Facility resources: HTTP requests
- Reports API client → District reporting: HTTP requests
- Authentication routes → PostgreSQL access: queries users
server/src/routes/auth.js - Authentication routes → Token and passwords: checks and issues tokens
server/src/routes/auth.js - Authentication routes → Authentication guard: guards reset
server/src/routes/auth.js - Authentication routes → Role guard: checks admin role
server/src/routes/auth.js - Authentication guard → Token and passwords: verifies token
server/src/middleware/requireAuth.js - Facility resources → PostgreSQL access: queries resources
server/src/routes/facilities.js - Referral workflow → PostgreSQL access: stores referrals
server/src/routes/referrals.js - Referral workflow → Audit logging: records actions
server/src/routes/referrals.js - Referral workflow → Referral notifications: sends alerts
server/src/routes/referrals.js - Audit logging → PostgreSQL access: writes audit
server/src/services/auditService.js - Referral notifications → Socket rooms: emits to room
server/src/services/notificationService.js - Referral notifications → SMS stub: fallback message
server/src/services/notificationService.js - Referral notifications → PostgreSQL access: records channel
server/src/services/notificationService.js - Live event listener → Socket rooms: listens for events
- Account administration → PostgreSQL access: queries accounts
server/src/routes/admin.js - Account administration → Token and passwords: hashes passwords
server/src/routes/admin.js - Account administration → Audit logging: records changes
server/src/routes/admin.js - Account administration → Authentication guard: requires login
server/src/routes/admin.js - Account administration → Role guard: checks role
server/src/routes/admin.js - District reporting → PostgreSQL access: queries report data
server/src/routes/reports.js