Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Archit1706/temporary-road-closures

Repository files navigation

Temporary Road Closures Database and API

Google Summer of Code 2025 Project for OpenStreetMap Foundation

A comprehensive system for collecting and disseminating temporary road closure information, designed to enhance OSM-based navigation applications with real-time closure data and intelligent routing capabilities.

Python 3.11+ Next.js 15 FastAPI PostgreSQL PostGIS OpenLR License: AGPL v3


🎯 Project Overview

OpenStreetMap provides excellent static map data, but temporary road closures (construction, accidents, events) are often not captured quickly enough for navigation apps. This project bridges that gap by creating an open platform where:

  • Community members can report temporary road closures in real-time through a user-friendly web interface
  • Navigation applications can query closure data and calculate closure-aware routes
  • OpenLR integration ensures cross-platform compatibility across different map providers
  • OSM ecosystem benefits from enhanced real-time data and intelligent routing

🌟 Key Features

  • πŸ—ΊοΈ Interactive Web Application: Next.js-based frontend for easy closure reporting and visualization
  • πŸš— Closure-Aware Routing: Intelligent route calculation that avoids temporary road closures
  • πŸš΄β€β™€οΈ Multi-Modal Support: Transportation-specific routing for cars, bicycles, and pedestrians
  • πŸ“ OpenLR Integration: Map-agnostic location references for universal compatibility
  • πŸ” Secure Authentication: OAuth2 + JWT with Google/GitHub integration
  • πŸ“Š Real-time Analytics: Live statistics and closure status tracking
  • 🎯 Geometry Support: Both point closures (intersections) and road segment closures
  • πŸ“± Mobile Responsive: Optimized interface for field reporting on any device

πŸ“ Repository Structure

temporary-road-closures/
β”œβ”€β”€ backend/                 # FastAPI backend service βœ…
β”‚   β”œβ”€β”€ app/                # Application code with OpenLR integration
β”‚   β”œβ”€β”€ docker-compose.yml  # Development environment
β”‚   β”œβ”€β”€ requirements.txt    # Python dependencies
β”‚   └── README.md          # Detailed backend documentation
β”œβ”€β”€ frontend/               # Next.js web application βœ…
β”‚   β”œβ”€β”€ app/               # Next.js 15 App Router structure
β”‚   β”œβ”€β”€ components/        # React components for UI
β”‚   β”œβ”€β”€ services/          # API clients and utilities
β”‚   β”œβ”€β”€ context/           # State management
β”‚   β”œβ”€β”€ public/            # Static assets
β”‚   β”œβ”€β”€ package.json       # Node.js dependencies
β”‚   └── README.md          # Detailed frontend documentation
β”œβ”€β”€ docs/                  # Project documentation
β”œβ”€β”€ LICENSE                # GNU AGPL v3.0 license
└── README.md             # This file

πŸ› οΈ Backend (Fully Implemented) βœ…

Complete FastAPI backend featuring:

  • Database: PostgreSQL 15 + PostGIS 3.5 for advanced geospatial operations
  • REST API: Comprehensive endpoints with OpenAPI/Swagger documentation
  • Authentication: OAuth2 Password Bearer + JWT tokens with Google/GitHub integration
  • OpenLR Service: Complete encoding/decoding for cross-platform compatibility
  • Spatial Queries: Advanced geospatial filtering, bounding box searches, and route analysis
  • Security: Rate limiting, CORS, input validation, and role-based access control

πŸ“– View Detailed Backend Documentation

🎨 Frontend (Fully Implemented) βœ…

Complete Next.js web application featuring:

  • Interactive Mapping: Leaflet.js-based map interface with OpenStreetMap tiles
  • Closure Reporting: Multi-step guided forms for accurate closure submission
  • Real-time Visualization: Live closure status with color-coded indicators
  • Mobile Responsive: Touch-optimized interface for field reporting
  • Authentication: JWT-based login with demo mode for testing
  • Edit Capabilities: Update and delete your own closure reports
  • Statistics Dashboard: Real-time analytics and closure insights

πŸ“– View Detailed Frontend Documentation

πŸ›£οΈ Closure-Aware Routing (Fully Implemented) βœ…

Advanced routing system featuring:

  • Transportation Modes: Car, bicycle, and pedestrian routing with mode-specific closure filtering
  • Valhalla Integration: Open-source routing engine for accurate path calculation
  • Smart Avoidance: Automatically avoid closures relevant to your transportation mode
  • Route Comparison: Side-by-side comparison of direct vs. closure-aware routes
  • Real-time Processing: Live calculation of optimal routes considering current closures

πŸ“– View Routing Documentation

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose (recommended for full setup)
  • Node.js 18+ (for frontend development)
  • Python 3.11+ (for backend development)
  • Git

1. Clone the Repository

git clone https://github.com/Archit1706/temporary-road-closures
cd temporary-road-closures

2. Start the Backend API

cd backend

# Copy environment configuration
cp .env.example .env

# Start all services with Docker
docker-compose up -d

# Verify services are running
docker-compose ps

3. Start the Frontend Application

cd frontend

# Install dependencies
npm install

# Configure environment
cp .env.example .env.local

# Start development server
npm run dev

4. Access the Applications

Available Services:

5. Test the System

# Health check
curl http://localhost:8000/health

# Try the web application
open http://localhost:3000

# Explore closure-aware routing
open http://localhost:3000/closure-aware-routing

For detailed setup instructions and development guides: πŸ‘‰ Backend Setup Guide πŸ‘‰ Frontend Setup Guide

πŸš€ Production Deployment

Prerequisites for Production

  • Server: Ubuntu 20.04+ or similar Linux distribution
  • Docker & Docker Compose: Latest stable versions
  • Domain Names: DNS configured for your domains (e.g., closures.osm.ch)
  • SSL Certificates: Let's Encrypt (automated setup included)

SSL Certificate Setup

The application includes automated SSL certificate management using Let's Encrypt:

  1. Initial Certificate Setup:

    # Install certbot on the host system
    sudo apt-get update
    sudo apt-get install certbot
    
    # Obtain certificates for your domains
    sudo certbot certonly --standalone \
      -d closures.osm.ch \
      -d api.closures.osm.ch \
      --email [email protected] \
      --agree-tos
  2. Automated Renewal:

    The docker-compose.prod.yml includes a certbot service that automatically renews certificates twice daily.

    Alternatively, use the provided renewal script:

    sudo ./scripts/renew_ssl.sh
  3. Troubleshooting Expired Certificates:

    If you see ERR_CERT_DATE_INVALID or similar SSL errors:

    # Renew certificates immediately
    sudo ./scripts/renew_ssl.sh
    
    # Or manually with certbot
    sudo certbot renew
    docker exec osm_closures_nginx_prod nginx -s reload

πŸ“– Complete SSL Certificate Setup Guide

Production Deployment Steps

  1. Clone and Configure:

    git clone https://github.com/Archit1706/temporary-road-closures
    cd temporary-road-closures
    cp .env.prod.example .env.prod
    # Edit .env.prod with your production settings
  2. Deploy Application:

    ./scripts/deploy_prod.sh
  3. Verify Services:

    docker-compose -f docker-compose.prod.yml ps
    curl https://closures.osm.ch
    curl https://api.closures.osm.ch/health

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Next.js Web   β”‚    β”‚  Closure-Aware  β”‚    β”‚   Navigation    β”‚
β”‚   Application   │◄──►│    Routing      │◄──►│     Apps        β”‚
β”‚   [Frontend]    β”‚    β”‚   [Frontend]    β”‚    β”‚  [Integration]  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚   FastAPI API   β”‚ ← βœ… **Complete**
                      β”‚   + OpenLR      β”‚
                      β”‚   + OAuth2      β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚  PostgreSQL +   β”‚ ← βœ… **Complete**
                      β”‚    PostGIS      β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Technology Stack

Frontend (βœ… Complete)

  • Framework: Next.js 15 with TypeScript and App Router
  • Mapping: Leaflet.js with React-Leaflet integration
  • Styling: Tailwind CSS v4 with responsive design
  • State Management: React Context API with useReducer
  • Forms: React Hook Form with multi-step validation
  • Icons: Lucide React icon library
  • HTTP Client: Axios with interceptors

Backend (βœ… Complete)

  • API Framework: FastAPI with async support and automatic documentation
  • Database: PostgreSQL 15 + PostGIS 3.5 for geospatial operations
  • Authentication: OAuth2 + JWT with Google/GitHub integration
  • Geospatial: PostGIS + GeoAlchemy2 for spatial queries
  • Location Encoding: OpenLR integration for cross-platform compatibility
  • Caching: Redis for performance optimization
  • Containerization: Docker + Docker Compose for easy deployment

Routing Integration (βœ… Complete)

  • Routing Engine: Valhalla open-source routing service
  • Transportation Modes: Auto, bicycle, and pedestrian support
  • Spatial Processing: Automatic closure filtering based on transportation mode
  • Route Optimization: Point exclusion and intelligent path finding

🌍 Real-World Usage Examples

πŸš— For Daily Commuters

Scenario: Morning commute to work during construction season

  1. Check Route: Use closure-aware routing to plan your commute
  2. Select Mode: Choose "Auto" for car-based routing
  3. Compare Options: See direct route vs. closure-aware route
  4. Make Decision: Choose route that avoids construction delays

πŸ—οΈ For City Departments

Scenario: Chicago Department of Transportation reporting water main repair

  1. Login: Authenticate with city credentials
  2. Report Closure: Use multi-step form to report road closure
  3. Set Details: Specify location, duration, and closure type
  4. Monitor: Track closure status and community feedback

πŸš΄β€β™€οΈ For Cyclists

Scenario: Bike commuter planning route through downtown

  1. Select Bicycle Mode: Choose transportation type for relevant filtering
  2. Route Planning: System automatically avoids car-only restrictions
  3. Bike Lane Awareness: Get notified of bike lane closures
  4. Safe Routing: Receive routes optimized for cycling safety

πŸ“± For Community Members

Scenario: Local resident spotting unexpected road closure

  1. Open App: Access the mobile-responsive web interface
  2. Quick Report: Submit closure report with location and photo
  3. Help Others: Contribute to community navigation knowledge
  4. Real-time Impact: Immediate availability for other users

πŸ“ˆ Development Timeline

Google Summer of Code 2025 - Completed Successfully:

  • βœ… Weeks 1-2: Project setup, database design, and initial API structure
  • βœ… Weeks 3-5: Core API implementation with authentication and CRUD operations
  • βœ… Weeks 6-7: OpenLR integration and advanced spatial query capabilities
  • βœ… Week 8: Midterm evaluation - Backend API complete and documented
  • βœ… Weeks 9-10: Frontend web application with interactive mapping and reporting
  • βœ… Weeks 11-12: Closure-aware routing implementation with Valhalla integration
  • βœ… Weeks 13-15: Testing, documentation, deployment guides, and project finalization

πŸ“Š Project Statistics

Backend Capabilities

  • 25+ API Endpoints with comprehensive OpenAPI documentation
  • Real-time Geospatial Queries with PostGIS optimization
  • OpenLR Integration for cross-platform location referencing
  • OAuth2 Authentication with multiple provider support
  • Rate Limiting and security best practices
  • Docker Containerization for easy deployment

Frontend Features

  • Interactive Mapping with Leaflet.js and OpenStreetMap tiles
  • Multi-step Forms with validation and progress tracking
  • Responsive Design optimized for mobile field reporting
  • Real-time Updates with live closure status calculation
  • Demo Mode with 25+ sample closures for testing
  • Closure-Aware Routing with transportation mode filtering

Community Impact

  • Open Source: All code available under AGPL-3.0 license
  • Standards Compliant: OpenLR, GeoJSON, and OSM compatibility
  • Scalable Architecture: Designed for community growth
  • Documentation: Comprehensive guides for users and developers

πŸ”— Links & Resources

πŸ“š Documentation

🌐 Project Resources

πŸ› οΈ Technical Resources

🀝 Contributing

This project welcomes contributions from the OpenStreetMap community and developers worldwide!

πŸ› οΈ Development Setup

  1. Fork the repository on GitHub
  2. Clone your fork locally
  3. Setup Backend: Follow instructions in ./backend/README.md
  4. Setup Frontend: Follow instructions in ./frontend/README.md
  5. Create a feature branch: git checkout -b feature/awesome-feature
  6. Make your changes and add comprehensive tests
  7. Document your changes in relevant README files
  8. Submit a pull request with detailed description

πŸ› Reporting Issues

πŸ’¬ Community

🎯 Contribution Areas

  • Backend Development: API enhancements, performance optimization, new endpoints
  • Frontend Development: UI/UX improvements, new features, mobile optimization
  • Documentation: User guides, API documentation, setup instructions
  • Testing: Integration tests, performance testing, user acceptance testing
  • Localization: Multi-language support for international OSM community
  • Integration: Connections with other OSM tools and navigation applications

πŸ‘₯ Team

πŸŽ“ Google Summer of Code 2025

πŸ›οΈ Host Organization

OpenStreetMap Foundation

  • Supporting open geographic data and collaborative mapping
  • Enabling navigation innovation through open standards
  • Fostering community-driven geospatial solutions

πŸ“„ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

View Full License

πŸ”“ Open Source Commitment

  • Free Software: Always free to use, modify, and distribute
  • Copyleft: Modifications must be shared under AGPL-3.0
  • Network Use: Server-side modifications must be disclosed
  • Commercial Use: Permitted with license compliance
  • Community Driven: Open development and transparent governance

πŸ™ Acknowledgments

🌟 Special Thanks

🌍 Community

  • OSM Community Worldwide for feedback, testing, and real-world validation
  • OsmAnd Developers for navigation integration discussions
  • OpenLR Working Group for location referencing standards
  • Chicago Department of Transportation for testing data and use cases
  • React and TypeScript Communities for development best practices
  • Open Source Contributors who made this project possible

πŸš€ Getting Started

Ready to explore the Temporary Road Closures system?

πŸ”₯ For Developers

  1. Setup the Backend - Complete development environment
  2. Setup the Frontend - Web application development
  3. Explore the API - Interactive documentation
  4. Join the Community - Connect with other contributors

πŸ—ΊοΈ For OSM Community

  1. Learn About the Project - OSM diary updates
  2. Try the Web App - Experience the complete interface
  3. Test Closure-Aware Routing - Advanced routing features
  4. Provide Feedback - Help shape the future

🏒 For Organizations

  1. Review Integration Examples - Connect your systems
  2. Understand OpenLR - Cross-platform compatibility
  3. Explore API Capabilities - Integration possibilities
  4. Contact the Team - Discuss your specific use case

πŸš΄β€β™€οΈ For End Users

  1. Visit the Application - Start reporting closures
  2. Try Demo Mode - No login required for testing
  3. Learn Closure-Aware Routing - Better route planning
  4. Read User Guide - Comprehensive documentation

πŸ† Project Success

This Google Summer of Code 2025 project has successfully delivered:

βœ… Complete Backend System

  • Production-ready FastAPI with comprehensive documentation
  • PostgreSQL + PostGIS database with optimized spatial queries
  • OpenLR integration for cross-platform compatibility
  • OAuth2 authentication with multiple providers
  • Rate limiting, security, and monitoring capabilities

βœ… Full Frontend Application

  • Next.js 15 web application with TypeScript
  • Interactive mapping with closure visualization
  • Multi-step closure reporting forms
  • Real-time status tracking and analytics
  • Mobile-responsive design for field use

βœ… Advanced Routing System

  • Closure-aware route calculation
  • Transportation mode filtering (auto, bicycle, pedestrian)
  • Valhalla routing engine integration
  • Real-time route comparison and optimization

🎯 Community Impact

  • Open-source solution for the OSM ecosystem
  • Standards-compliant implementation (OpenLR, GeoJSON)
  • Comprehensive documentation for users and developers
  • Foundation for future navigation app integration

🌟 Star this repository if you find it useful for the OpenStreetMap ecosystem!

πŸ“’ Follow development progress in the OSM diary and GitHub discussions.

πŸš€ Try the live demo by following the Quick Start guide above.


Building the future of open navigation data, one closure at a time. πŸ—ΊοΈβœ¨

"Temporary closures, permanent solutions" - Making OSM navigation smarter for everyone.

About

Temporary Road Closures Database and API - GSOC 2025

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •