# ๐Ÿ™ Antares Data Exporter
![Octopus ERP Converter](docs/images/Octopus8.ico) **A powerful Rust utility for fetching Antares B2B product data and exporting to Excel** [Features](#features) โ€ข [Installation](#installation) โ€ข [Usage](#usage) โ€ข [Configuration](#configuration) โ€ข [Architecture](#architecture)
--- ## Overview **Antares Data Exporter** is a high-performance Rust utility that seamlessly integrates with the Antares B2B web service to fetch product catalog data and export it to Excel with intelligent field mapping and business rule validation. Perfect for inventory management, data migration, and supply chain automation. ## โœจ Features - ๐Ÿš€ **Fast & Efficient** - Blocking HTTP client with 300-second timeout for reliable operations - ๐Ÿ“Š **Excel Export** - Intelligent field mapping with 8 carefully curated columns - ๐Ÿง  **Smart Row Filtering** - Automatically skips incomplete records based on business rules - ๐Ÿ“ **Dual Logging** - All events logged to both terminal and daily log files - ๐ŸŽฏ **Flexible Output** - Support for custom file paths or directory-based exports - ๐Ÿ” **Secure Credentials** - Environment-based credential management, no hardcoding - ๐Ÿ—๏ธ **Modular Architecture** - Clean separation of concerns for easy extension - ๐Ÿ“ฆ **Auto Directory Creation** - Creates necessary directories on first run ## ๐Ÿ› ๏ธ Technology Stack - **Language:** Rust (2024 edition) - **HTTP Client:** reqwest with blocking mode - **Excel:** rust_xlsxwriter - **Environment:** dotenv - **Date/Time:** chrono ## ๐Ÿ“‹ Prerequisites - Rust 1.70+ (with Cargo) - Valid Antares B2B API credentials (usercode & password) - Write access to create `log/`, `out/`, and `antares.json` at repo root ## ๐Ÿ“ฅ Installation ```bash # Clone the repository git clone https://github.com/yourusername/antares_get_data.git cd antares_get_data # Create .env from template cp .env.example .env # Configure your credentials nano .env # or your favorite editor ``` ## โš™๏ธ Configuration Edit `.env` with your Antares credentials and output preferences: ```env # Antares B2B API credentials ANTARES_USERCODE=your_usercode ANTARES_PASSWORD=your_password_hash # Output path for Excel file # - Directory: Creates 'antares.xlsx' inside # - File path (*.xlsx): Creates file at exact location OUT=out ``` ### OUT Path Examples ```env OUT=out # โ†’ out/antares.xlsx OUT=exports/data.xlsx # โ†’ exports/data.xlsx OUT=/tmp/antares/report.xlsx # โ†’ /tmp/antares/report.xlsx ``` ## ๐Ÿš€ Usage ```bash # Build the project cargo build --release # Run the data exporter cargo run # Or run the compiled binary directly ./target/release/antares_get_data ``` ### What Happens on Execution 1. โœ… **Initialization** - Logger created, output directory prepared 2. ๐Ÿ” **Credential Loading** - Env vars validated and loaded 3. ๐ŸŒ **API Request** - Fetches product data from Antares B2B (300s timeout) 4. ๐Ÿ“Š **Data Processing** - Deserializes JSON into typed structs 5. ๐Ÿ“ **JSON Export** - Saves raw response to `antares.json` 6. ๐Ÿ“‹ **Excel Export** - Generates filtered, formatted Excel file 7. ๐Ÿ“‹ **Logging** - All events logged to `log/YYYY-MM-DD.log` + terminal ## ๐Ÿ“‹ Excel Output The generated Excel file contains 8 columns of curated product data: | Column | Source | Notes | |--------|--------|-------| | BESZCIKKSZAM | cikkszam | Product ID (required) | | GYCIKKSZAM | cikkszam | Duplicate of BESZCIKKSZAM | | BESZCIKKNEV | cikk_megnevezes_rovid / cikk_megnevezes | Product name (required) | | GYARTO | Constant: "EGYEB" | Manufacturer code | | CIKKAZON | vonalkod | Barcode (if available) | | KESZLET | szabad_keszlet | Available stock | | ME | mennyisegi_egyseg_kod | Unit of measure | | EGYSEGAR | netto_kisker_ar / "Alap รกr" | Net unit price | **Filtering Rules:** - Rows are skipped if `BESZCIKKSZAM` is empty - Rows are skipped if both `BESZCIKKNEV` sources are empty - Product name prefers short form (`cikk_megnevezes_rovid`), falls back to full form - Unit price prefers direct field; searches `cikk_jellemzok` for "Alap รกr" if zero ## ๐Ÿ“ Project Structure ``` antares_get_data/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ main.rs # Pipeline orchestration โ”‚ โ”œโ”€โ”€ api/ โ”‚ โ”‚ โ”œโ”€โ”€ mod.rs โ”‚ โ”‚ โ””โ”€โ”€ client.rs # Antares B2B URL builder โ”‚ โ”œโ”€โ”€ tools/ โ”‚ โ”‚ โ”œโ”€โ”€ mod.rs โ”‚ โ”‚ โ”œโ”€โ”€ excel.rs # Excel export with field mapping โ”‚ โ”‚ โ””โ”€โ”€ logger.rs # Dual-output logging system โ”‚ โ””โ”€โ”€ template/ โ”‚ โ”œโ”€โ”€ mod.rs โ”‚ โ””โ”€โ”€ antares.rs # Serde models for API schema โ”œโ”€โ”€ .env.example # Configuration template โ”œโ”€โ”€ Cargo.toml # Rust dependencies โ””โ”€โ”€ README.md # This file ``` ## ๐Ÿ—๏ธ Architecture ### Modular Design - **`src/api/client.rs`** - Builds Antares B2B API URLs - **`src/tools/excel.rs`** - Intelligent Excel export with business rules - **`src/tools/logger.rs`** - Dual logging (terminal + file) to `log/{YYYY-MM-DD}.log` - **`src/template/antares.rs`** - Serde models matching Antares B2B schema - **`src/main.rs`** - Clean orchestration without implementation details ### Pipeline Flow ``` Load Env Vars โ†“ Initialize Logger โ†“ Build API URL โ†“ Fetch from Antares B2B (300s timeout) โ†“ Deserialize JSON โ†’ Save to antares.json โ†“ Export Filtered Data โ†’ Excel (with logging) โ†“ Log Summary + Results ``` ## ๐Ÿ“ Logging All operations are logged to two destinations simultaneously: **Terminal Output:** ``` [2026-04-30 16:30:15] โ„น Starting Antares data export [2026-04-30 16:30:22] โœ“ API call successful - Fetched 142 items [2026-04-30 16:30:25] โœ“ Export successful - 142 rows exported to out/antares_export.xlsx ``` **Log Files:** `log/2026-04-30.log` (daily rotation) ## ๐Ÿงช Development ```bash # Format code cargo fmt --all -- --check # Lint with Clippy cargo clippy --all-targets -- -D warnings # Run tests cargo test # Build optimized release cargo build --release ``` ## ๐Ÿ“ฆ Generated Artifacts After running, you'll find: - **`antares.json`** - Full, pretty-printed API response - **`out/antares_export.xlsx`** - Filtered Excel export (or custom path) - **`log/YYYY-MM-DD.log`** - Daily operation log All are automatically created and git-ignored. ## ๐Ÿ” Security Notes - โœ… Credentials stored only in `.env` (git-ignored) - โœ… `.env.example` documents required variables without secrets - โœ… No hardcoded credentials in source code - โœ… API passwords transmitted over HTTPS only ## ๐Ÿ› Troubleshooting **Missing ANTARES_USERCODE error:** ``` Create .env file in repo root with: ANTARES_USERCODE=your_code ANTARES_PASSWORD=your_password OUT=out ``` **Invalid OUT path error:** ``` Ensure OUT is either: - A directory (created if missing): OUT=out - A .xlsx file: OUT=export/data.xlsx ``` **API timeout:** - Default timeout is 300 seconds (5 minutes) - Check your network connection - Verify Antares B2B service is available ## ๐Ÿ“„ License [Add your license here] ## ๐Ÿค Contributing Contributions welcome! Please follow the module structure and keep the architecture clean. ---
**Built with โค๏ธ for Antares B2B integration**