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 A | System B |
|---|---|
| Django monolith with PostgreSQL | Nest.js application with MongoDB |
| Synchronous REST communication only | Limited real-time capabilities |
| Minimal type safety (JavaScript) | Partial TypeScript adoption |
| Deployed on bare EC2 instances | Containerized 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:
- Authentication and authorization service
- Patient profile management service
- Care provider availability service
- Appointment scheduling service
- 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:
- Appointment service validates availability and creates a pending booking
- Event published to
appointment.requestedtopic exchange - Notification service consumes event and sends push notification to provider
- Provider availability service consumes event and temporarily reserves time slot
- 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
| Metric | Before | After | Improvement |
|---|---|---|---|
| Message loss across systems | 5% | 0.5% | 95% reduction |
| Bandwidth usage (real-time) | Baseline | 60% of baseline | 40% reduction |
| Concurrent WebSocket connections | 0 | 5,000+ | New capability |
| TypeScript compilation errors | 5,000+ | 0 | Complete elimination |
| Mobile app bundle size | Baseline | 65% of baseline | 35% reduction |
| Initial load time (mobile) | Baseline | Sub-2 seconds | Significant 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:
- Code push triggers parallel test suites
- Docker images build with layer caching for speed
- Images pushed to Amazon ECR
- ECS services update with rolling deployment strategy
- Health checks verify successful deployment
- 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
| Category | Technologies |
|---|---|
| Backend Frameworks | Node.js, Nest.js, Django |
| Message Broker | RabbitMQ |
| Real-time Communication | Socket.IO, Redis Pub/Sub |
| Mobile Development | React Native CLI, React Navigation |
| Databases | PostgreSQL, MongoDB, Redis |
| Cloud Infrastructure | AWS EC2, RDS, S3, ECS |
| Containerization | Docker, Docker Compose |
| CI/CD | GitHub Actions |
| Monitoring | OpenTelemetry, ELK Stack, Prometheus, Grafana |
| Voice Integration | Twilio 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.