diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..9917040 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,30 @@ +# Antares Data Exporter - Operational Guide for Agents + +This repository contains a synchronous Rust utility that fetches product data from the Antares B2B API and exports it to Excel. Follow these instructions for successful operation and development. + +## โš™๏ธ Execution & Setup +1. **Setup:** Always run `cp .env.example .env` first, then fill credentials in `.env`. +2. **Build/Run Order:** The intended command sequence is: `cargo build --release` followed by running the binary (`./target/release/antares_get_data`). +3. **Development Flow:** Use this order when developing or verifying changes: + * `cargo fmt --all -- --check` (Linting) + - `cargo check` (Compile/Verify) + * `cargo test` (Testing) + +## ๐Ÿ’ป Architecture & Quirks +* **Blocking HTTP:** The API client uses `reqwest::blocking::Client`. This is intentional; the entire process is synchronous, and a 300-second timeout must be respected. +* **Credentials:** Only use `ANTARES_USERCODE` and `ANTARES_PASSWORD` from `.env`. Hardcoding credentials is prohibited. +* **Artifacts (Persistence):** Three key artifacts are generated daily/per run: + 1. `antares.json`: Raw API response data. Saved at the repo root. + 2. `out/antares_export.xlsx`: Final Excel export. The `out/` directory must exist. + 3. `log/{YYYY-MM-DD}.log`: Daily operational logs. The `log/` directory must exist. + +## ๐Ÿ“Š Business Logic (Excel Export Rules) +The Excel sheet does not use a simple JSON dump; it implements specific business rules: +* **Required Fields:** Rows are skipped if the product code (`cikkszam`) or product name is missing. +* **Column Mapping Precedence:** + * `BESZCIKKNEV`: Use `cikk_megnevezes_rovid`, falling back to `cikk_megnevezes`. + * `EGYSEGAR`: Prefer `netto_kisker_ar`. If zero, check the product description (`cikk_jellemzok`) for an entry matching `"Alap รกr"`. + +## ๐Ÿ—‚๏ธ Module Ownership +* **Schema Changes:** Always update struct definitions in `src/template/antares.rs` before making changes to data handling logic. +* **Tooling:** New utility functions (e.g., CSV export) should be added as self-contained modules within `src/tools/`. \ No newline at end of file