# cpp7957/nm architecture

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

- Interactive diagram: https://gitdiagram.com/cpp7957/nm
- Repository: https://github.com/cpp7957/nm

## Overview

##### Main components
a. Data Source (External Service)
- Google Image Search (via HTTP requests)
b. Crawling Module (`crawling.py`)
- HTTP client (requests)
- HTML parser (BeautifulSoup)
- Download manager (file I/O, tqdm for progress)
c. Local Storage
- `noh_images/` folder (raw images)
- `노무현.jpg` (reference image)
- `noh_mosaic.jpg` (output)
d. Mosaic Module (`mosaic.py`)
- Image loader (Pillow)
- Tile processor (resize to TILE_SIZE)
- Grid assembler (BUILD grid of size GRID_SIZE)
e. Output
- Final mosaic image saved to disk

##### Relationships and data flow
- Crawling Module → Local Storage (save images to `noh_images/`)
- Local Storage (`noh_images/` + `노무현.jpg`) → Mosaic Module (load inputs)
- Mosaic Module → Local Storage (`noh_mosaic.jpg`)
- (Optionally) show libraries as subcomponents of each module

##### Architectural patterns / design principles
- Pipeline pattern: two sequential stages (Crawl → Process)
- Separation of concerns: crawling and processing live in separate scripts
- Dependency injection (via constants in `mosaic.py` for TILE_SIZE, GRID_SIZE)
- Reusability: using standard libraries (requests, BeautifulSoup, Pillow, NumPy)

##### Technologies
- Python 3
- requests, beautifulsoup4, pillow, numpy, tqdm
- HTTP/HTTPS for external communication
- File system for storage

## Diagram (Mermaid)

```mermaid
flowchart TD
    Google["Google Image Search"]:::external
    Crawl["Crawling Module\n• requests\n• BeautifulSoup\n• tqdm"]:::codeModule
    Images["noh_images/"]:::storage
    RefImg["노무현.jpg"]:::storage
    Mosaic["Mosaic Module\n• Pillow\n• NumPy"]:::codeModule
    OutImg["noh_mosaic.jpg"]:::storage
    Readme["README.md"]:::docs
    License["LICENSE"]:::docs

    Google -->|"download images"| Crawl
    Crawl -->|"save images"| Images
    Images -->|"load images"| Mosaic
    RefImg -->|"load reference"| Mosaic
    Mosaic -->|"save mosaic"| OutImg

    classDef codeModule fill:#D6EAF8,stroke:#2E86C1,color:#1B4F72
    classDef storage fill:#D5F5E3,stroke:#27AE60,color:#1D8348
    classDef external fill:#FDEBD0,stroke:#E67E22,color:#A04000
    classDef docs fill:#F5EEF8,stroke:#8E44AD,color:#5B2C6F

    click Crawl "https://github.com/cpp7957/nm/blob/main/crawling.py"
    click Mosaic "https://github.com/cpp7957/nm/blob/main/mosaic.py"
    click Readme "https://github.com/cpp7957/nm/blob/main/README.md"
    click License "https://github.com/cpp7957/nm/tree/main/LICENSE"
```
