# rainhacker/locator architecture

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

- Interactive diagram: https://gitdiagram.com/rainhacker/locator
- Repository: https://github.com/rainhacker/locator

## Overview

##### Main Components

A. Client Layer:
- Web Browser (User Interface)
- Google Maps Integration
- Bootstrap UI Framework

B. Web Layer:
- JSP Pages (home.jsp, showMap.jsp)
- MapServlet (Controller)

C. Business Layer:
- Location Service Components
- Location Selector System
- CSV Data Processing

D. Data Layer:
- NYC WiFi Hotspot CSV File
- Google Maps API Integration

**[Top Layer]**
**Client Layer (Web Browser)**

**[Middle Layers]**
**Web Layer (Servlets & JSPs)**

**Business Layer (Location Processing)**

**[Bottom Layer]**
**Data Layer (CSV & External APIs)**

##### Component Relationships to Highlight

- Client → Web Layer (HTTP Requests)
- Web Layer → Business Layer (Java Method Calls)
- Business Layer → Data Layer (File Reading & API Calls)
- Business Layer → Google Maps API (External Service)

B. Include these specific components:
- MapServlet as the main controller
- Location Selector hierarchy (AbstractLocationSelector, NearestOneLocationSelector, NearestNlocationSelector)
- LocationSelectorSimpleFactory for instantiation
- CSV Data Store (NYC_Free_Public_WiFi_12052014.csv)

##### Specific Implementation Details

A. Client Layer:
- Bootstrap UI components
- Google Maps JavaScript integration
- User interaction points (1 or 10 nearest locations selection)

B. Web Layer:
- MapServlet as the main controller
- JSP view templates
- Request/response flow

C. Business Layer:
- Detail the Location Selector pattern
- Factory pattern implementation
- Location processing logic

D. Data Layer:
- CSV data source
- Google Maps API integration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef client fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef web fill:#99ff99,stroke:#333,stroke-width:2px
    classDef business fill:#ffcc99,stroke:#333,stroke-width:2px
    classDef data fill:#ffff99,stroke:#333,stroke-width:2px
    classDef external fill:#e6e6e6,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        Browser["Web Browser"]:::client
        HomeJSP["home.jsp"]:::client
        ShowMapJSP["showMap.jsp"]:::client
        Bootstrap["Bootstrap UI"]:::client
    end

    %% Web Layer
    subgraph WebLayer["Web Layer"]
        MapServlet["MapServlet\n(Controller)"]:::web
    end

    %% Business Layer
    subgraph BusinessLayer["Business Layer"]
        LocationModel["Location Model"]:::business
        AbstractSelector["AbstractLocationSelector"]:::business
        SelectorFactory["LocationSelectorSimpleFactory"]:::business
        NearestOne["NearestOneLocationSelector"]:::business
        NearestN["NearestNLocationSelector"]:::business
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        CSVData["NYC WiFi Hotspot CSV"]:::data
        GMapsAPI["Google Maps API"]:::external
    end

    %% Relationships
    Browser --> HomeJSP
    Browser --> ShowMapJSP
    HomeJSP --> MapServlet
    ShowMapJSP --> MapServlet
    Bootstrap --> HomeJSP
    Bootstrap --> ShowMapJSP
    
    MapServlet --> SelectorFactory
    SelectorFactory --> AbstractSelector
    AbstractSelector --> NearestOne
    AbstractSelector --> NearestN
    NearestOne --> LocationModel
    NearestN --> LocationModel
    LocationModel --> CSVData
    LocationModel --> GMapsAPI

    %% Click Events
    click HomeJSP "https://github.com/rainhacker/locator/blob/master/src/main/webapp/home.jsp"
    click ShowMapJSP "https://github.com/rainhacker/locator/blob/master/src/main/webapp/showMap.jsp"
    click Bootstrap "https://github.com/rainhacker/locator/tree/master/src/main/webapp/bootstrap"
    click MapServlet "https://github.com/rainhacker/locator/blob/master/src/main/java/locator/MapServlet.java"
    click LocationModel "https://github.com/rainhacker/locator/blob/master/src/main/java/locator/Location.java"
    click AbstractSelector "https://github.com/rainhacker/locator/blob/master/src/main/java/locator/selector/AbstractLocationSelector.java"
    click SelectorFactory "https://github.com/rainhacker/locator/blob/master/src/main/java/locator/selector/LocationSelectorSimpleFactory.java"
    click NearestOne "https://github.com/rainhacker/locator/blob/master/src/main/java/locator/selector/NearestOneLocationSelector.java"
    click NearestN "https://github.com/rainhacker/locator/blob/master/src/main/java/locator/selector/NearestNlocationSelector.java"
    click CSVData "https://github.com/rainhacker/locator/blob/master/src/main/webapp/WEB-INF/data/NYC_Free_Public_WiFi_12052014.csv"

    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        WebComp["Web Component"]:::web
        BusinessComp["Business Component"]:::business
        DataComp["Data Component"]:::data
        ExternalComp["External Service"]:::external
    end
```
