A Node.js application that monitors doctor availability on the SERGAS (Galician Health Service) website and sends email notifications when specific doctors become available for appointments. Mainly developed to test NodeJs and make some Vivecoding on the way.
- 🔍 Monitors specific doctors on the SERGAS website
- 📧 Sends email notifications when doctors become available
- 🕐 Configurable check intervals
- 📊 Comprehensive logging
- 🐳 Docker support for easy deployment
- 🔒 Secure configuration with environment variables
- Node.js 18+ or Docker
- Gmail account (or other SMTP server) for email notifications
- Doctor URL on to SERGAS website
- Clone the repository:
git clone <your-repo-url>
cd DoctorChecker- Create your environment file:
cp .env.example .env- Edit
.envwith your configuration:
nano .env- Build and run with Docker Compose:
docker-compose up -d- Install dependencies:
npm install-
Configure environment variables (see Configuration section)
-
Run the application:
npm startFor development:
npm run devCreate a .env file based on .env.example and configure the following variables:
SERGAS_BASE_URL: Base URL for SERGAS website (default: https://www.sergas.es)CHECK_INTERVAL_MINUTES: How often to check for availability (default: 15 minutes)DOCTORS_TO_MONITOR: Comma-separated list of doctor names or IDs to monitor
SMTP_HOST: SMTP server hostname (default: smtp.gmail.com)SMTP_PORT: SMTP server port (default: 587)SMTP_SECURE: Use SSL/TLS (default: false)SMTP_USER: Your email addressSMTP_PASS: Your email password or app passwordADMIN_EMAILS: Comma separated emails that will receive the startup notificationUSER_EMAILS: Comma separated emails that will receive doctor status updatesFROM_EMAIL: Email address for sending notifications
For Gmail, you'll need to:
- Enable 2-factor authentication
- Generate an "App Password" for this application
- Use the app password in
SMTP_PASS
Build the image:
docker build -t doctor-checker .Run with docker-compose:
docker-compose up -dView logs:
docker-compose logs -fStop the application:
docker-compose downEdit the DOCTORS_TO_MONITOR environment variable:
DOCTORS_TO_MONITOR=Dr. García,Dr. López,Dr. Martínez
Modify CHECK_INTERVAL_MINUTES in your .env file:
CHECK_INTERVAL_MINUTES=10
The application includes placeholder code for SERGAS website integration. You'll need to:
- Analyze the actual SERGAS website structure
- Update the selectors in
src/services/sergasService.js - Modify the
parseDoctorInfomethod to match the website's HTML structure
Logs are stored in the logs/ directory and also displayed in the console. The application logs:
- Doctor availability checks
- Email notifications sent
- Errors and warnings
- Application startup/shutdown events
- Verify SMTP credentials
- Check if 2FA is enabled (use app password for Gmail)
- Ensure firewall allows SMTP connections
- The website structure may change, requiring updates to selectors
- Rate limiting may occur with frequent requests
- Consider using proxy rotation for production use
- Ensure Docker and Docker Compose are installed
- Check that ports are not in use
- Verify environment file is properly configured
Run tests:
npm testRun in development mode:
npm run dev- Never commit
.envfiles to version control - Use app passwords instead of main account passwords
- Consider rate limiting to respect SERGAS servers
- Monitor logs for suspicious activity
ISC License
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues related to:
- SERGAS website changes: Update the selectors in the service
- Email configuration: Check your SMTP settings
- Docker deployment: Verify your docker-compose configuration