# Initial Setup & Backend Implementation

## Operations Log

### Configuration & Code Update
- **Action**: Updated codebase to support advanced environment configurations.
- **Details**:
  - Updated `src/config/config.js` to read SASL and SSL configurations from `.env`.
  - Updated `src/kafka/consumer.js` to support SASL authentication.
  - Updated `src/db/databaseManager.js` to support PostgreSQL SSL connections.
  - Verified `.env` integration with `dotenv`.

### Backend Component Construction
- **Action**: Initialized backend scaffolding and core implementation.
- **Details**:
  - Created project structure under `bls-rcu-action-backend`.
  - Implemented `DatabaseManager` with connection pooling.
  - Implemented `KafkaConsumer` with error handling.
  - Implemented `RedisIntegration` for heartbeats and error logging.
  - Added Docker and PM2 configuration files.

### Documentation Updates
- **Action**: Refined data schema and documentation.
- **Details**:
  - **Schema Changes**:
    - `room_id`: Changed to `VARCHAR(32)` (String).
    - `direction`: Changed to `VARCHAR(10)` (String: "上传"/"下发").
    - `cmd_word`: Changed to `VARCHAR(10)` (String: "0x36").
    - Added `extra` field (JSONB) for raw communication data.
    - Defined Primary Key: 32-bit Unsigned UUID (`guid`).
    - Defined Composite Key logic: `ts_ms` (Key1) + `guid` (Key2).
  - **Indices**: Marked `hotel_id`, `room_id`, `direction`, `cmd_word` for indexing.
  - **Kafka Format**: Created `docs/kafka_format.md` with updated JSON reference.
