# bedla/praguehacks-realreality architecture

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

- Interactive diagram: https://gitdiagram.com/bedla/praguehacks-realreality
- Repository: https://github.com/bedla/praguehacks-realreality

## Overview

##### Project type and purpose
- This is a Java-based microservice (mock server) whose sole responsibility is to serve geospatial data (converted ESRI Shapefiles) over HTTP as a REST API.
- A Chrome-extension-based frontend (hosted in a separate repo) consumes this API.

##### File structure
- Top-level: Maven project (`pom.xml`, `.mvn/`, `mvnw`).
- src/main/java/cz/bedla/praguehacks2016/realreality:
- Application.java – entry point, boots embedded HTTP container
- config/JerseyConfig.java – registers REST endpoints & providers
- endpoint/Rest.java – JAX-RS resource with HTTP paths
- service/Service.java – business logic layer
- db/Database.java – data access façade to shapefile “database”
- geotools/GeoToolsFeatureCollectionSupport.java – adapter between GeoTools FeatureCollections and JSON output
- utils/GeoUtils.java & Utils.java – coordinate helpers, JSON serialization helpers
- src/main/resources/application.properties – runtime configuration (file‐paths, server port)

##### README for additional insights
- Describes manual pre-processing of .shp files in QGIS for reprojection to EPSG:3857 and adding an integer `my_id` field.
- Lists the datasets to download and convert.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Offline Data Preparation
    subgraph "Offline Data Preparation"
        QGIS["QGIS (Preprocessor)"]:::external
        FS["File System (.shp files)"]:::data
    end
    QGIS -->|"writes .shp files"| FS

    %% Configuration Store
    Config["application.properties"]:::config
    Config -->|"loaded at startup"| App

    %% Java Microservice
    subgraph "Java Microservice"
        App["Application (Application.java)"]:::core
        Jersey["JerseyConfig (JerseyConfig.java)"]:::core
        Rest["Rest Endpoint (Rest.java)"]:::core
        Service["Service Layer (Service.java)"]:::core
        DB["Database (Database.java)"]:::core
        GeoAdapter["GeoTools Adapter (GeoToolsFeatureCollectionSupport.java)"]:::core
        GeoUtils["GeoUtils (GeoUtils.java)"]:::util
        Utils["Utils (Utils.java)"]:::util
    end

    %% Client
    Chrome["Chrome Extension Client"]:::external

    %% Build & Deployment
    subgraph "Build & Deployment"
        POM["pom.xml"]:::build
        MVNW["mvnw / mvnw.cmd"]:::build
        Wrapper[".mvn/wrapper"]:::build
    end

    %% Data Flow Runtime
    Chrome -->|"HTTP/JSON"| Rest
    App -->|"boots embedded server"| Jersey
    Jersey -->|"registers endpoints"| Rest
    Rest -->|"invokes"| Service
    Service -->|"invokes"| DB
    DB -->|"uses"| GeoAdapter
    GeoAdapter -->|"reads .shp"| FS
    GeoAdapter -->|"returns FeatureCollection"| Service
    Service -->|"uses"| GeoUtils
    Service -->|"uses"| Utils
    Service -->|"returns JSON"| Rest
    Rest -->|"HTTP response"| Chrome

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef core fill:#bbf,stroke:#333,stroke-width:1px
    classDef data fill:#bfb,stroke:#333,stroke-width:1px
    classDef config fill:#fbf,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
    classDef util fill:#ffb,stroke:#333,stroke-width:1px
    classDef build fill:#ddd,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2

    %% Click Events
    click App "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/Application.java"
    click Jersey "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/config/JerseyConfig.java"
    click Rest "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/endpoint/Rest.java"
    click Service "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/service/Service.java"
    click DB "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/db/Database.java"
    click GeoAdapter "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/geotools/GeoToolsFeatureCollectionSupport.java"
    click GeoUtils "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/utils/GeoUtils.java"
    click Utils "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/java/cz/bedla/praguehacks2016/realreality/utils/Utils.java"
    click Config "https://github.com/bedla/praguehacks-realreality/blob/master/src/main/resources/application.properties"
    click POM "https://github.com/bedla/praguehacks-realreality/blob/master/pom.xml"
    click MVNW "https://github.com/bedla/praguehacks-realreality/tree/master/mvnw"
    click Wrapper "https://github.com/bedla/praguehacks-realreality/tree/master/.mvn/wrapper"
```
