# Hooks Comment Signal Service

A real-time stream processing service built on Apache Flink that tracks user engagement signals related to hook comments.

## Overview

This service processes comment-related events from hooks (short video clips) and stores engagement signals in Redis. The signals are used by recommendation systems to understand user preferences and engagement patterns.

## Features

### Event Processing
- **Hook Comment Events**: Tracks when users comment on hooks via `EventNames.HookComment.value`
- **Comment Signals**: Stores user engagement signals based on commenting behavior

### Data Storage
The service stores the following data in Redis:

#### User Comment Signals
- `hooks_positive_signal_comment:{user_id}` - Sorted set of hooks the user has commented on (timestamp as score)
  - **Size Limit**: Automatically trimmed to keep only the most recent 100 entries

## Event Schema

The service expects events with the following structure:

```json
{
  "name": "HookComment",
  "timestamp": "2024-01-01T00:00:00Z",
  "source": "hooks_app",
  "user_id": "12345",
  "session_id": "session_abc",
  "properties": {
    "hook_id": "hook_123",
    "hook_status": "complete",
    "recommendation_item_id": "rec_456"
  },
  "request_id": "req_789"
}
```

## Configuration

The service supports both local development and cloud deployment configurations:

### Local Development
- Stream ARN: Points to development Kinesis stream
- Redis: localhost:6379
- Environment: dev

### Production/Staging
- Stream ARN: Retrieved from CDK runtime properties
- Redis: Retrieved from CDK runtime properties
- Environment: prod/staging

## Running the Service

### Local Development
```bash
python main.py
```

### Production Deployment
The service is deployed via AWS CDK as a Kinesis Analytics application.

## Dependencies

- Apache Flink (PyFlink)
- Redis Python client
- AWS Kinesis connector for Flink

## Monitoring

The service outputs processing logs with the identifier `HOOK-COMMENT-EVENTS` for monitoring and debugging.
