Skip to content

AI-powered navigation tool for safer travel, avoiding high-risk zones using real-time crime data and intelligent routing.

Notifications You must be signed in to change notification settings

HackHarvard2024-Team/front-end

Repository files navigation

Albatross App Screenshot

🦅 Albatross

Get home faster. Safer. Smarter.

HackHarvard 2024 License

Vue.js Cloudflare Databricks Python OpenAI HERE Maps

OverviewFeaturesArchitectureTech StackRepositoriesGetting StartedTeam

Complete walkthrough demonstrating route search, danger slider tuning, hot-zone visualization, and safe rerouting

albatross_demo.mp4

Overview

Albatross is an AI-powered navigation system that prioritizes your safety by calculating routes that avoid crime hot-zones. Like the albatross bird that never fails to find its way home, our application ensures you reach your destination through the safest possible path.

Traditional navigation apps optimize for distance or time. Albatross optimizes for your safety. By aggregating criminal history data with real-time traffic and city layout information, we provide quick, safe, and efficient routing.

The Problem

Many of us have experienced moments when navigation apps have led us into areas that felt unsafe or uneasy. Current routing solutions don't factor in neighborhood safety, leaving users vulnerable to potentially dangerous situations.

The Solution

Albatross uses machine learning to:

  • Analyze historical crime data
  • Generate dynamic crime hot-zones
  • Calculate routes that intelligently avoid high-risk areas
  • Provide real-time rerouting based on safety scores

Features

Feature Description
Interactive Map Beautiful, intuitive map powered by HERE Maps API
Multi-Modal Transport Car, pedestrian, bicycle, truck, scooter, taxi, and bus
Danger Sensitivity Customize safety threshold with danger level slider (0-5)
Current Location One-click access to your current position
Dark Mode Easy on the eyes for night navigation
Smart Search Place search with autocomplete
Route Instructions Turn-by-turn navigation with time & distance
Crime Visualization See danger zones highlighted on the map

Architecture

System Design

Albatross System Architecture

System Overview

flowchart TB
    subgraph Client["Client Layer"]
        UI[Vue.js Dashboard]
        MAP[HERE Maps SDK]
    end

    subgraph Edge["Edge Computing"]
        CF[Cloudflare Workers]
        POLY[Polyline Decoder]
        GEO[Geometry Utils]
    end

    subgraph API["External APIs"]
        HERE[HERE Routing API]
        GEOCODE[HERE Geocoding API]
    end

    subgraph Processing["Data Processing"]
        PY[Python Analysis Engine]
        ML[ML Crime Scoring]
        EMB[OpenAI Embeddings]
    end

    subgraph Storage["Data Layer - AWS"]
        DB[(Databricks)]
        DELTA[(Delta Lake)]
        MLFLOW[MLflow]
    end

    subgraph Data["Data Sources"]
        CRIME[Crime Data CSV]
        GEO_DATA[GeoJSON Boundaries]
        GOOGLE[Google Geocoding API]
    end

    UI --> MAP
    UI -->|"Route Request"| HERE
    UI -->|"Encoded Polyline"| CF
    CF --> POLY
    CF --> GEO
    CF -->|"Fetch Crime Zones"| DB

    HERE -->|"Re-calculated Route"| UI
    CF -->|"N-gon Crime Hotzones"| UI

    CRIME --> PY
    GEO_DATA --> PY
    PY --> ML
    ML --> EMB
    PY -->|"Crime Blocks"| DELTA

    DB --> DELTA
    DB --> MLFLOW

    GOOGLE --> PY
Loading

Data Flow

sequenceDiagram
    participant U as User
    participant V as Vue.js App
    participant H as HERE API
    participant C as Cloudflare Worker
    participant D as Databricks

    U->>V: Enter Origin & Destination
    V->>H: Request Initial Route
    H-->>V: Return Polyline
    V->>C: Send Polyline + Danger Level
    C->>D: Query Crime Zones
    D-->>C: Return N-gon Polygons
    C->>C: Check Intersections
    C-->>V: Return Overlapping Zones
    V->>V: Display Crime Zones
    V->>H: Request Route (Avoid Areas)
    H-->>V: Return Safe Route
    V-->>U: Display Safe Navigation
Loading

Crime Data Processing Pipeline

flowchart LR
    subgraph ETL["ETL Pipeline"]
        E[Extract]
        T[Transform]
        L[Load]
    end

    subgraph Extract
        CSV[Crime CSV Files]
        GEO[GeoJSON Boundaries]
    end

    subgraph Transform
        ADDR[Address Geocoding]
        BLOCK[Block Assignment]
        EMBED[Crime Embeddings]
        SCORE[Severity Scoring]
        CLUSTER[K-Means Clustering]
    end

    subgraph Load
        DELTA[(Delta Lake)]
        FINAL[final_fast.csv]
    end

    CSV --> E
    GEO --> E
    E --> ADDR
    ADDR --> BLOCK
    BLOCK --> EMBED
    EMBED --> SCORE
    SCORE --> CLUSTER
    CLUSTER --> L
    L --> DELTA
    L --> FINAL
Loading

Crime Severity Classification

graph TD
    subgraph Input
        CRIME[Crime Description]
    end

    subgraph Processing
        EMB[OpenAI Embeddings]
        COS[Cosine Similarity]
    end

    subgraph Reference["Reference Embeddings"]
        R0["Level 0: Safe"]
        R1["Level 1: Low"]
        R2["Level 2: High"]
    end

    subgraph Output
        SCORE[Severity Score 0-2]
    end

    CRIME --> EMB
    EMB --> COS
    R0 --> COS
    R1 --> COS
    R2 --> COS
    COS --> SCORE
Loading

Tech Stack

Frontend

Technology Purpose
Reactive UI Framework
Fast Development Server
State Management
Interactive Mapping

Edge Computing

Technology Purpose
Serverless Edge Functions
Worker Logic

Data Processing

Technology Purpose
Data Analysis
Crime Text Embeddings
K-Means Clustering
Numerical Processing

Data Storage

Technology Purpose
Unified Analytics
ACID Data Lake
Distributed Computing
ML Lifecycle Management

APIs

Service Purpose
HERE Routing API Optimal Pathfinding
HERE Geocoding API Address to Coordinates
HERE Autosuggest API Search Autocomplete
Google Geocoding API Batch Address Resolution

Repositories

This project is organized into multiple repositories:

Repository Description Link
albatross-frontend Vue.js web application with HERE Maps integration Repo
albatross-cloudflare Cloudflare Workers for edge computing and polygon intersection Repo
albatross-databricks Scala notebooks for Databricks/Delta Lake setup Repo
albatross-analysis Python scripts for crime data processing and ML Repo

Getting Started

Prerequisites

Requirement Version
18+
3.9+
Account Required
Account Required
Developer Account
API Key

1. Frontend Setup

# Clone the frontend repository
git clone https://github.com/YOUR_USERNAME/albatross-frontend.git
cd albatross-frontend

# Install dependencies
npm install

# Configure environment variables
cp .env.example .env
# Add your HERE API key to .env

# Start development server
npm run dev
Configuration Details

Configuration (src/MapPage.vue & src/components/HereMap.vue):

// Replace with your HERE API key
apiKey: 'YOUR_HERE_API_KEY'

2. Cloudflare Workers Setup

# Clone the cloudflare repository
git clone https://github.com/YOUR_USERNAME/albatross-cloudflare.git
cd albatross-cloudflare

# Install Wrangler CLI
npm install -g wrangler

# Login to Cloudflare
wrangler login

# Deploy the worker
wrangler deploy
Worker Files
File Purpose
worker.js Main request handler
polylineDecoder.js Flexible polyline decoding
geometryUtils.js Polygon intersection algorithms
polygonFetcher.js Databricks data fetching

3. Data Processing Setup

# Clone the analysis repository
git clone https://github.com/YOUR_USERNAME/albatross-analysis.git
cd albatross-analysis

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install numpy scikit-learn openai requests polyline

# Set OpenAI API key
export OPENAI_API_KEY='your-api-key'

# Run the analysis pipeline
python analyze.py
Required Data Files
datafiles/
├── usa.geojson          # US Census block boundaries
├── boston_crime.csv     # Boston crime incidents
├── crime.csv            # Additional crime data
└── final_fast.csv       # Output: processed crime zones

4. Databricks Setup

  1. Create a Databricks workspace on AWS
  2. Upload the Scala notebooks:
    • Create4gonDeltaLake.scala - Initialize Delta Lake tables
    • CrimeDataProcessing.scala - Process and store crime data
  3. Upload crime data CSV to DBFS
  4. Run notebooks in order
Delta Lake Schema
val schema = StructType(Array(
  StructField("vertex1_lat", DoubleType),
  StructField("vertex1_lon", DoubleType),
  StructField("vertex2_lat", DoubleType),
  StructField("vertex2_lon", DoubleType),
  StructField("vertex3_lat", DoubleType),
  StructField("vertex3_lon", DoubleType),
  StructField("vertex4_lat", DoubleType),
  StructField("vertex4_lon", DoubleType),
  StructField("crime_score", DoubleType)
))

How It Works

Crime Zone Generation

Step Process
1 Data Ingestion - Crime data loaded from CSV files
2 Geocoding - Addresses converted to coordinates via Google API
3 Block Assignment - Crimes assigned to census blocks using ray-casting
4 Severity Scoring - OpenAI embeddings + cosine similarity
5 Zone Classification - Ranked by crime density into 5 levels
6 Polygon Simplification - K-Means clustering to 4-sided N-gons

Danger Levels

Level Percentile Risk
5 Top 2% Most dangerous
4 Top 5% Very dangerous
3 Top 10% Dangerous
2 Top 50% Moderate risk
1 Bottom 50% Low risk

Route Calculation

  1. User enters origin and destination
  2. Initial route calculated via HERE Routing API
  3. Polyline sent to Cloudflare Worker
  4. Worker checks intersections with crime zones
  5. Matching danger zones returned to frontend
  6. Route recalculated with avoid[areas] parameter
  7. Safe route displayed with crime zones visualized

Future Roadmap

  • Real-time Notifications - Push alerts for nearby incidents
  • Personalized Safety - User-specific risk preferences
  • AI Crime Prediction - Predictive models for emerging hot-zones
  • Mobile Apps - Native iOS and Android applications
  • Community Reports - Crowdsourced safety data
  • Time-based Routing - Different routes for day vs. night
  • 911 Integration - Emergency service coordination

Accomplishments

  • Completed all core functionalities within hackathon timeframe
  • Successfully integrated multiple new technologies (Databricks, Cloudflare Workers)
  • Built efficient real-time crime data clustering system
  • Implemented flexible polyline encoding workarounds
  • Created scalable architecture for future enhancements

What We Learned

Technology Learnings
Databricks & Delta Lake Unified analytics platform and ACID transactions
Cloudflare Workers Edge computing for low-latency processing
HERE APIs Geo-routing and flexible polyline encoding
Vue.js Reactive frontend development
Scala & Spark Distributed data processing
ML Embeddings Text similarity for crime classification

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

# 1. Fork the repository
# 2. Create your feature branch
git checkout -b feature/AmazingFeature

# 3. Commit your changes
git commit -m 'Add some AmazingFeature'

# 4. Push to the branch
git push origin feature/AmazingFeature

# 5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.


Team

HackHarvard 2024

Shahir Ahmed
Shahir Ahmed

Full Stack
Boosung Kim
Boosung Kim

Full Stack
Jordan Zedeck
Jordan Zedeck

Full Stack

Acknowledgments

HERE Databricks Cloudflare OpenAI

Special thanks to Boston Police Department for open crime data


Albatross - Because everyone deserves to get home safe.

Devpost Get Started Report Bug

About

AI-powered navigation tool for safer travel, avoiding high-risk zones using real-time crime data and intelligent routing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published