A culturally sensitive mental health conversational assistant for Omani Arabic speakers, providing therapeutic-grade support with strict cultural and safety protocols. The system is Dockerized for easy local development and cloud deployment.
+-------------------+ +---------------------+ +-----------------------------+
| Frontend | <---> | Backend | <---> | LLM Service |
| (React + Vite) | REST | (Node.js/Express) | REST | (Python/FastAPI + LangChain)|
+-------------------+ +---------------------+ +-----------------------------+
| | |
| | |
| v v
| +-------------------+ +----------------------+
| | Speech Services | | OpenAI GPT-4o |
| | (Azure/Google STT | | GPT-4-1106-preview |
| | & Azure TTS) | | (via LangChain) |
| +-------------------+ +----------------------+
-
Frontend (React + Vite):
Single-page application for user interaction. Handles chat UI, audio recording, and playback. Communicates with the backend via REST APIs. -
Backend (Node.js/Express):
Orchestrates the system. Handles API endpoints for chat, audio transcription (STT), text-to-speech (TTS), and relays chat requests to the LLM service. Manages integration with external speech services. -
LLM Service (Python/FastAPI + LangChain):
Handles all LLM logic, including prompt management, safety validation, and cultural adaptation. Uses OpenAI GPT-4o for main conversational intelligence and GPT-4-1106-preview for safety validation. -
External Services:
- Azure/Google STT: Speech-to-text for Omani Arabic.
- Azure TTS: Text-to-speech for Omani Arabic.
- OpenAI GPT-4o & GPT-4-1106-preview: Used for chat and safety validation.
- User interacts with the frontend (text or audio).
- Frontend sends user input to the backend.
- Backend:
- For audio: uses Azure/Google STT to transcribe.
- For chat: relays message to LLM service.
- LLM Service processes the message, applies safety/cultural validation, and generates a response.
- Crisis Mechanism: If a crisis is detected (e.g., suicide, self-harm, violence), the system immediately returns a culturally appropriate crisis message and flags the conversation.
- Fallback Mechanism: If the response needs modification for safety or cultural reasons, the system attempts to regenerate a safer, more appropriate reply.
- Backend (if needed) uses Azure TTS to convert LLM response to audio.
- Frontend displays text and/or plays audio response.
-
Clone the repository:
git clone https://github.com/Virschnieder/cultural-specific-conversational-bot-for-mental-health.git cd cultural-specific-conversational-bot-for-mental-health -
Set up environment variables:
- Copy
.env.exampleto.envin each ofbackend/,frontend/, andllm_service/. - Fill in your local values (API keys, URLs, etc.).
- Copy
-
Start all services:
docker compose up --build
- Frontend: http://localhost:5173
- Backend: http://localhost:5001
- LLM Service: http://localhost:8000
-
Stop all services:
docker compose down
- Frontend:
VITE_BACKEND_URL(set to backend URL at build time)
- Backend:
LLM_SERVICE_URL(URL to LLM service)AZURE_SPEECH_KEY,AZURE_SPEECH_REGION, etc.
- LLM Service:
OPENAI_API_KEY
Note:
- For local dev, use
localhostURLs. - For production, the GitHub Actions workflow injects the correct Azure URLs at build time.
-
Automated via GitHub Actions:
- See
.github/workflows/dockerized-multiservice-deploy.yml - Builds and pushes Docker images for each service to GitHub Container Registry.
- Deploys each service to its own Azure Web App for Containers.
- Sets environment variables in Azure using the Azure CLI.
- See
-
To deploy:
- Push to the
mainbranch. - The workflow will build, push, and deploy all services.
- Environment variables are set automatically in Azure.
- Push to the
- LangChain (Python): Modular LLM orchestration, prompt management, safety/cultural validation.
- OpenAI GPT-4o & GPT-4-1106-preview: Used for chat generation and safety validation.
- Azure/Google STT & Azure TTS: Speech-to-text and text-to-speech for Omani Arabic.
- Strict environment variable management: All secrets and URLs are externalized.
- Easy local development and cloud deployment with Docker.
- Fork the repo and clone locally.
- Copy
.env.exampleto.envin each service and set your own keys/URLs. - Submit PRs for improvements, bugfixes, or new features.
MIT
Questions?
Open an issue or discussion on GitHub!