# vsuin/directory-search architecture

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

- Interactive diagram: https://gitdiagram.com/vsuin/directory-search
- Repository: https://github.com/vsuin/directory-search

## Overview

##### Project type and purpose
- This is a small open-source PHP web tool named “Directory Search Tool.”
- Purpose: provide password-protected, minimum-length directory scanning and search functionality via a single PHP script (`search.php`).

##### File structure
- Top-level directory contains just:
- `search.php` – the only executable component
- `README.md` – documentation
- No separate frontend/back-end directories, no database, no external service modules.

##### README for additional insights
- Requires an HTTP server with PHP (Apache+PHP, Nginx+PHP-FPM).
- Prompts for password (default “1234”) then accepts queries ≥3 characters.
- Uses filesystem access to scan directories and return matches dynamically.

##### Main components
a. User (Browser)
b. Web Server (Apache/WAMP/XAMPP or live host)
c. PHP Runtime / Interpreter
d. Authentication Module (within `search.php`)
e. Search Module (directory traversal & filtering logic)
f. File System (webroot directory)
g. Response Renderer (HTML output generator)

##### Relationships and interactions
- User submits HTTP GET/POST to `search.php`.
- Web Server forwards request to PHP runtime.
- PHP runtime invokes Authentication Module:
- If password invalid → return HTML “access denied.”
- If valid → proceed to Search Module.
- Search Module reads filesystem recursively under webroot, filters filenames/paths by query length (≥3 chars) and match criteria.
- Results passed to Response Renderer, which builds an HTML page.
- Web Server returns HTML response to User.

##### Architectural patterns and design principles
- Single-entry-point script (Front Controller pattern).
- Module separation inside one file: authentication, validation, search logic, output.
- Layered flow: HTTP layer → auth layer → business logic layer → I/O layer → presentation layer.

##### Relevant technologies/frameworks/libraries
- PHP (built-in functions: `scandir()`, `RecursiveIteratorIterator`, string matching).
- HTTP Server (Apache / Nginx).
- HTML/CSS for results rendering (no JS dependencies).

## Diagram (Mermaid)

```mermaid
flowchart TB
    User["User Browser"]:::user
    WebServer["Web Server (Apache/Nginx)"]:::server
    PHPRuntime["PHP Runtime"]:::server

    subgraph "search.php"
        FC["Front Controller"]:::processing
        Auth["Authentication Module"]:::processing
        Search["Search Module"]:::processing
        Renderer["Response Renderer"]:::processing
    end

    FileSystem["File System (Webroot)"]:::fs
    README["Documentation (README.md)"]:::doc

    User -->|"HTTP request\nPassword+Query"| WebServer
    WebServer -->|"forward to PHP"| PHPRuntime
    PHPRuntime --> FC
    FC --> Auth
    Auth -->|"valid credentials"| Search
    Auth -->|"invalid credentials\naccess denied"| Renderer
    Search -->|"filesystem scan request"| FileSystem
    FileSystem -->|"scan results"| Search
    Search --> Renderer
    Renderer -->|"HTML output"| WebServer
    WebServer --> User

    click FC "https://github.com/vsuin/directory-search/blob/main/search.php"
    click Auth "https://github.com/vsuin/directory-search/blob/main/search.php"
    click Search "https://github.com/vsuin/directory-search/blob/main/search.php"
    click Renderer "https://github.com/vsuin/directory-search/blob/main/search.php"
    click README "https://github.com/vsuin/directory-search/blob/main/README.md"
    click FileSystem "https://github.com/vsuin/directory-search/tree/main/./"

    classDef processing fill:#ADD8E6,stroke:#036,stroke-width:1px
    classDef fs fill:#90EE90,stroke:#060,stroke-width:1px
    classDef server fill:#D3D3D3,stroke:#666,stroke-width:1px
    classDef user fill:#FFE4B5,stroke:#C96,stroke-width:1px
    classDef doc fill:#FFD700,stroke:#AA0,stroke-width:1px
```
