How mohammed-alshaibani/healthyai works
HealTrip AI helps patients in Saudi Arabia find healthcare providers through a bilingual chat assistant and a provider directory. In the chat flow, the web client sends a message to the API; the API validates it, checks for emergencies before invoking the agent, and the agent can request doctor or hospital searches. Search results are grounded in database data, with fallback datasets when the database is unavailable. The directory also supports provider registration. The README documents uploads and bilingual UI; source excerpts do not show the full upload path or all directory API wiring.
Main entry points: ChatWindow.tsx Chat UI · chat.service.ts Chat Service · agent.ts Agent Orchestrator · doctors.service.ts Doctor Search
Components 25
Patient Web App
- Chat UI
apps/web/src/components/ChatWindow.tsx - Chat Input
apps/web/src/components/ChatInput.tsx - Message List
apps/web/src/components/MessageList.tsx - Web API Client
apps/web/src/lib/api.ts - Provider Directory
apps/web/src/app/providers/page.tsx
API Orchestration
- API App
apps/api/src/app.ts - Chat Endpoint
apps/api/src/chat/chat.controller.ts - Chat Service
apps/api/src/chat/chat.service.ts - Request Validation
apps/api/src/shared/middleware/validate-request.ts - Emergency Safety
apps/api/src/safety/safety.service.ts - Provider Endpoints
apps/api/src/providers/providers.controller.ts
Assistant and Search
- Agent Orchestrator
apps/api/src/agent/agent.ts - Agent Prompts
apps/api/src/agent/prompts.ts - Search Tool Registry
apps/api/src/agent/tools.ts - OpenAI Adapter
apps/api/src/llm/openai-adapter.ts - LLM Interface
apps/api/src/llm/llm-provider.ts
Healthcare Data
- Provider Service
apps/api/src/providers/providers.service.ts - Doctor Search
apps/api/src/doctors/doctors.service.ts - Hospital Search
apps/api/src/hospitals/hospitals.service.ts - Geo Resolution
apps/api/src/shared/geo.ts - Fallback Data
apps/api/src/shared/fallback-data.ts - Prisma Client
apps/api/src/lib/prisma.ts
Other components
- Patient
- PostgreSQL
- Nominatim
Connections 31
- Patient → Chat UI: uses
README.md - Chat UI → Chat Input: renders
apps/web/src/components/ChatWindow.tsx - Chat UI → Message List: renders
apps/web/src/components/ChatWindow.tsx - Chat UI → Web API Client: sends messages
apps/web/src/components/ChatWindow.tsx - Web API Client → Chat Endpoint: POSTs chat
apps/web/src/lib/api.ts - API App → Chat Endpoint: routes chat
apps/api/src/app.ts - Chat Endpoint → Request Validation: validates request
apps/api/src/chat/chat.controller.ts - Chat Endpoint → Chat Service: delegates message
apps/api/src/chat/chat.controller.ts - Chat Service → Emergency Safety: checks emergency
apps/api/src/chat/chat.service.ts - Chat Service → Agent Prompts: builds location context
apps/api/src/chat/chat.service.ts - Chat Service → Agent Orchestrator: runs agent
apps/api/src/chat/chat.service.ts - Agent Orchestrator → Search Tool Registry: dispatches tools
apps/api/src/agent/agent.ts - Agent Orchestrator → Agent Prompts: uses prompts
apps/api/src/agent/agent.ts - Agent Orchestrator → LLM Interface: requests completion
apps/api/src/agent/agent.ts - OpenAI Adapter → LLM Interface: implements
apps/api/src/llm/openai-adapter.ts - Search Tool Registry → Doctor Search: searches doctors
apps/api/src/agent/tools.ts - Search Tool Registry → Hospital Search: searches hospitals
apps/api/src/agent/tools.ts - Doctor Search → Prisma Client: queries
apps/api/src/doctors/doctors.service.ts - Hospital Search → Prisma Client: queries
apps/api/src/hospitals/hospitals.service.ts - Prisma Client → PostgreSQL: accesses
- Doctor Search → Fallback Data: uses on failure
apps/api/src/doctors/doctors.service.ts - Hospital Search → Fallback Data: uses on failure
apps/api/src/hospitals/hospitals.service.ts - Doctor Search → Geo Resolution: resolves location
apps/api/src/doctors/doctors.service.ts - Hospital Search → Geo Resolution: resolves location
apps/api/src/hospitals/hospitals.service.ts - Geo Resolution → Nominatim: reverse geocodes
apps/api/src/shared/geo.ts - Patient → Provider Directory: browses providers
apps/web/src/app/providers/page.tsx - Provider Directory → Provider Endpoints: requests directory actions
- API App → Provider Endpoints: routes providers
apps/api/src/app.ts - Provider Endpoints → Request Validation: validates registration
apps/api/src/providers/providers.controller.ts - Provider Endpoints → Provider Service: delegates provider actions
apps/api/src/providers/providers.controller.ts - Provider Service → Prisma Client: queries and writes
apps/api/src/providers/providers.service.ts