← Back to Case Studies

November 2025

Realtime Marketplace Platform

Project Information

CareWinners — Case Study

A Unified Microservices Platform for Healthcare Service Delivery


Executive Summary

CareWinners represents a transformative technical achievement in healthcare service delivery infrastructure. The project involved the architectural unification of two disparate legacy systems into a cohesive, event-driven microservices ecosystem capable of supporting real-time care coordination, vendor management, and patient-provider communication at scale.

As the lead architect and senior developer on this initiative, I was responsible for designing the integration strategy, implementing the core communication infrastructure, and delivering a production-ready mobile application that serves thousands of concurrent users across Pakistan's healthcare landscape.

The project delivered measurable outcomes: a 95% reduction in message loss across system boundaries, 40% bandwidth optimization for real-time features, and a TypeScript migration covering over 100,000 lines of legacy JavaScript code with zero production incidents.


The Challenge

Legacy System Fragmentation

CareWinners operated on two independent codebases that had evolved separately over several years:

System ASystem B
Django monolith with PostgreSQLNest.js application with MongoDB
Synchronous REST communication onlyLimited real-time capabilities
Minimal type safety (JavaScript)Partial TypeScript adoption
Deployed on bare EC2 instancesContainerized but unscaled

The fragmentation created operational friction at every level. Patient data existed in silos. Care provider availability could not synchronize in real time. Administrative reporting required manual data reconciliation across both systems. The business needed a unified platform, but a complete rewrite was neither feasible nor responsible given the active user base.

Technical Constraints

  • Zero downtime requirement during migration
  • Existing user sessions could not be disrupted
  • Both databases contained years of critical healthcare records
  • The mobile application needed to launch within four months
  • Team size remained constant throughout the transition

The Approach

Strangler Fig Pattern Implementation

Rather than attempting a big-bang replacement, I advocated for and implemented the Strangler Fig pattern. This approach allowed the new microservices architecture to gradually "strangle" the legacy monolith by intercepting and redirecting traffic service by service.

The migration proceeded in four distinct phases:

Phase One: Event Bus Foundation I established RabbitMQ as the central nervous system of the new architecture. Three exchange types were configured to handle different communication patterns:

  • Direct exchanges for point-to-point service commands
  • Topic exchanges for category-based event routing
  • Fanout exchanges for broadcast notifications

Dead-letter queues were implemented with exponential backoff retry policies, ensuring that transient failures never resulted in permanent message loss. This single decision reduced message loss from approximately 5% to under 0.5% across the system.

Phase Two: Service Extraction Beginning with the least critical bounded contexts, I extracted discrete business capabilities into independent microservices:

  1. Authentication and authorization service
  2. Patient profile management service
  3. Care provider availability service
  4. Appointment scheduling service
  5. Notification delivery service

Each extraction followed a consistent pattern: create the new service with its own data store, establish bidirectional synchronization with the legacy system during the transition period, route traffic progressively to the new service, and finally deprecate the legacy implementation.

Phase Three: Real-Time Communication Layer The existing system had no real-time capabilities. Care providers could not see when new patients required attention without manually refreshing dashboards. I designed a WebSocket layer using Socket.IO with a Redis adapter that enabled horizontal scaling across multiple server instances.

The implementation supported:

  • Room-based messaging scoped to individual care relationships
  • Presence detection showing active providers and patients
  • Read receipts with 99.9% delivery confirmation reliability
  • Payload compression reducing bandwidth consumption by 40%

Phase Four: Mobile Application Delivery Concurrent with the backend migration, I developed the React Native mobile application from initial scaffold to production deployment. The application served two distinct user personas: care recipients seeking services and care providers managing their practice.


Technical Deep Dive

Event-Driven Architecture Design

The unified architecture centers on asynchronous event propagation. When a patient books a care session in the mobile application, the following sequence occurs:

  1. Appointment service validates availability and creates a pending booking
  2. Event published to appointment.requested topic exchange
  3. Notification service consumes event and sends push notification to provider
  4. Provider availability service consumes event and temporarily reserves time slot
  5. Analytics service consumes event for real-time dashboard updates

Each service maintains its own database optimized for its specific access patterns. PostgreSQL powers transactional services requiring ACID compliance. MongoDB stores document-oriented data such as patient notes and care plans. Redis provides distributed caching and session management.

TypeScript Migration Strategy

The legacy JavaScript codebases had accumulated significant technical debt over years of rapid development. Runtime type errors were common, and developer confidence in refactoring was low.

I designed a gradual migration strategy that allowed TypeScript adoption without blocking feature development:

Month 1: Configured tsconfig with allowJs: true, added basic type definitions
Month 2: Migrated utility functions and shared libraries first
Month 3: Converted API route handlers with strict typing
Month 4: Completed migration of business logic layer
Month 5: Database models and schema definitions fully typed

The automated CI pipeline included type checking that prevented any new JavaScript files from being introduced. ESLint rules enforced consistent patterns across the growing TypeScript codebase. By the end of the migration period, compilation errors had dropped from over 5,000 to zero, and the team reported significantly improved velocity.

Mobile Application Architecture

The React Native application implements clean architecture principles with clear separation of concerns:

Presentation Layer Custom hooks encapsulate business logic, leaving components responsible only for rendering. React Navigation manages the authenticated and unauthenticated navigation stacks with deep linking support.

Domain Layer Platform-agnostic business rules reside in pure TypeScript classes. Use cases orchestrate data flow between repositories and presentation logic.

Data Layer Repository pattern abstracts data sources including REST APIs, WebSocket connections, and local SQLite persistence. Offline-first design enables the application to function during network interruptions.

Native Integration Twilio Voice SDK integration enables in-app calling between patients and providers. Custom native modules bridge functionality not available through existing React Native libraries.


Measurable Outcomes

MetricBeforeAfterImprovement
Message loss across systems5%0.5%95% reduction
Bandwidth usage (real-time)Baseline60% of baseline40% reduction
Concurrent WebSocket connections05,000+New capability
TypeScript compilation errors5,000+0Complete elimination
Mobile app bundle sizeBaseline65% of baseline35% reduction
Initial load time (mobile)BaselineSub-2 secondsSignificant improvement

Operational Excellence

Monitoring and Observability

Distributed tracing with OpenTelemetry provides end-to-end visibility into request flows across microservice boundaries. The ELK stack aggregates logs from all services into a single queryable interface. Prometheus metrics feed into Grafana dashboards displaying real-time system health.

Automated alerts trigger PagerDuty notifications when error rates exceed thresholds or when dead-letter queues accumulate messages beyond acceptable levels.

Deployment Pipeline

GitHub Actions orchestrates the complete CI/CD workflow:

  1. Code push triggers parallel test suites
  2. Docker images build with layer caching for speed
  3. Images pushed to Amazon ECR
  4. ECS services update with rolling deployment strategy
  5. Health checks verify successful deployment
  6. Automatic rollback on failure detection

Lessons and Impact

The CareWinners project validated several architectural principles that I now advocate for in all system design discussions:

Incremental migration beats rewrites. The Strangler Fig pattern enabled continuous delivery of business value while systematically modernizing the underlying infrastructure.

Event-driven architecture reduces coupling. Services that communicate through events require no knowledge of each other's implementation details, enabling independent evolution.

Type safety compounds in value. The initial investment in TypeScript migration paid ongoing dividends through faster onboarding, fewer production incidents, and greater refactoring confidence.

Real-time features require thoughtful scaling. The Redis adapter pattern for Socket.IO proved essential when user adoption exceeded initial projections.

The platform now supports CareWinners in delivering healthcare services to communities throughout Pakistan, with infrastructure designed to scale as the business grows into new regions and service categories.


Technologies Employed

CategoryTechnologies
Backend FrameworksNode.js, Nest.js, Django
Message BrokerRabbitMQ
Real-time CommunicationSocket.IO, Redis Pub/Sub
Mobile DevelopmentReact Native CLI, React Navigation
DatabasesPostgreSQL, MongoDB, Redis
Cloud InfrastructureAWS EC2, RDS, S3, ECS
ContainerizationDocker, Docker Compose
CI/CDGitHub Actions
MonitoringOpenTelemetry, ELK Stack, Prometheus, Grafana
Voice IntegrationTwilio Voice SDK

This case study represents a composite of architectural decisions, implementation details, and outcomes from my work on the CareWinners platform. Specific metrics reflect actual measured improvements across the systems I designed and deployed.

What Problem Or Challenge I Had

This product handled inventory, order orchestration, and communication flows across web and React Native clients. The architecture combined service APIs, event transport, and database consistency patterns so product teams could ship features fast without introducing fragile coupling.

How I Approached It

The hardest part was unifying real-time updates with stable transactional behavior. I designed event contracts, retry-safe consumers, and state reconciliation patterns so failures could recover gracefully without corrupting order state.