# roshanalokhande/bms-web-scraping- architecture

> Architecture diagram of the GitHub repository roshanalokhande/bms-web-scraping-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/roshanalokhande/bms-web-scraping-
- Repository: https://github.com/roshanalokhande/bms-web-scraping-

## Overview

##### Project type and purpose
- This is an open-source Python web-scraping tool.
- Purpose: Automatically extract event details (name, venue, category, price, image URL, etc.) from the BookMyShow website for a user-specified city and save results to Excel (and raw HTML for debugging).

##### File structure
- Top-level files:
- README.md – project description and instructions
- main.py – entry point and orchestration
- requirements.txt – dependency list
- No frontend/backend split or microservices; it’s a single-service CLI tool.

##### README for insights
- Uses undetected_chromedriver & Selenium to drive Chrome and avoid bot-detection.
- Parses HTML with BeautifulSoup.
- Stores data via pandas/openpyxl into an Excel file.
- Saves raw HTML snapshots.
- Handles dynamic loading (scrolling) and error conditions (CAPTCHAs, timeouts).

##### Components & relationships
a. Main Components
1. User CLI (main.py)
2. undetected_chromedriver + Selenium (Browser Automation)
3. External BookMyShow Website (Target)
4. BeautifulSoup Parser
5. Data Layer (pandas → Excel file)
6. Debug Layer (raw HTML file)
7. Error/Retry Handler
b. Data Flow & Interactions
- User invokes main.py with city parameter.
- main.py launches undetected_chromedriver → spins up Chrome.
- Selenium navigates to BookMyShow URL → browser renders dynamic content.
- Browser automation scrolls, waits, handles CAPTCHAs/timeouts (Error Handler).
- Page source (raw HTML) is passed to BeautifulSoup.
- BeautifulSoup extracts structured event details.
- Parsed data fed into pandas DataFrame → written to bookmyshow_<city>events.xlsx.
- Raw HTML also written to disk for debugging.
c. Architectural Patterns & Design Principles
- Pipeline pattern: data flows through stages (fetch → parse → store).
- Separation of concerns:
- Fetching & rendering (Selenium)
- Parsing (BeautifulSoup)
- Persistence (pandas/openpyxl)
- Error handling (retry, CAPTCHA detection)
- Extensibility point: city parameter → can adapt to other pages or websites.
d. Key Technologies & Frameworks
- Python 3.8+
- undetected_chromedriver (manages ChromeDriver invisibly)
- Selenium WebDriver (dynamic content handling)
- BeautifulSoup4 (HTML parsing)
- pandas & openpyxl (data storage to Excel)

##### Detail is key
- Every stage: user input → browser launch → scrolling → HTML capture → parsing → storage → error handling.
- Don’t over-modularize—this is a single-service tool—but clearly separate logical steps.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Documentation"
        README["README.md"]:::datastore
        REQ["requirements.txt"]:::datastore
    end

    subgraph "Scraping Pipeline"
        CLI["User CLI"]:::process
        Browser["Browser Automation"]:::process
        ExtSite["BookMyShow Website"]:::external
        Error["Error/Retry Handler"]:::process
        Parser["HTML Parser (BeautifulSoup)"]:::process
        Data[(Excel Output)]:::datastore
        Debug[(Raw HTML Output)]:::datastore
    end

    README --> CLI
    REQ --> CLI

    CLI -->|"start(city)"| Browser
    Browser -->|"navigate"| ExtSite
    ExtSite -->|"pageSource"| Browser
    Browser -->|"captureHTML"| Debug
    Browser -->|"pageSource"| Parser
    Parser -->|"parsedData"| Data

    Browser -->|errorDetected| Error
    Error -->|retry| Browser

    %% Click Events
    click README "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/README.md"
    click REQ "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/requirements.txt"
    click CLI "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/main.py"
    click Browser "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/main.py"
    click ExtSite "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/main.py"
    click Error "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/main.py"
    click Parser "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/main.py"
    click Data "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/main.py"
    click Debug "https://github.com/roshanalokhande/bms-web-scraping-/blob/main/main.py"

    %% Styles
    classDef process fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef datastore fill:#90EE90,stroke:#333,stroke-width:1px
```
