# ngshiheng/michelin-my-maps architecture

> Architecture diagram of the GitHub repository ngshiheng/michelin-my-maps, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ngshiheng/michelin-my-maps
- Repository: https://github.com/ngshiheng/michelin-my-maps

## Overview

##### Main Components

a) Core Components:
- Crawler Service (pkg/crawler)
- Parser Service (pkg/parser)
- Data Storage Layer (CSV output)
- Logger Service (pkg/logger)
- Michelin Domain Models (pkg/michelin)

b) External Components:
- Michelin Guide Website (External Data Source)
- Cache System (mentioned in README)
- CI/CD Pipeline (GitHub Actions)

**[Michelin Website] -> [Crawler Service] -> [Parser Service] -> [CSV Storage]**

##### Specific Component Details

Crawler Service (Main Component):
- Two sub-components: crawler.go and xpath.go
- Connection to external Michelin website
- Cache interaction

Parser Service:
- Connection to the Michelin domain models
- Test coverage (parser_test.go)

Domain Models:
- Three model files (distinction.go, restaurant.go, url.go)
- Their relationship to the parser

- External Layer |

- Service Layer  |

- Domain Layer   |

- Storage Layer  |

##### Technical Details

- Go Colly integration points
- XPath selectors usage
- CSV output format
- Cache mechanism
- Error handling paths
- Logging points

This architecture should emphasize the project's main purpose as a data collection tool while showing its robust error handling, caching, and logging capabilities.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        MichelinWeb["Michelin Guide Website"]:::external
    end

    subgraph "Service Layer"
        Crawler["Crawler Service"]:::service
        Parser["Parser Service"]:::service
        Logger["Logger Service"]:::service
        
        subgraph "Crawler Components"
            CrawlerImpl["Crawler Implementation"]:::component
            XPath["XPath Selectors"]:::component
        end
        
        subgraph "Parser Components"
            ParserImpl["Parser Implementation"]:::component
            ParserTest["Parser Tests"]:::component
        end
    end

    subgraph "Domain Layer"
        subgraph "Michelin Models"
            Restaurant["Restaurant Model"]:::model
            Distinction["Distinction Model"]:::model
            URL["URL Model"]:::model
        end
    end

    subgraph "Storage Layer"
        Cache[(Cache)]:::storage
        CSV[(CSV Storage)]:::storage
    end

    subgraph "Infrastructure"
        CLI["Command Line Interface"]:::infra
        CICD["CI/CD Pipeline"]:::infra
        Docker["Docker Container"]:::infra
    end

    MichelinWeb -->|Raw Data| Crawler
    Crawler -->|Processed Data| Parser
    Parser -->|Formatted Data| CSV
    
    Crawler --> Cache
    Cache --> Crawler
    
    Logger -.->|Logging| Crawler
    Logger -.->|Logging| Parser
    
    Crawler --- CrawlerImpl
    Crawler --- XPath
    Parser --- ParserImpl
    Parser --- ParserTest
    
    Parser --> Restaurant
    Parser --> Distinction
    Parser --> URL
    
    CLI --> Crawler
    
    classDef external fill:#90EE90
    classDef service fill:#ADD8E6
    classDef component fill:#F0F8FF
    classDef model fill:#DDA0DD
    classDef storage fill:#FFD700
    classDef infra fill:#D3D3D3

    click Crawler "https://github.com/ngshiheng/michelin-my-maps/tree/main/pkg/crawler/"
    click CrawlerImpl "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/crawler/crawler.go"
    click XPath "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/crawler/xpath.go"
    click Parser "https://github.com/ngshiheng/michelin-my-maps/tree/main/pkg/parser/"
    click ParserImpl "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/parser/parser.go"
    click ParserTest "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/parser/parser_test.go"
    click Logger "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/logger/logger.go"
    click Restaurant "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/michelin/restaurant.go"
    click Distinction "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/michelin/distinction.go"
    click URL "https://github.com/ngshiheng/michelin-my-maps/blob/main/pkg/michelin/url.go"
    click CSV "https://github.com/ngshiheng/michelin-my-maps/blob/main/data/michelin_my_maps.csv"
    click CLI "https://github.com/ngshiheng/michelin-my-maps/blob/main/cmd/mym/mym.go"
    click CICD "https://github.com/ngshiheng/michelin-my-maps/blob/main/.github/workflows/ci.yml"
    click Docker "https://github.com/ngshiheng/michelin-my-maps/tree/main/docker/Dockerfile"
```
