# oumansour1024/mubawab-scraper architecture

> Architecture diagram of the GitHub repository oumansour1024/mubawab-scraper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oumansour1024/mubawab-scraper
- Repository: https://github.com/oumansour1024/mubawab-scraper

## Overview

This is a Python/Selenium scraper for Mubawab real-estate listings. The main workflow is CLI selection, city URL construction, paginated listing extraction, detail enrichment, SQLite persistence, and flat-file export. A separate city-discovery workflow collects footer city links for later scraping. The graph reflects sampled orchestration and scraper code plus SOURCE INDEX references; some parser and retry internals were not excerpted, so their uncertain wiring is omitted.

Main entry points: [`src/mubawab_scraper/pipeline/orchestrator.py`](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/pipeline/orchestrator.py) (Listing orchestrator), [`src/mubawab_scraper/pipeline/orchestratior_ville.py`](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/pipeline/orchestratior_ville.py) (City discovery orchestrator), [`src/mubawab_scraper/scrapers/search.py`](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/search.py) (Paginated search), [`src/mubawab_scraper/scrapers/detail.py`](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/detail.py) (Detail enrichment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and configuration"]
  node_cli["Scraper CLI<br/>[cli.py]"]
  node_config["Settings<br/>[config.py]"]
  node_logging["Logging<br/>[logging_config.py]"]
end

subgraph group_collection["Collection"]
  node_listing_pipeline["Listing orchestrator<br/>[orchestrator.py]"]
  node_city_pipeline["City discovery orchestrator"]
  node_url_builder["Search URL builder<br/>[urls.py]"]
  node_browser["Chrome driver<br/>[driver.py]"]
  node_waits["Page waits<br/>[waits.py]"]
  node_search_scraper["Paginated search<br/>[search.py]"]
  node_detail_scraper["Detail enrichment<br/>[detail.py]"]
  node_city_scraper["City link discovery"]
  node_rate_limit["Rate limiting<br/>[rate_limit.py]"]
  node_retry["Retry helper<br/>[retry.py]"]
end

subgraph group_parsing["Parsing and models"]
  node_card_parser["Listing card parser<br/>[card_parser.py]"]
  node_pagination_parser["Pagination parser"]
  node_detail_parser["Listing detail parser<br/>[detail_parser.py]"]
  node_list_parser["List parser<br/>[list_parser.py]"]
  node_parser_helpers["Parser helpers<br/>[helpers.py]"]
  node_models["Listing and city models<br/>[models.py]"]
end

subgraph group_persistence["Persistence and export"]
  node_sqlite[("SQLite store<br/>[sqlite_store.py]")]
  node_csv_export["Flat-file export<br/>[csv_store.py]"]
end

node_user(("Operator"))
node_mubawab{{"Mubawab website"}}
node_analyst(("Analytics consumers"))

node_user -->|"runs commands"| node_cli
node_cli -->|"starts scraping"| node_listing_pipeline
node_cli -->|"discovers cities"| node_city_pipeline
node_cli -->|"reads defaults"| node_config
node_listing_pipeline -->|"reads settings"| node_config
node_listing_pipeline -->|"builds city URL"| node_url_builder
node_listing_pipeline -->|"opens browser"| node_browser
node_listing_pipeline -->|"scrapes pages"| node_search_scraper
node_listing_pipeline -->|"enriches listings"| node_detail_scraper
node_listing_pipeline -->|"loads listings"| node_sqlite
node_listing_pipeline -->|"exports records"| node_csv_export
node_listing_pipeline -->|"logs progress"| node_logging
node_city_pipeline -->|"builds search URL"| node_url_builder
node_city_pipeline -->|"opens browser"| node_browser
node_city_pipeline -->|"collects city links"| node_city_scraper
node_city_pipeline -->|"saves cities"| node_sqlite
node_city_pipeline -->|"exports cities"| node_csv_export
node_search_scraper -->|"fetches listing pages"| node_mubawab
node_search_scraper -->|"waits for results"| node_waits
node_search_scraper -->|"parses cards"| node_card_parser
node_search_scraper -->|"reads pagination"| node_pagination_parser
node_search_scraper -->|"pauses between pages"| node_rate_limit
node_detail_scraper -->|"fetches listing details"| node_mubawab
node_detail_scraper -->|"waits for details"| node_waits
node_detail_scraper -->|"parses details"| node_detail_parser
node_detail_scraper -->|"limits requests"| node_rate_limit
node_detail_scraper -->|"retries failures"| node_retry
node_city_scraper -->|"fetches city links"| node_mubawab
node_city_scraper -->|"waits for footer"| node_waits
node_city_scraper -->|"creates city records"| node_models
node_card_parser -->|"uses helpers"| node_parser_helpers
node_sqlite -->|"stores city records"| node_models
node_sqlite -.->|"provides query data"| node_csv_export
node_analyst -.->|"consumes exports"| node_csv_export

click node_cli "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/cli.py"
click node_config "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/config.py"
click node_logging "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/logging_config.py"
click node_listing_pipeline "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/pipeline/orchestrator.py"
click node_city_pipeline "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/pipeline/orchestratior_ville.py"
click node_url_builder "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/utils/urls.py"
click node_browser "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/browser/driver.py"
click node_waits "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/browser/waits.py"
click node_search_scraper "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/search.py"
click node_detail_scraper "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/detail.py"
click node_city_scraper "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/search_ville_url.py"
click node_rate_limit "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/utils/rate_limit.py"
click node_retry "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/utils/retry.py"
click node_card_parser "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/card_parser.py"
click node_pagination_parser "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/pagination_parser.py"
click node_detail_parser "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/detail_parser.py"
click node_list_parser "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/list_parser.py"
click node_parser_helpers "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/helpers.py"
click node_models "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/models.py"
click node_sqlite "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/storage/sqlite_store.py"
click node_csv_export "https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/storage/csv_store.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_config,node_logging toneBlue
class node_listing_pipeline,node_city_pipeline,node_url_builder,node_browser,node_waits,node_search_scraper,node_detail_scraper,node_city_scraper,node_rate_limit,node_retry toneAmber
class node_card_parser,node_pagination_parser,node_detail_parser,node_list_parser,node_parser_helpers,node_models toneMint
class node_sqlite,node_csv_export toneRose
class node_user,node_mubawab,node_analyst toneIndigo
```

## Components

### Entry and configuration

- [Scraper CLI](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/cli.py): `src/mubawab_scraper/cli.py`
- [Settings](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/config.py): `src/mubawab_scraper/config.py`
- [Logging](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/logging_config.py): `src/mubawab_scraper/logging_config.py`

### Collection

- [Listing orchestrator](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/pipeline/orchestrator.py): `src/mubawab_scraper/pipeline/orchestrator.py`
- [City discovery orchestrator](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/pipeline/orchestratior_ville.py): `src/mubawab_scraper/pipeline/orchestratior_ville.py`
- [Search URL builder](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/utils/urls.py): `src/mubawab_scraper/utils/urls.py`
- [Chrome driver](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/browser/driver.py): `src/mubawab_scraper/browser/driver.py`
- [Page waits](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/browser/waits.py): `src/mubawab_scraper/browser/waits.py`
- [Paginated search](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/search.py): `src/mubawab_scraper/scrapers/search.py`
- [Detail enrichment](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/detail.py): `src/mubawab_scraper/scrapers/detail.py`
- [City link discovery](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/scrapers/search_ville_url.py): `src/mubawab_scraper/scrapers/search_ville_url.py`
- [Rate limiting](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/utils/rate_limit.py): `src/mubawab_scraper/utils/rate_limit.py`
- [Retry helper](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/utils/retry.py): `src/mubawab_scraper/utils/retry.py`

### Parsing and models

- [Listing card parser](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/card_parser.py): `src/mubawab_scraper/parsers/card_parser.py`
- [Pagination parser](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/pagination_parser.py): `src/mubawab_scraper/parsers/pagination_parser.py`
- [Listing detail parser](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/detail_parser.py): `src/mubawab_scraper/parsers/detail_parser.py`
- [List parser](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/list_parser.py): `src/mubawab_scraper/parsers/list_parser.py`
- [Parser helpers](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/parsers/helpers.py): `src/mubawab_scraper/parsers/helpers.py`
- [Listing and city models](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/models.py): `src/mubawab_scraper/models.py`

### Persistence and export

- [SQLite store](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/storage/sqlite_store.py): `src/mubawab_scraper/storage/sqlite_store.py`
- [Flat-file export](https://github.com/oumansour1024/mubawab-scraper/blob/main/src/mubawab_scraper/storage/csv_store.py): `src/mubawab_scraper/storage/csv_store.py`

### Other components

- **Operator**
- **Mubawab website**
- **Analytics consumers**

## Connections

- Operator → Scraper CLI: runs commands (evidence: `src/mubawab_scraper/cli.py`)
- Scraper CLI → Listing orchestrator: starts scraping (evidence: `src/mubawab_scraper/cli.py`)
- Scraper CLI → City discovery orchestrator: discovers cities (evidence: `src/mubawab_scraper/cli.py`)
- Scraper CLI → Settings: reads defaults (evidence: `src/mubawab_scraper/cli.py`)
- Listing orchestrator → Settings: reads settings (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- Listing orchestrator → Search URL builder: builds city URL (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- Listing orchestrator → Chrome driver: opens browser (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- Listing orchestrator → Paginated search: scrapes pages (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- Listing orchestrator → Detail enrichment: enriches listings (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- Listing orchestrator → SQLite store: loads listings (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- Listing orchestrator → Flat-file export: exports records (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- Listing orchestrator → Logging: logs progress (evidence: `src/mubawab_scraper/pipeline/orchestrator.py`)
- City discovery orchestrator → Search URL builder: builds search URL (evidence: `src/mubawab_scraper/pipeline/orchestratior_ville.py`)
- City discovery orchestrator → Chrome driver: opens browser (evidence: `src/mubawab_scraper/pipeline/orchestratior_ville.py`)
- City discovery orchestrator → City link discovery: collects city links (evidence: `src/mubawab_scraper/pipeline/orchestratior_ville.py`)
- City discovery orchestrator → SQLite store: saves cities (evidence: `src/mubawab_scraper/pipeline/orchestratior_ville.py`)
- City discovery orchestrator → Flat-file export: exports cities (evidence: `src/mubawab_scraper/pipeline/orchestratior_ville.py`)
- Paginated search → Mubawab website: fetches listing pages (evidence: `src/mubawab_scraper/scrapers/search.py`)
- Paginated search → Page waits: waits for results (evidence: `src/mubawab_scraper/scrapers/search.py`)
- Paginated search → Listing card parser: parses cards (evidence: `src/mubawab_scraper/scrapers/search.py`)
- Paginated search → Pagination parser: reads pagination (evidence: `src/mubawab_scraper/scrapers/search.py`)
- Paginated search → Rate limiting: pauses between pages (evidence: `src/mubawab_scraper/scrapers/search.py`)
- Detail enrichment → Mubawab website: fetches listing details (evidence: `src/mubawab_scraper/scrapers/detail.py`)
- Detail enrichment → Page waits: waits for details (evidence: `src/mubawab_scraper/scrapers/detail.py`)
- Detail enrichment → Listing detail parser: parses details (evidence: `src/mubawab_scraper/scrapers/detail.py`)
- Detail enrichment → Rate limiting: limits requests (evidence: `src/mubawab_scraper/scrapers/detail.py`)
- Detail enrichment → Retry helper: retries failures (evidence: `src/mubawab_scraper/scrapers/detail.py`)
- City link discovery → Mubawab website: fetches city links (evidence: `src/mubawab_scraper/scrapers/search_ville_url.py`)
- City link discovery → Page waits: waits for footer (evidence: `src/mubawab_scraper/scrapers/search_ville_url.py`)
- City link discovery → Listing and city models: creates city records (evidence: `src/mubawab_scraper/scrapers/search_ville_url.py`)
- Listing card parser → Parser helpers: uses helpers (evidence: `src/mubawab_scraper/parsers/card_parser.py`)
- SQLite store → Listing and city models: stores city records (evidence: `src/mubawab_scraper/storage/sqlite_store.py`)
- SQLite store → Flat-file export: provides query data
- Analytics consumers → Flat-file export: consumes exports (evidence: `README.md`)
