# masbug/etoro-edavki architecture

> Architecture diagram of the GitHub repository masbug/etoro-edavki, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/masbug/etoro-edavki
- Repository: https://github.com/masbug/etoro-edavki

## Overview

##### Project type and purpose
- This is a single-module, command-line Python tool (`etoro_edavki.py`) packaged via `setup.py`.
- Purpose: ingest an Excel account-statement from eToro, fetch FX rates, transform and export XML forms (Doh-KDVP, D-IFI, Doh-Div) plus debug XLSX files for import into Slovenia’s eDavki system.

##### File structure
- Top‐level files:
- `etoro_edavki.py` – main CLI script + core logic
- `requirements.txt` – Python dependencies
- `setup.py` – package entry point
- `Company_info.xlsx` (named in README as `Naslovi_info.xlsx`): manual lookup of issuer info
- `LICENSE`, `README.md`, `.gitignore`, plus an optional Excel template
- No separate “src” or “lib” folders: all logic in one module.
- No web UI or services beyond an HTTP call to Banka Slovenije for FX rates.

##### Extract insights from the README
- Dependencies (likely `pandas` or `openpyxl`, `requests`, `lxml` or similar).
- Workflow:
1. CLI parses arguments (`argparse` or `click`).
2. Load eToro XLSX.
3. Fetch FX table from Banka Slovenije.
4. Convert each transaction: group by form type.
5. Generate XML files and two debug XLSX files in `output/`.
6. User imports XML into eDavki and completes missing fields (e.g., issuer info).

##### Key components
a. Main Components
- CLI Entrypoint (etoro-edavki)
- Excel Parser (reads eToroAccountStatement)
- FX Rate Fetcher (calls Banka SI API)
- Data Processor / Mapper (classifies transactions per form)
- XML Generator (creates Doh-KDVP.xml, D-IFI.xml, Doh-Div.xml)
- Debug Excel Generator (Dividende-info, Debug)
- Configuration/Manual Data (Company_info.xlsx)
- Output Folder (`/output`)
b. Relationships & Data Flows
- User invokes CLI → CLI Entrypoint
- CLI → Excel Parser (reads XLSX)
- CLI → FX Rate Fetcher → returns rate table
- Parser + Rates → Data Processor → splits by form type
- Data Processor → XML Generator → writes XML files to `output/`
- Data Processor → Debug Excel Generator → writes debug XLSX to `output/`
- XMLs / XLSX → imported by user into eDavki
c. Architectural Patterns & Principles
- Single-responsibility: separate parsing, rate fetching, processing, and output generation
- Modular design within one script (could be refactored into distinct modules)
- External dependency isolation (HTTP calls and file I/O)
d. Key Technologies & Libraries
- Python 3.x
- argparse or click for CLI
- pandas / openpyxl for Excel I/O
- requests for HTTP
- lxml or built-in `xml.etree` for XML serialization

##### Detail level
- Step of the CLI pipeline
- External dependencies (HTTP API, manual Excel)
- Don’t overcomplicate: you’re documenting a linear ETL-like workflow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CLI Tool"
        CLI["CLI Entrypoint\n(etoro_edavki.py)"]:::internal
        Parser["Excel Parser"]:::internal
        Fetcher["FX Rate Fetcher"]:::internal
        Processor["Data Processor / Mapper"]:::internal
        XMLGen["XML Generator"]:::internal
        DebugGen["Debug Excel Generator"]:::internal
    end

    Config["Manual Data\n(Company_info.xlsx)"]:::io
    Output["Output Folder\n(./output/)"]:::io
    API["Banka Slovenije API"]:::external
    User["User"]:::external
    eDavki["eDavki UI"]:::external

    User -->|"runs CLI"| CLI
    CLI -->|"reads transactions"| Parser
    CLI -->|"reads manual data"| Config
    CLI -->|"fetches rates"| Fetcher
    Fetcher -->|"rate table"| Processor
    Parser -->|"transactions"| Processor
    Processor -->|"classified data"| XMLGen
    Processor -->|"classified data"| DebugGen
    XMLGen -->|"XML files"| Output
    DebugGen -->|"XLSX files"| Output
    Output -->|"user imports"| eDavki
    CLI -->|"uses API"| API

    subgraph "Project Files"
        Req["requirements.txt"]:::docs
        Setup["setup.py"]:::docs
        Readme["README.md"]:::docs
        License["LICENSE"]:::docs
    end

    click CLI "https://github.com/masbug/etoro-edavki/blob/main/etoro_edavki.py"
    click Parser "https://github.com/masbug/etoro-edavki/blob/main/etoro_edavki.py"
    click Fetcher "https://github.com/masbug/etoro-edavki/blob/main/etoro_edavki.py"
    click Processor "https://github.com/masbug/etoro-edavki/blob/main/etoro_edavki.py"
    click XMLGen "https://github.com/masbug/etoro-edavki/blob/main/etoro_edavki.py"
    click DebugGen "https://github.com/masbug/etoro-edavki/blob/main/etoro_edavki.py"
    click Config "https://github.com/masbug/etoro-edavki/blob/main/Company_info.xlsx"
    click Output "https://github.com/masbug/etoro-edavki/tree/main/./output/"
    click Req "https://github.com/masbug/etoro-edavki/blob/main/requirements.txt"
    click Setup "https://github.com/masbug/etoro-edavki/blob/main/setup.py"
    click Readme "https://github.com/masbug/etoro-edavki/blob/main/README.md"
    click License "https://github.com/masbug/etoro-edavki/tree/main/LICENSE"

    classDef internal fill:#cfe2f3,stroke:#000
    classDef external fill:#d5e8d4,stroke:#000
    classDef io fill:#fde9d9,stroke:#000
    classDef docs fill:#f3f3f3,stroke:#000
```
