# Project Overview

This project, `sme-feed-file-export`, is a Python-based ETL (Extract, Transform, Load) tool designed to process "STARS" data from a Snowflake database for Sony Music Entertainment (SME). The main purpose is to extract data from a specified Snowflake view, split it into per-store files based on various processing modes, and format them with headers and footers. The generated files are then compressed into a zip archive and can be optionally uploaded to an SFTP server.

The application is configured primarily through environment variables, with different `PROCESS_MODE` settings (`US`, `GB`, `AGGREGATE`, etc.) to handle different feed types. The core logic is contained in `feed_file_exporter.py`, which orchestrates the entire ETL process.

## Building and Running

### Dependencies

The project uses Python and its dependencies are listed in `requirements.txt`. To install them, you can use pip:

```bash
pip install -r requirements.txt
```

### Running the Application

The application is run from the command line using `feed_file_exporter.py`. The behavior of the script is controlled by environment variables. The `README.md` file contains a comprehensive list of these variables.

Here's a basic example of how to run the script:

```bash
# Set the required environment variables
export ENVIRONMENT=DEV
export SNOWFLAKE_SOURCE_TABLE=<your_source_table>
export PERIOD_ID=<your_period_id>
# ... and other necessary variables

# Run the script
python feed_file_exporter.py
```

For local development, the script supports interactive prompts for missing environment variables and command-line arguments to override certain settings, especially for SFTP.

### Testing

The project uses `pytest` for testing. The tests are located in the `tests/` directory. To run the tests, you can use the following command:

```bash
pytest
```

## Development Conventions

*   **Configuration:** The application heavily relies on environment variables for configuration. This is a good practice for separating configuration from code. The `config.py` file likely contains default values and logic for handling these variables.
*   **Modularity:** The code is organized into several modules with distinct responsibilities:
    *   `feed_file_exporter.py`: Main application logic.
    *   `sftp_transfer.py`: Handles SFTP file transfers.
    *   `snowflake_proxy/`: Likely contains the logic for interacting with Snowflake.
    *   `models/`: Contains data models and queries for Snowflake.
    *   `constants/`: Defines application-wide constants.
*   **Testing:** The presence of a `tests/` directory and a `pytest.ini` file indicates that the project uses `pytest` for unit testing.
*   **Interactive Development:** The script includes features to enhance the local development experience, such as interactive prompts for missing environment variables and command-line overrides.
*   **Asynchronous Keepalive:** The use of a background process to "keep the environment alive" suggests that the application might be deployed in an environment that terminates long-running idle processes.
