Skip to content

timothewt/autohike

Repository files navigation

AutoHike

Build trails effortlessly in a few seconds

C++ React Docker

AutoHike is an intelligent hiking app that automatically generates personalized hiking routes based on your preferences. Whether you want a short stroll or a challenging trek, AutoHike designs the perfect trail from start to finish, considering factors like terrain type, elevation gain, and difficulty.

Features


  • Custom Hike Generation: Select your start and end points on an interactive map and let AutoHike create the optimal trail for you.
  • Preference-Based Routing: Adjust terrain type, elevation, and difficulty to tailor your hike.
  • Real-Time Map Visualization: See your route displayed directly on a map with key stats.
  • Scalable Backend: High-performance C++ backend capable of handling large datasets and complex route computations.
  • Modern Frontend: Built with React for a smooth and interactive user experience.

Technology Stack


  • Backend: C++ (graph-based algorithms for route generation)
  • Frontend: React (interactive maps and user interface)
  • Communication: REST API between frontend and backend

Backend Dependencies

Development-only

  • Osmium: To pre-process OpenStreetMap data.
  • GDAL: To process elevation data.
  • zlib: To read the compressed OSM files.

Getting Started


Backend

  1. Navigate to the backend directory:

    cd backend
  2. Build the application:

    mkdir -p build
    cd build
    cmake ..
    make -j
    
  3. If not done yet, for the data preprocessing, use:

   cmake -DBUILD_PREPROCESS=ON ..
   make -j
   ./preprocess_osm ../../data/raw/raw.osm.pbf ../../data/raw/raw-srtm.tif ../../data/tiles
  1. Run the backend server:
    ./AutoHikeBackend ../../data/tiles

The backend server will start on http://localhost:8080 with the following endpoints:

  • GET /api/health - Health check
  • POST /api/route - Route calculation (returns GeoJSON)
  • POST /api/export/gpx - GPX export

Frontend

  1. Navigate to the frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev

Configuration


The backend server can be configured using environment variables:

Server Configuration

Variable Default Range Description
AUTOHIKE_HOST 127.0.0.1 - Server bind address (use 0.0.0.0 for Docker)
AUTOHIKE_PORT 8080 1-65535 Server port
AUTOHIKE_MAX_THREADS 8 1-100 Maximum worker threads
AUTOHIKE_TIMEOUT 30 1-300 Request timeout in seconds

Tile Management

Variable Default Range Description
AUTOHIKE_MAX_TILES_CACHE 200 1-1000 Maximum tiles to cache in memory
AUTOHIKE_TILES_PATH "" - Custom path to tile data (optional)

Security & Limits

Variable Default Range Description
AUTOHIKE_MAX_REQUEST_SIZE 1048576 1024-10MB Maximum request size in bytes (1MB)
AUTOHIKE_ALLOWED_ORIGINS "" - CORS allowed origins (comma-separated, empty = allow all)

Database

Variable Default Description
AUTOHIKE_DB_PATH ../../database.sqlite Path to SQLite database

Production Example

# Set environment variables for production
export AUTOHIKE_HOST=0.0.0.0
export AUTOHIKE_PORT=3000
export AUTOHIKE_ALLOWED_ORIGINS="https://yourdomain.com,https://app.yourdomain.com"
export AUTOHIKE_MAX_REQUEST_SIZE=2097152
export AUTOHIKE_MAX_THREADS=16
export AUTOHIKE_MAX_TILES_CACHE=500

# Run the server
./AutoHikeBackend /path/to/tiles

Docker Configuration

When running with Docker, make sure to set AUTOHIKE_HOST=0.0.0.0 in your docker-compose.yml:

services:
  backend:
    environment:
      - AUTOHIKE_HOST=0.0.0.0
      - AUTOHIKE_MAX_TILES_CACHE=200

Acknowledgments


A big thanks to each open source project that made this app possible:

  • Path and water location data were obtained from OpenStreetMap.
  • Elevation data were sourced from the SRTM dataset provided by OpenTopography.
  • Shelter location data were retrieved from refuges.info.
  • Map tiling was provided by the Thunderforest API.

📄 License


This project is under license Apache 2.0.

Releases

No releases published

Packages

No packages published