General07 integrations
Integrations
This directory contains documentation for all third-party service integrations and external API connections used throughout the Kulcare platform.
Integration Categories
Communication Services
- SMS & Voice - SMS delivery via MSG91, Twilio, and voice services
- WhatsApp - WhatsApp messaging via WATI API with delivery tracking
- Push Notifications - Mobile push notifications via AWS SNS
- Email Services - Transactional emails and campaign management
Healthcare & Compliance
- ABDM Integration - India's Ayushman Bharat Digital Mission
- FHIR Compliance - Healthcare data exchange standards
- Medical APIs - Drug databases, medical coding systems
Payment & Billing
- Razorpay - Payment gateway for subscriptions and transactions
- Financial APIs - Banking integrations and financial reporting
Analytics & Marketing
- Analytics Services - Mixpanel, Google Analytics, tracking
- Marketing Automation - Baserow, campaign management
- Google Services - Google My Business, Maps, OAuth
Infrastructure & Cloud
- AWS Services - S3, SNS, CloudWatch, and other AWS integrations
- ElasticSearch - Search and indexing services
- Background Jobs - Sidekiq and job processing
Development & Monitoring
- Error Tracking - Sentry, logging, and error monitoring
- API Documentation - External API integrations and webhooks
- Testing Services - Testing environments and mock services
Quick Reference
Active Integrations
| Service | Purpose | Status | Configuration |
|---|---|---|---|
| MSG91 | SMS delivery (India) | Active | Rails.application.credentials.msg91_auth_key |
| Twilio | SMS/Voice (US/International) | Active | Twilio credentials |
| WATI | WhatsApp messaging | Active | WATI API tokens |
| AWS SNS | Push notifications | Active | AWS credentials |
| Razorpay | Payment processing | Active | Razorpay keys |
| Mixpanel | Analytics tracking | Active | Mixpanel tokens |
| Baserow | Data analytics/CRM | Active | Baserow API |
| Google APIs | Maps, GMB, OAuth | Active | Google service account |
| ElasticSearch | Search indexing | Active | ES cluster config |
| Sentry | Error monitoring | Active | Sentry DSN |
Integration Patterns
Background Job Processing
Most external API calls are processed asynchronously using Sidekiq:
# Standard pattern for external API integration
class ExternalApiService < ActiveJob::Base
queue_as :external_apis
def perform(params)
# API call logic
# Error handling
# Logging
end
endWebhook Handling
External services send webhooks to dedicated controllers:
class ExternalWebhooksController < ApplicationController
skip_before_action :verify_authenticity_token
def create
# Verify webhook signature
# Process webhook data
# Return appropriate response
end
endConfiguration Management
All integration credentials are stored securely:
# Credentials access pattern
Rails.application.credentials.service_name.api_key
Rails.application.credentials.service_name.webhook_secretError Handling
Standardized error handling for external integrations:
begin
external_api_call
rescue StandardError => e
Rails.logger.error "Integration Error: #{e.message}"
ErrorTrackingService.notify(e)
# Graceful degradation logic
endIntegration Health Monitoring
Health Check Endpoints
Each integration should implement health check endpoints:
def health_check
{
service_name: {
status: 'healthy|degraded|down',
last_success: timestamp,
last_error: error_message,
response_time: milliseconds
}
}
endMonitoring Alerts
Set up monitoring for:
- API response times
- Error rates
- Webhook delivery failures
- Service unavailability
- Rate limit violations
Security Considerations
API Key Management
- Store all credentials in Rails encrypted credentials
- Rotate keys regularly
- Use environment-specific keys
- Monitor key usage and access
Webhook Security
- Verify webhook signatures
- Use HTTPS endpoints only
- Implement rate limiting
- Log all webhook requests
Data Privacy
- Minimize data shared with third parties
- Comply with HIPAA/GDPR requirements
- Audit data access and sharing
- Implement data retention policies
Development Guidelines
Adding New Integrations
- Create integration documentation
- Implement service classes with error handling
- Add configuration to credentials
- Create background jobs for async processing
- Implement webhook handlers if needed
- Add monitoring and health checks
- Write comprehensive tests
- Update this documentation
Testing Integrations
- Use VCR for recording HTTP interactions
- Mock external APIs in test environment
- Test error scenarios and edge cases
- Validate webhook signature verification
- Test rate limiting and retry logic
Documentation Standards
Each integration should document:
- Service overview and purpose
- Authentication and configuration
- API endpoints and data formats
- Error handling and retry logic
- Rate limits and quotas
- Webhook specifications
- Testing approaches
- Troubleshooting guides
Related Documentation
- Development Guide - Testing external integrations
- Deployment Guide - Environment configuration
- Background Jobs - Sidekiq and job processing
- Monitoring - System monitoring and alerts