Engineering
Deep Dives

A comprehensive look into the technical challenges, architecture decisions, and system designs implemented in real-world production environments.

Architecture
Event-Driven
Performance
Redis Backed
Reliability
99.9% Up-time

Webhook & Asynchronous Notification System

Backend Architecture

Developed an internal "Webhook-like" event system for the Arep-API ecosystem, designed to handle multi-channel asynchronous notifications (Push, SMS, Email).

View Arep-API

Listener

Middleware intercepts req/res

Queue

Redis-backed Bull queue

Processor

Asynchronous job execution

The Listener: Notification Middleware

The middleware acts as the receiver for internal events, listening for successful (200/201) API responses to trigger the flow without blocking the main request cycle.

typescript
@Injectable()
export class NotificationMiddleware implements NestMiddleware {
  async use(req: Request, res: Response, next: NextFunction) {
    const endpoint = req.originalUrl.split('/api/')[1];
    const eventName = `${endpoint}_${req.method.toLowerCase()}`;

    res.on('finish', async () => {
      if (res.statusCode === 200 || res.statusCode === 201) {
        await this.notificationQueue.add(JobName.PROCESS_NOTIFICATION, {
          notification,
          targetUsers,
        });
      }
    });
    next();
  }
}
The "Messy Part": Dynamic Extraction

"The biggest challenge was extracting target user IDs dynamically across varying endpoint structures (params vs body vs session). I solved it by creating a centralized probe helper that normalizes naming conventions like userId vs id."

Booking System & iCal Synchronization

Third-Party Integration

Implemented as a core feature for the Aroovia Platform, handling third-party integrations with Airbnb and Booking.com.

Adapter PatternIdempotent LogicObservabilityRetry Mechanism
The Critical Bug

Airbnb's iCal feed marked dates outside the current year as booked without documentation, leading to false unavailability across the system.

Implementation: The Adapter Pattern
typescript
class AirbnbICalAdapter {
  private isValid(event) {
    const now = new Date();
    const max = new Date();
    max.setFullYear(now.getFullYear() + 1);
    
    // Explicitly filtering non-documented overflow dates
    return event.start >= now && event.end <= max;
  }

  parse(rawData: string) {
    return parseICal(rawData)
      .filter(this.isValid)
      .map(this.normalize);
  }
}
Idempotent Processing

Ensuring repetitive sync cycles don't duplicate bookings or trigger redundant notifications.

Anomalous Spike Detection

Alerting engineers when a property suddenly shows 100% occupancy via a feed sync.