# osmhu/osmhu-website architecture

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

- Interactive diagram: https://gitdiagram.com/osmhu/osmhu-website
- Repository: https://github.com/osmhu/osmhu-website

## Overview

##### Main Components

a. Frontend Layer:
- Main JavaScript modules organization:
- Handling (/js/map/)
- POI (Points of Interest) management (/js/poi/)
- Search functionality (/js/search/)
- Direction services (/js/directions/)
- UI Components (/js/popup/, /js/common/)

b. Backend Layer:
- PHP-based server components
- Query handlers (/query/)
- Configuration management (/config/)

c. Database Layer:
- Dual database support (MySQL and PostgreSQL)
- GIS functionality (especially for PostgreSQL)

##### Key Architectural Elements

**[Client Browser]**
- ↓↑
**[Frontend Layer]**
- Map Components
- Search Interface
- POI Management
- Direction Services
- UI Components
- ↓↑
**[Backend API Layer]**
- Query Handlers
- Configuration Management
- ↓↑
**[Database Layer]**
- MySQL/PostgreSQL
- GIS Extensions

##### Important Details

a. External Services Integration:
- OpenStreetMap Data Services
- Nominatim Search Integration
- Overpass API Integration

b. Asset Management:
- CSS Structure (/css/)
- Static Resources (/kepek/)
- Build Pipeline (webpack, gulp)

##### Specific Implementation Notes

- Blue: Frontend components
- Green: Backend services
- Yellow: Database systems
- Gray: External services

- Clear data flow paths:
- User interactions
- API calls
- Database queries
- External service requests

##### Technical Stack Highlights

- Frontend: JavaScript (ES6+), CSS3
- Backend: PHP
- Databases: MySQL/PostgreSQL with GIS support
- Build Tools: Webpack, Gulp
- Testing: Jest

##### Development Environment

A separate section showing:
- Docker container setup
- Apache configuration
- Development tools and scripts

##### Key Architectural Patterns to Highlight

- Component-based frontend architecture
- Service-oriented backend structure
- MVC-like pattern in the frontend organization
- Worker-based processing for popup HTML creation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Frontend["Frontend Layer"]
        direction TB
        MapComp["Map Components"]:::frontend
        POIComp["POI Management"]:::frontend
        SearchComp["Search Components"]:::frontend
        DirComp["Direction Services"]:::frontend
        UIComp["UI Components"]:::frontend

        subgraph MapComponents["Map Module"]
            CoreMap["Core Map"]:::frontend
            MapControls["Map Controls"]:::frontend
            MapLayers["Map Layers"]:::frontend
        end

        subgraph POIComponents["POI Module"]
            POILayer["POI Layer"]:::frontend
            Overpass["Overpass Integration"]:::frontend
            POISearch["POI Search"]:::frontend
        end

        subgraph SearchComponents["Search Module"]
            AutoComplete["Autocomplete"]:::frontend
            NominatimSearch["Nominatim Search"]:::frontend
            SearchResults["Search Results"]:::frontend
        end

        subgraph DirectionComponents["Directions Module"]
            DirectionsAPI["Directions API"]:::frontend
            DirectionsControl["Directions Control"]:::frontend
            DirectionsResults["Directions Results"]:::frontend
        end
    end

    subgraph Backend["Backend Layer"]
        direction TB
        QueryHandlers["Query Handlers"]:::backend
        ConfigMgmt["Configuration Management"]:::backend
        
        subgraph Queries["Query Services"]
            CitiesQuery["Cities Query"]:::backend
            CoordQuery["Coordinates Query"]:::backend
            StreetsQuery["Streets Query"]:::backend
        end
    end

    subgraph Database["Database Layer"]
        MySQL[(MySQL)]:::database
        PostgreSQL[(PostgreSQL/PostGIS)]:::database
    end

    subgraph External["External Services"]
        OSM["OpenStreetMap"]:::external
        NominatimAPI["Nominatim API"]:::external
        OverpassAPI["Overpass API"]:::external
    end

    %% Connections
    Browser <--> Frontend
    Frontend <--> Backend
    Backend <--> Database
    Frontend <--> External

    %% Click Events
    click MapComp "https://github.com/osmhu/osmhu-website/tree/main/js/map/"
    click CoreMap "https://github.com/osmhu/osmhu-website/blob/main/js/map/Map.js"
    click MapControls "https://github.com/osmhu/osmhu-website/tree/main/js/map/controls/"
    click MapLayers "https://github.com/osmhu/osmhu-website/tree/main/js/map/layers/"
    click POIComp "https://github.com/osmhu/osmhu-website/tree/main/js/poi/"
    click POILayer "https://github.com/osmhu/osmhu-website/blob/main/js/poi/PoiLayer.js"
    click Overpass "https://github.com/osmhu/osmhu-website/blob/main/js/poi/Overpass.js"
    click POISearch "https://github.com/osmhu/osmhu-website/blob/main/js/poi/PoiSearchHierarchy.js"
    click SearchComp "https://github.com/osmhu/osmhu-website/tree/main/js/search/"
    click AutoComplete "https://github.com/osmhu/osmhu-website/blob/main/js/search/Autocomplete.js"
    click NominatimSearch "https://github.com/osmhu/osmhu-website/blob/main/js/search/NominatimSearch.js"
    click SearchResults "https://github.com/osmhu/osmhu-website/blob/main/js/search/SearchResults.js"
    click DirComp "https://github.com/osmhu/osmhu-website/tree/main/js/directions/"
    click DirectionsAPI "https://github.com/osmhu/osmhu-website/blob/main/js/directions/DirectionsApi.js"
    click DirectionsControl "https://github.com/osmhu/osmhu-website/blob/main/js/directions/DirectionsControl.js"
    click DirectionsResults "https://github.com/osmhu/osmhu-website/blob/main/js/directions/DirectionsResultLayer.js"
    click UIComp "https://github.com/osmhu/osmhu-website/tree/main/js/common/"
    click QueryHandlers "https://github.com/osmhu/osmhu-website/tree/main/query/"
    click CitiesQuery "https://github.com/osmhu/osmhu-website/blob/main/query/cities.php"
    click CoordQuery "https://github.com/osmhu/osmhu-website/blob/main/query/coordinates.php"
    click StreetsQuery "https://github.com/osmhu/osmhu-website/blob/main/query/streets.php"
    click ConfigMgmt "https://github.com/osmhu/osmhu-website/tree/main/config/"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend"]:::backend
        Database_L["Database"]:::database
        External_L["External Services"]:::external
    end
```
