Kulcare Docs
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

Healthcare & Compliance

Payment & Billing

  • Razorpay - Payment gateway for subscriptions and transactions
  • Financial APIs - Banking integrations and financial reporting

Analytics & Marketing

Infrastructure & Cloud

Development & Monitoring

Quick Reference

Active Integrations

ServicePurposeStatusConfiguration
MSG91SMS delivery (India)ActiveRails.application.credentials.msg91_auth_key
TwilioSMS/Voice (US/International)ActiveTwilio credentials
WATIWhatsApp messagingActiveWATI API tokens
AWS SNSPush notificationsActiveAWS credentials
RazorpayPayment processingActiveRazorpay keys
MixpanelAnalytics trackingActiveMixpanel tokens
BaserowData analytics/CRMActiveBaserow API
Google APIsMaps, GMB, OAuthActiveGoogle service account
ElasticSearchSearch indexingActiveES cluster config
SentryError monitoringActiveSentry 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
end

Webhook 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
end

Configuration Management

All integration credentials are stored securely:

# Credentials access pattern
Rails.application.credentials.service_name.api_key
Rails.application.credentials.service_name.webhook_secret

Error 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
end

Integration 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
    }
  }
end

Monitoring 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

  1. Create integration documentation
  2. Implement service classes with error handling
  3. Add configuration to credentials
  4. Create background jobs for async processing
  5. Implement webhook handlers if needed
  6. Add monitoring and health checks
  7. Write comprehensive tests
  8. 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

On this page