# dumilson/search_images_google architecture

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

- Interactive diagram: https://gitdiagram.com/dumilson/search_images_google
- Repository: https://github.com/dumilson/search_images_google

## Overview

##### Project type and purpose
- This is a small PHP-based full-stack web application whose sole purpose is to let users search Google Images via a simple UI. It uses index.php as the entry point, a couple of PHP classes to handle scraping, and jQuery/Bootstrap on the frontend.

##### File structure
- Top level:
- index.php – main HTTP entry point and view renderer
- README.md – project description and stack
- Classes/ directory:
- ScrapperGoogle.php – encapsulates logic to craft HTTP requests to Google and parse HTML results
- GetImages.php – higher-level service that uses ScrapperGoogle to retrieve a set of image URLs
- No separate configs, no database, no deployment scripts beyond PHP’s built-in server.

##### Extract insights from the README
- Technology stacks: PHP for server, jQuery + Bootstrap for UI, custom “Scrapper” classes for Google scraping
- Deployment: runs via `php -S localhost:8080`

##### Main components
a. Client / Browser (renders HTML, uses jQuery to send search requests)
b. Frontend assets (Bootstrap CSS/JS, jQuery library)
c. Web Server / PHP runtime (index.php)
d. Scraper service layer (GetImages class coordinating the scraping workflow)
e. HTTP Client & Parser (ScrapperGoogle class making requests to Google and parsing the response HTML)
f. External Service (Google Images endpoint)

##### Relationships & data flows
1. User enters a query in the browser UI →
2. jQuery AJAX POST to index.php →
3. index.php instantiates GetImages →
4. GetImages calls ScrapperGoogle to fetch and parse Google HTML →
5. ScrapperGoogle issues outbound HTTP request to Google Images →
6. Google responds with HTML →
7. ScrapperGoogle extracts image URLs and returns them to GetImages →
8. index.php packages results in JSON or renders them directly →
9. AJAX success handler in browser updates the UI with thumbnails

##### Architectural patterns and principles
- Single-page, request/response pattern via AJAX
- Separation of concerns: index.php (controller + view), GetImages (service layer), ScrapperGoogle (adapter for external HTTP + parser)
- No persistence layer; stateless scraping operations

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Browser"]:::frontend
        Assets["jQuery & Bootstrap"]:::frontend
    end

    %% Backend Layer
    subgraph "Server Layer (PHP 7.x)" 
        Index["index.php (Controller & View Renderer)"]:::backend
        GetImages["GetImages Service"]:::backend
        ScrapperGoogle["ScrapperGoogle Client/Parser"]:::backend
    end

    %% External Service
    External["Google Images Endpoint"]:::external

    %% Documentation
    Documentation["README.md (Project Docs)"]:::doc

    %% Data Flows
    Browser -->|"send query (AJAX POST)"| Index
    Assets -->|"loaded in view"| Index
    Index -->|"instantiate & call"| GetImages
    GetImages -->|"calls"| ScrapperGoogle
    ScrapperGoogle -->|"HTTP GET google.com/search?"| External
    External -->|"HTML response"| ScrapperGoogle
    ScrapperGoogle -->|"parse URLs and return"| GetImages
    GetImages -->|"returns image URLs"| Index
    Index -->|"return JSON / render view"| Browser

    %% Click Events
    click Index "https://github.com/dumilson/search_images_google/blob/main/index.php"
    click GetImages "https://github.com/dumilson/search_images_google/blob/main/Classes/GetImages.php"
    click ScrapperGoogle "https://github.com/dumilson/search_images_google/blob/main/Classes/ScrapperGoogle.php"
    click Documentation "https://github.com/dumilson/search_images_google/blob/main/README.md"

    %% Styles
    classDef frontend fill:#aed6f1,stroke:#1f618d,color:#1f618d
    classDef backend fill:#abebc6,stroke:#196f3d,color:#196f3d
    classDef external fill:#d5dbdb,stroke:#566573,color:#566573
    classDef doc fill:#f9e79f,stroke:#b9770e,color:#7d6608
```
