## Problem

Hotel operators need to manage rate data across multiple systems and processes, currently handled by three separate legacy utilities that require manual coordination and lack unified monitoring. The existing tools (ExportMailer for CSV/email, PriceExport for API, RateLoader for HTTP) operate independently, leading to operational inefficiencies, error-prone manual processes, and limited visibility into system health and performance.

## Goals

- Provide a single, cohesive application that unifies all rate management operations
- Enable both automated background processing and manual GUI-driven operations
- Ensure reliable, scheduled execution of all rate-related tasks
- Deliver comprehensive monitoring and logging capabilities
- Maintain backward compatibility with existing data formats and APIs
- Support easy deployment via standalone executable

## User Stories

- As a hotel operator, I want to manually trigger CSV exports and email delivery so that I can send rate data on-demand without waiting for scheduled runs
- As a hotel operator, I want to manually export price data to the API so that I can push updates immediately when needed
- As a hotel operator, I want to monitor the HTTP server status and control its operation so that I can ensure rate loading is available when required
- As a hotel operator, I want to view real-time logs from all components so that I can troubleshoot issues and verify operations
- As an IT administrator, I want to configure all settings through a GUI so that I can easily manage the application without editing configuration files
- As an IT administrator, I want the application to run automatically in the background so that scheduled tasks execute reliably without user intervention
- As a support technician, I want comprehensive error logging and graceful failure handling so that I can diagnose and resolve issues quickly

## Scheduler Implementation Details

### Architecture

- **Scheduler** (`core/scheduler.py`): 30-second wake intervals, checks scheduled hours (default: 8,12,15,18,20)
- **Task Queue** (`core/task_queue.py`): FIFO queue with single worker thread for sequential execution
- **Tasks** (`core/tasks.py`): ExportMailerTask and PriceExportTask with error handling
- **Mailer** (`core/mailer.py`): SMTP with SSL/TLS support, maintains PRD §2.1 compatibility
- **ExportMailer** (`features/export_mailer.py`): CSV export workflow with compression and fallback handling

### Key Features

- **Reliable Timing**: 30-second wake cycles ensure scheduled execution
- **Sequential Processing**: Single-threaded task execution prevents resource conflicts
- **Error Resilience**: Continues operation through individual task failures
- **Thread Safety**: Proper synchronization and daemon thread management
- **Configuration Integration**: Schedule hours from `settings.ini`

### Email System

- **Legacy Compatibility**: Exact PRD §2.1 signature maintained
- **Attachment Handling**: Automatic compression for files >20MB
- **Error Recovery**: Fallback to local SQL files if downloads fail
- **Comprehensive Logging**: Detailed SMTP transaction logging

### Current Limitations (To Be Addressed)

- **Configuration Reload**: Scheduler doesn't automatically reload config changes during runtime
- **Limited Monitoring**: No built-in metrics for last run time, next scheduled time, or execution logs
- **Settings Loading**: Configuration not refreshed on each execution cycle

## UX Principles

- **Simplicity**: Single application with clear tabbed interface for different functions
- **Visibility**: Real-time status indicators and log viewing for all operations
- **Reliability**: Application stays running through errors, with clear error reporting
- **Consistency**: Maintain existing data formats and workflows where possible
- **Accessibility**: Windows-native GUI with standard controls and clear labeling
- **Feedback**: Immediate visual feedback for all user actions and system status
