Skip to content

About

bus

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

49 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸšŒ BelBusRadar

Real-Time Bus Intelligence for a Safer Belfast

BelBusRadar is a real-time interactive map dashboard for Belfast commuters. It combines live bus tracking, journey planning, route exploration, service updates, and safety intelligence into a single, accessible web application.

Built for HackBelfast โ€” Builder Track.


๐ŸŽฏ The Problem

Belfast commuters currently need 3+ separate apps to plan, track, and manage bus journeys. None of these apps provide safety information, and most fail basic accessibility standards. BelBusRadar solves this by combining everything into one unified, map-first platform.


โœจ Features

๐Ÿ—บ๏ธ Interactive Map (Home Page)

  • Full-screen Mapbox GL JS map centred on Belfast with 3D pitch view
  • 7 toggleable overlay layers with distinct visual markers:
    • ๐Ÿ”บ Bus Stops โ€” 2,400+ stops across greater Belfast (blue triangles)
    • ๐ŸŸข Live Buses โ€” Interpolated moving bus positions updated every 10 seconds (green arrows)
    • โŒ Traffic Crashes โ€” Historical collision data colour-coded by severity (red X markers)
    • ๐ŸŸ  Potholes โ€” Reported pothole locations with status (orange circles)
    • ๐ŸŸฃ Street Crime โ€” 1,400+ monthly crime incidents from UK Police API (purple diamonds)
    • ๐ŸŸฃ Air Quality โ€” Monitoring stations + pollution heatmap with rush-hour boost
    • โšก Lighting Faults โ€” Non-spatial sidebar list (always visible, minimisable)
  • Click any marker for detailed popup information
  • Click a bus stop to fetch real-time departure data on demand
  • Fullscreen mode with dedicated toggle button
  • "Jump to Map" button for instant scroll access
  • Filter menu with map key showing all marker types
  • Rush hour status banner (07:00โ€“09:00, 16:00โ€“19:00)

๐Ÿ“‹ Routes Page

  • Browse all 2,600+ Translink bus and rail routes across Northern Ireland
  • Filter by route number/name via search
  • Filter by service type (Metro, Ulsterbus, Glider, Goldline, Foyle Metro, NI Railways)
  • Expandable route cards with operator, direction, and transport type
  • Paginated display (10 per page) for performance
  • Server-side caching of the 2MB XML route data (10-minute TTL)

๐Ÿ“ Journey Planner

  • From/To inputs with debounced autocomplete (searches Translink stops as you type)
  • Swap origin/destination button
  • Departure time selector (Now / Choose Time with date + time pickers)
  • Journey results showing:
    • Total duration, departure โ†’ arrival times
    • Number of transfers, walking time
    • Step-by-step leg details with timeline UI (walk/bus/transfer icons)
    • Route numbers as badges
  • ๐Ÿ›ก๏ธ "Make My Journey Safer" โ€” AI-simulated safety analysis:
    • Fetches real PSNI crime data within 100m of journey origin
    • Filters to transit-relevant crimes only (excludes burglary, shoplifting, etc.)
    • Applies severity weighting (robbery 4x, violent crime 3x, ASB 0.3x)
    • Calculates weighted risk score per day (Low < 1, Moderate 1โ€“5, High 5+)
    • Generates contextual safety tips based on crime categories + time of day
    • Includes AI disclaimer

๐Ÿ“ข Updates Page

  • Live service alerts and disruption information
  • Colour-coded severity (red = major disruption, yellow = delay, green = normal)
  • Filter by date (Today / Yesterday / This Week / All)
  • Filter by route number
  • Expandable cards with description, affected routes, estimated resolution
  • "View Affected Route" links to Routes page

๐ŸŒ™ Dark Mode

  • Full dark/light theme toggle in the navbar
  • Persists to localStorage, respects system prefers-color-scheme
  • All pages, components, inputs, and cards have dark variants

โ™ฟ Accessibility

  • ARIA labels on interactive elements
  • Keyboard navigation support
  • Sufficient colour contrast
  • Responsive design (mobile-first)
  • Screen reader compatible status banners

๐Ÿ—๏ธ Tech Stack

Layer Technology
Frontend React 19, Vite, Tailwind CSS, Mapbox GL JS, react-map-gl
Backend Express.js (Node.js)
APIs Translink EFA Open Data API, UK Police API
Local Data CSV (collisions, air quality), XML (potholes, lighting, air quality)
Coordinate Conversion proj4 (Irish Grid EPSG:29902 โ†’ WGS84)
XML Parsing fast-xml-parser (server-side), fast-xml-parser (client-side)
CSV Parsing PapaParse
AI Development Claude Opus (agent-driven), Figma AI (UI generation)
Design Figma โ†’ Code export, custom branding

๐Ÿ“Š Data Sources

Source Data Format Update Frequency
Translink EFA API Live departures, stop search, journey planning, route geometry, line list JSON/XML Real-time
UK Police API Street-level crime data with coordinates, categories, outcomes JSON Monthly
PSNI Traffic Collisions traffic_collision_2025.csv + traffic_collision_casualty_2025.csv CSV Annual
Pothole Enquiries Pothole_Enquiries_2026.xml XML Ongoing
Air Quality Stations Belfast_Air_Monitoring_Stations.csv CSV Static
Air Quality Readings Automatic_Air_Quality.xml, Non_Automatic_Air_Quality.xml, Aggregated_Air_Quality_Stats.xml XML (Atom) Periodic
Lighting Faults LightingFaultsCurrentYear.xml XML Ongoing

๐Ÿš€ Getting Started

Prerequisites

Installation

git clone <repo-url>
cd BelBusRadar
npm install

Environment Variables

Copy .env.example to .env and fill in your keys:

TRANSLINK_API_KEY="your_translink_api_key"
VITE_MAPBOX_TOKEN="your_mapbox_token"
TRANSLINK_API_BASE_URL="https://opendata.translinkniplanner.co.uk/Ext_API"

Running

Start the Express backend:

npm run server

In a separate terminal, start the Vite dev server:

npm run dev

The app will be available at http://localhost:5173. The Vite dev server proxies /api/* requests to the Express backend on port 3001.

Building for Production

npm run build

The built files will be in dist/. The Express server can serve them as static files.


๐Ÿ”Œ API Endpoints

Endpoint Description
GET /api/buses All bus stops in greater Belfast (CoordInfo bounding box)
GET /api/live-buses Interpolated live bus positions from active departures
GET /api/departures/:stopId Real-time departures for a specific stop
GET /api/lines All 2,600+ Translink routes (cached 10 min)
GET /api/search-stops?q=QUERY Stop/location autocomplete search
GET /api/trip?from=ID&to=ID&date=YYYYMMDD&time=HHMM Journey planning
GET /api/updates Service alerts (live API with sample fallback)
GET /api/crimes Street crime data from UK Police API (cached 10 min)
GET /api/safety-analysis?lat=LAT&lng=LNG&hour=HH Weighted safety analysis

๐Ÿงฎ Safety Analysis Algorithm

The "Make My Journey Safer" feature uses a weighted scoring system:

Crime Weights:
  Possession of weapons  โ†’ 5x
  Robbery                โ†’ 4x
  Violent crime           โ†’ 3x
  Theft from person       โ†’ 2x
  Criminal damage/arson   โ†’ 1.5x
  Public order            โ†’ 1x
  Drugs                   โ†’ 1x
  Other theft             โ†’ 0.5x
  Anti-social behaviour   โ†’ 0.3x

Risk = ฮฃ(crime_count ร— weight) / 30 days

  Low:      < 1 weighted incidents/day
  Moderate: 1โ€“5 weighted incidents/day
  High:     > 5 weighted incidents/day

Only crimes within 100m of the journey origin are counted. Non-transit categories (burglary, shoplifting, bicycle theft) are excluded entirely.


๐Ÿ—‚๏ธ Project Structure

BelBusRadar/
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ data/                    # Local datasets (CSV, XML)
โ”‚   โ”œโ”€โ”€ judges/                  # Pitch deck and judging docs
โ”‚   โ””โ”€โ”€ BBR_Logo_White.PNG       # App logo
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ assets/                  # Images and logos
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ Navbar.jsx           # Navigation with dark mode toggle
โ”‚   โ”‚   โ”œโ”€โ”€ Footer.jsx           # Site footer
โ”‚   โ”‚   โ”œโ”€โ”€ FilterMenu.jsx       # Map overlay toggles + map key
โ”‚   โ”‚   โ””โ”€โ”€ StatusBanner.jsx     # Rush hour indicator
โ”‚   โ”œโ”€โ”€ context/
โ”‚   โ”‚   โ””โ”€โ”€ ThemeContext.jsx      # Dark/light mode state
โ”‚   โ”œโ”€โ”€ layers/
โ”‚   โ”‚   โ”œโ”€โ”€ BusLayer.jsx         # Bus stops + live bus markers
โ”‚   โ”‚   โ”œโ”€โ”€ CrashOverlay.jsx     # Traffic collision markers
โ”‚   โ”‚   โ”œโ”€โ”€ PotholeOverlay.jsx   # Pothole markers
โ”‚   โ”‚   โ”œโ”€โ”€ LightingOverlay.jsx  # Lighting faults sidebar panel
โ”‚   โ”‚   โ”œโ”€โ”€ AirQualityLayer.jsx  # Air quality stations + heatmap
โ”‚   โ”‚   โ””โ”€โ”€ CrimeOverlay.jsx     # Street crime markers
โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”œโ”€โ”€ MapPage.jsx          # Home page with interactive map
โ”‚   โ”‚   โ”œโ”€โ”€ RoutesPage.jsx       # Route browser with filters
โ”‚   โ”‚   โ”œโ”€โ”€ JourneyPlannerPage.jsx # Journey planner + safety analysis
โ”‚   โ”‚   โ””โ”€โ”€ UpdatesPage.jsx      # Service alerts
โ”‚   โ”œโ”€โ”€ parsers/                 # Dataset-specific parsers
โ”‚   โ”œโ”€โ”€ utils/                   # Coordinate converter, rush hour engine
โ”‚   โ”œโ”€โ”€ App.jsx                  # Router setup
โ”‚   โ””โ”€โ”€ main.jsx                 # Entry point with providers
โ”œโ”€โ”€ server.js                    # Express API proxy + safety engine
โ”œโ”€โ”€ vite.config.js               # Vite + Tailwind config
โ””โ”€โ”€ package.json

๐Ÿ† Practical Features

๐Ÿ… Use of Data

  • 7 live data sources integrated into one platform
  • Real-time Translink API integration (departures, routes, journey planning)
  • Spatial data visualization on an interactive map
  • Data consolidation solving the fragmentation problem

๐Ÿ›ก๏ธ AI for Everyday Safety

  • "Make My Journey Safer" with weighted crime scoring
  • Transit-relevant crime filtering within 100m radius
  • Time-of-day contextual safety tips
  • AI disclaimer for transparency

๐ŸŽจ Experience Design & Usability

  • Map-first interface (recognition over recall)
  • Figma AI โ†’ Code pipeline
  • Dark mode, responsive design, accessibility compliance
  • Minimal friction (autocomplete, filters, one-click access)

๐Ÿ‘ฅ Team

Lab Rats โ€” HackBelfast


๐Ÿ“„ License

This project was built for HackBelfast. All rights reserved.

About

bus

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages