## Stack and Dependencies

### Runtime Environment

- **Python**: 3.8 (32-bit) for Oracle compatibility
- **Operating System**: Windows 7+ (tested on Windows 11)
- **Oracle Client**: 32-bit required for cx_Oracle

### Core Dependencies

- **cx_Oracle 7.3**: Oracle database connectivity
  - Purpose: Database operations for rate data
  - Risks: Requires 32-bit Oracle client, version compatibility
- **requests**: HTTP client for API calls and file downloads
  - Purpose: External API communication, SQL file retrieval
  - Risks: Network dependency, SSL certificate issues
- **python-dateutil**: Date parsing and manipulation
  - Purpose: Handling date formats in rate data
  - Risks: Minimal, stable library
- **Flask**: Lightweight web framework for HTTP server
  - Purpose: REST API for rate data ingestion
  - Risks: Not in standard library, additional dependency
- **ipaddress**: Python standard library for IP address validation
  - Purpose: IP address format validation and manipulation
  - Risks: Minimal, standard library component
- **schedule**: Job scheduling library
  - Purpose: Automated task execution
  - Risks: Simple library, potential timing issues

### GUI Dependencies

- **tkinter**: Python standard GUI library
  - Purpose: Cross-platform GUI interface
  - Risks: Basic widgets, Windows-specific behavior

### Build and Test Dependencies

- **PyInstaller**: Creates standalone executables
  - Purpose: Distribution packaging
  - Risks: Large executables, antivirus false positives

## Configuration

### Settings Structure

INI file format with sections for different components:

```
[settings]
# Oracle
oracleconnectstring = v8live/live@v8
nls_lang = AMERICAN_AMERICA.CL8MSWIN1251
file_encoding = cp1251

# ExportMailer
hotel_key = HOTEL123
url = http://fidelio.pro/select.sql
block-url = http://fidelio.pro/selectBlocks.sql
sendfrom = folkote@yandex.ru
sendto = metraplex@gmail.com
mailserver = smtp.yandex.ru
port = 465
pwd = hvlmwcrnbafsavjy
ssl = 1

# PriceExport
api_url = https://app.hotellab.io/privat/api/integration/1c/set-pms-prices/5
token = 1111
months = 12
batch_max_size_kb = 1024  # 1MB default batch size
batch_max_days = 30  # Maximum days per batch
deeper_logging = 0  # Enable deeper HTTP request/response logging

# RateLoader
server_port = 8000
auto_start_server = 1

# IP Management
ip_file = ip_access.json
auto_add_new_ips = 1
log_denied_requests = 1
max_tracked_ips = 1000

# Scheduler
schedule_hours = 8,12,15,18,20
```

### Configuration Management

- Auto-creation of missing keys with defaults
- No validation (user responsibility)
- Reload not supported (requires restart)
- File encoding: UTF-8 with BOM

## Build and Test

### Build Process

- **PyInstaller**: Single command to create executable
- **Spec File**: Custom spec for proper packaging
- **Dependencies**: All Python packages bundled
- **Output**: Single .exe file + required DLLs

### Test Strategy

- **Integration Tests**: End-to-end workflow validation
- **GUI Tests**: Interface functionality verification
- **Error Handling Tests**: Resilience under failure conditions
- **Performance Tests**: Stability and resource usage
- **PRD Validation**: Acceptance criteria testing

### Development Environment

- **IDE**: VS Code with Python extensions
- **Version Control**: Git (assumed)
- **Testing**: pytest framework (implied by test files)
- **Documentation**: Markdown files in docs/

## SLAs and Budgets

### Performance Budgets

- **Memory**: 2GB RAM minimum, target < 500MB typical usage
- **CPU**: Minimal background processing
- **Storage**: 200MB disk space, log rotation at 5MB
- **Network**: HTTP timeouts, retry logic for reliability

### Availability Requirements

- **Uptime**: Application stays running through all error conditions
- **Task Execution**: Scheduled tasks complete reliably
- **HTTP Server**: Available when enabled, proper error responses
- **GUI**: Responsive interface, no blocking operations

### Monitoring and Observability

- **Logs**: Single unified rateloader.log file with component prefixes ([EXPORT], [PRICE], [RATELOADER], [GUI], [ORACLE], [SCHEDULER], [HTTP], [QUEUE], [IPMANAGER]) and rotation
- **Health Checks**: HTTP root URL ("/"), /ping and /status endpoints (root URL and /ping return identical responses)
- **Error Reporting**: Comprehensive exception logging with component identification
- **Status Indicators**: GUI shows component states
- **IP Access Control**: JSON-based IP tracking with allow/restrict functionality and global access modes
- **Batched Price Export**: Size-based batching (default 1MB) reduces API requests from 365+ to ~12 batches per year
- **Deeper Logging**: Optional HTTP request/response logging for Price Export with timestamped JSON files in logs/price_export/
