# imran-prog/fadex architecture

> Architecture diagram of the GitHub repository imran-prog/fadex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imran-prog/fadex
- Repository: https://github.com/imran-prog/fadex

## Overview

##### Main Components Identification

The system consists of three main layers:
- Python Interface Layer
- Rust Core Layer
- External Web Resources

##### Key Architectural Elements

a. Core Components (based on src/ directory):
- Crawler Module (crawler.rs)
- Parser Module (parser.rs)
- Library Interface (lib.rs)

**┌─────────────────────────┐**
- Python Application   │
- ┬─────────────┘

**┌─────────────────────────┐**
- PyO3 Bridge      │
- ┬─────────────┘

**┌─────────────┬─────────────┬─────────────┐**
- Crawler    │   Parser    │    Core     │
- Module     │   Module    │    Lib      │
- ┴─────────────┴─────────────┘

**┌─────────────────────────┐**
- Web Resources        │
- ┘

##### Flow Representation

- Python application → PyO3 Bridge (Function calls)
- PyO3 Bridge → Rust Core (Data translation)
- Crawler Module → Web Resources (HTTP requests)
- Parser Module → Crawler Module (HTML processing)

##### Component Details

For each component, include these details:

a. Python Interface:
- Async functions (fetch_page_py)
- Metadata extraction
- Link extraction
- Element selection

b. Rust Core:
- Crawler: Async web requests
- Parser: HTML processing
- Core Lib: PyO3 bindings

##### Additional Elements

Supporting elements:
- Error handling flows
- Async operation indicators
- Data transformation points

##### Performance Metrics

- Response time comparisons
- Memory usage
- Threading model

##### Performance optimization points

Keep the abstraction level focused on the main architectural components while showing the critical performance-related aspects that make Fadex unique.

- Special symbols
- Performance indicators

This will create a comprehensive yet clear visualization of Fadex's architecture, highlighting its key strength: the combination of Python's ease of use with Rust's performance.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Python Application Layer"]
        PythonApp["Python Application"]:::python
        ResultsHandler["Results Handler"]:::python
    end

    subgraph Bridge["Interface Layer"]
        PyO3["PyO3 Bridge"]:::bridge
    end

    subgraph Core["Rust Core Layer"]
        LibInterface["Library Interface"]:::rust
        CrawlerMod["Crawler Module"]:::rust
        ParserMod["Parser Module"]:::rust
    end

    subgraph External["External Layer"]
        WebResources["Web Resources"]:::external
    end

    subgraph Metrics["Performance Metrics"]
        Perf["Response Time: ~100ms
        Memory Usage: Optimized
        Threading: Async"]:::metrics
    end

    %% Connections
    PythonApp --> |"Function Calls"| PyO3
    ResultsHandler --> |"Data Processing"| PyO3
    PyO3 --> |"Data Translation"| LibInterface
    LibInterface --> |"Requests"| CrawlerMod
    LibInterface --> |"Processing"| ParserMod
    CrawlerMod --> |"HTTP Requests"| WebResources
    ParserMod --> |"HTML Processing"| CrawlerMod

    %% Legend
    subgraph Legend["Legend"]
        L1["Python Component"]:::python
        L2["Rust Component"]:::rust
        L3["Bridge Component"]:::bridge
        L4["External Resource"]:::external
        L5["Metrics"]:::metrics
    end

    %% Styles
    classDef python fill:#3776AB,color:#fff,stroke:#2D5F8A
    classDef rust fill:#F74C00,color:#fff,stroke:#B23900
    classDef bridge fill:#808080,color:#fff,stroke:#606060
    classDef external fill:#4CAF50,color:#fff,stroke:#388E3C
    classDef metrics fill:#9C27B0,color:#fff,stroke:#7B1FA2

    %% Click Events
    click CrawlerMod "https://github.com/imran-prog/fadex/blob/master/src/crawler.rs"
    click ParserMod "https://github.com/imran-prog/fadex/blob/master/src/parser.rs"
    click LibInterface "https://github.com/imran-prog/fadex/blob/master/src/lib.rs"
    click PythonApp "https://github.com/imran-prog/fadex/blob/master/pyproject.toml"
    click ResultsHandler "https://github.com/imran-prog/fadex/blob/master/fadex_lxml_results.py"
    click PyO3 "https://github.com/imran-prog/fadex/blob/master/Cargo.toml"
```
