119 lines
2.8 KiB
Markdown
119 lines
2.8 KiB
Markdown
# WhatsApp Medical Chatbot API
|
|
|
|
This is a FastAPI-based API for a WhatsApp medical chatbot that provides various healthcare services.
|
|
|
|
## Features
|
|
|
|
- WhatsApp integration for chat-based interactions
|
|
- Consultation booking with healthcare professionals
|
|
- OTC drug purchase capabilities
|
|
- Symptom checking and clinical triage
|
|
- Doctor report generation
|
|
- Voice note processing for audio input
|
|
- Monitoring with Grafana, Prometheus, Loki, and Promtail
|
|
|
|
## Tech Stack
|
|
|
|
- **Backend**: Python 3.11+ with FastAPI
|
|
- **Database**: SQLite with SQLAlchemy ORM
|
|
- **Authentication**: JWT-based authentication
|
|
- **Documentation**: OpenAPI (Swagger UI and ReDoc)
|
|
- **Monitoring**: Prometheus, Grafana, Loki, and Promtail
|
|
- **Deployment**: Docker, Docker Compose, and Kubernetes
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.11+
|
|
- Docker and Docker Compose (for containerized deployment)
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone <repository-url>
|
|
cd whatsapp-medical-chatbot-api
|
|
```
|
|
|
|
2. Create a virtual environment:
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
```
|
|
|
|
3. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
4. Create a `.env` file based on `.env.example`:
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
Then edit the `.env` file to set the required environment variables.
|
|
|
|
### Running the Application
|
|
|
|
#### Using Python
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
#### Using Docker
|
|
|
|
```bash
|
|
docker-compose up -d
|
|
```
|
|
|
|
### Environment Variables
|
|
|
|
The application requires the following environment variables:
|
|
|
|
- `APP_NAME`: Name of the application
|
|
- `API_V1_PREFIX`: Prefix for API v1 endpoints
|
|
- `SECRET_KEY`: Secret key for JWT token generation
|
|
- `ACCESS_TOKEN_EXPIRE_MINUTES`: JWT token expiration time in minutes
|
|
- `WHATSAPP_API_URL`: WhatsApp API URL
|
|
- `WHATSAPP_API_TOKEN`: WhatsApp API authentication token
|
|
- `WHATSAPP_API_PHONE_NUMBER`: WhatsApp phone number for the chatbot
|
|
- `WHATSAPP_VERIFY_TOKEN`: WhatsApp webhook verification token
|
|
- `OPENAI_API_KEY`: OpenAI API key for NLP tasks
|
|
- `SPEECH_TO_TEXT_API_KEY`: API key for speech-to-text service
|
|
|
|
## API Documentation
|
|
|
|
The API documentation is available at:
|
|
|
|
- Swagger UI: `http://localhost:8000/docs`
|
|
- ReDoc: `http://localhost:8000/redoc`
|
|
- OpenAPI JSON: `http://localhost:8000/openapi.json`
|
|
|
|
## Monitoring
|
|
|
|
The application is set up with monitoring using Prometheus, Grafana, Loki, and Promtail:
|
|
|
|
- Prometheus: `http://localhost:9090`
|
|
- Grafana: `http://localhost:3000`
|
|
- Loki: `http://localhost:3100`
|
|
|
|
## Deployment
|
|
|
|
### Docker Compose
|
|
|
|
```bash
|
|
docker-compose up -d
|
|
```
|
|
|
|
### Kubernetes
|
|
|
|
Kubernetes manifests are provided in the `k8s` directory.
|
|
|
|
```bash
|
|
kubectl apply -f k8s/
|
|
```
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License - see the LICENSE file for details. |