# Hooks Comment View Signal Service

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

## Overview

This service processes comment view-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 based on comment viewing behavior.

## Features

### Event Processing
- **Hook Get Comment Events**: Tracks when users view/retrieve comments on hooks via `EventNames.HookGetComment.value`
- **Comment View Signals**: Stores user engagement signals based on comment viewing behavior

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

#### User Comment View Signals
- `hooks_positive_signal_comment_view:{user_id}` - Sorted set of hooks where the user has viewed comments (timestamp as score)
  - **Size Limit**: Automatically trimmed to keep only the most recent 200 entries

## Event Schema

The service expects events with the following structure:

```json
{
  "name": "HookGetComment",
  "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-GET-COMMENT-EVENTS` for monitoring and debugging.

## Related Services

This service works alongside:
- `hooks-comment-signal`: Tracks comment creation events
- Other hook engagement signal services for comprehensive user behavior tracking
