Skip to main content

Tokyo traffic data collection and analysis system using ODPT API

Project description

๐Ÿš‡ MCP Traffic - Tokyo Traffic Data Collection System

Deploy Jekyll site to Pages GitHub Pages GitHub stars GitHub forks

Real-time Tokyo transportation data collection and visualization system using ODPT API


๐ŸŽฏ Live Dashboard & Demo

๐Ÿ“Š ๐Ÿ”ด LIVE Tokyo Traffic Dashboard

Interactive real-time visualization of Tokyo's transportation network

Dashboard Preview User Guide Project Website

โœจ Dashboard Features

  • ๐Ÿ—บ๏ธ Interactive Tokyo Station Map with real-time markers
  • ๐Ÿ“ˆ Live Charts & Metrics showing passenger flow and performance
  • ๐Ÿš‚ Real-time Train Tracking with delay status
  • ๐ŸšŒ Bus Route Monitoring with live positions
  • ๐Ÿ“ฑ Mobile Responsive design for all devices
  • โšก Auto-refresh with 30-second data updates

๐Ÿ“Š Current System Status

๐Ÿ”ด LIVE: Tokyo Transportation Monitor
โ”œโ”€โ”€ Daily Passengers: 2.15M across 5 major stations
โ”œโ”€โ”€ System Performance: 94.2% punctuality rate
โ”œโ”€โ”€ Average Delay: 1.0 minutes
โ””โ”€โ”€ Active Alerts: 0 service disruptions

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • Git
  • Ruby 3.1+ (for Jekyll documentation)

Installation

# Clone the repository
git clone https://github.com/Tatsuru-Kikuchi/MCP-traffic.git
cd MCP-traffic

# Set up Python environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install Python dependencies
pip install -r requirements.txt

# Set up Jekyll for documentation
bundle install

# Configure the system
cp config/api_config.example.json config/api_config.json
# Edit config/api_config.json with your ODPT API settings

Running the System

# Test the installation
python src/collectors/traffic_collector.py --catalog-only

# Run a single data collection
python scripts/collect_all_data.py

# Start continuous scheduled collection
python scripts/schedule_collection.py

# Serve documentation locally
bundle exec jekyll serve

๐Ÿ“Š What is MCP Traffic?

A comprehensive Tokyo traffic data collection and analysis system that leverages the ODPT (Open Data Platform for Transportation) API to gather, process, and monitor real-time transportation data across Tokyo's extensive public transit network.

MCP Traffic (Model Control Protocol for Traffic) is an automated system designed for:

  • ๐Ÿ”„ Real-time Data Collection: Continuous gathering of Tokyo transportation data
  • โšก Data Processing: Automated cleaning, validation, and transformation
  • ๐Ÿ“ˆ Analysis & Monitoring: Traffic pattern analysis and system health monitoring
  • ๐Ÿ—„๏ธ Data Management: Organized storage with automatic archiving
  • ๐Ÿ“š Documentation: Comprehensive guides and API documentation

๐Ÿ—๏ธ System Architecture

Data Flow

ODPT API โ†’ Data Collectors โ†’ Data Processors โ†’ Storage โ†’ Analysis
    โ†“              โ†“              โ†“            โ†“         โ†“
Raw Data โ†’ Validation โ†’ Transformation โ†’ Archive โ†’ Insights

Directory Structure

MCP-traffic/
โ”œโ”€โ”€ src/                    # Source code
โ”‚   โ”œโ”€โ”€ collectors/         # Data collection modules
โ”‚   โ””โ”€โ”€ processors/         # Data processing utilities
โ”œโ”€โ”€ data/                   # Data storage
โ”‚   โ”œโ”€โ”€ raw/               # Original API responses
โ”‚   โ”œโ”€โ”€ processed/         # Cleaned data
โ”‚   โ””โ”€โ”€ archives/          # Historical data
โ”œโ”€โ”€ scripts/               # Automation scripts
โ”œโ”€โ”€ config/                # Configuration files
โ”œโ”€โ”€ monitoring/            # Health checks and alerts
โ”œโ”€โ”€ logs/                  # System logs
โ”œโ”€โ”€ docs/                  # Documentation
โ””โ”€โ”€ .github/workflows/     # CI/CD workflows

๐Ÿ”ง Configuration

API Configuration

Edit config/api_config.json:

{
  "odpt_api": {
    "base_url": "https://ckan.odpt.org/api/3/action/",
    "api_key": "your-api-key",
    "rate_limit": 100,
    "timeout": 30
  },
  "collection": {
    "schedule_interval": 300,
    "data_types": ["train", "bus", "station"],
    "regions": ["tokyo"]
  },
  "storage": {
    "format": "json",
    "compression": true,
    "retention_days": 365
  }
}

Jekyll Configuration

The documentation site is configured in _config.yml with:

  • GitHub Pages deployment
  • SEO optimization
  • Responsive design
  • Multi-language support

๐Ÿ“ˆ Data Collection Features

Supported Data Types

  • ๐Ÿš† Train Data: Real-time positions, delays, service status
  • ๐ŸšŒ Bus Data: Vehicle locations, route information, schedules
  • ๐Ÿข Station Data: Facility information, accessibility features
  • ๐Ÿ—บ๏ธ Route Data: Network topology, connections, fare information
  • ๐Ÿ“Š Operational Data: Service disruptions, maintenance schedules

Collection Strategies

  • Scheduled Collection: Automated data gathering at configurable intervals
  • On-demand Collection: Manual collection for specific data types
  • Error Recovery: Robust retry mechanisms with exponential backoff
  • Rate Limiting: Compliance with API usage policies

๐Ÿ–ฅ๏ธ Deployment Options

Local Development

# Standard Python development setup
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python scripts/collect_all_data.py

Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

# Monitor logs
docker-compose logs -f mcp-traffic

Server Deployment

# Install as systemd service
sudo cp deployment/mcp-traffic.service /etc/systemd/system/
sudo systemctl enable mcp-traffic
sudo systemctl start mcp-traffic

Cloud Deployment

  • AWS: EC2 + S3 + CloudWatch
  • Google Cloud: Compute Engine + Cloud Storage
  • Azure: Virtual Machines + Blob Storage

See the Deployment Guide for detailed instructions.

๐Ÿ“Š Monitoring & Health Checks

System Monitoring

  • API Connectivity: Continuous monitoring of ODPT API availability
  • Data Quality: Validation and completeness checks
  • Storage Usage: Disk space monitoring with alerts
  • Performance Metrics: Response times and throughput tracking

Health Check Commands

# System health overview
python monitoring/health_check.py

# Detailed performance metrics
python monitoring/performance_monitor.py

# Data quality report
python monitoring/data_quality_check.py

Alerting

  • Email notifications for system failures
  • Slack integration for real-time alerts
  • Custom webhook support for external monitoring

๐Ÿ” Data Analysis Tools

Built-in Analytics

  • Traffic pattern analysis
  • Peak hour identification
  • Service reliability metrics
  • Historical trend analysis

Integration Options

  • Jupyter Notebooks: Interactive data exploration
  • Pandas/NumPy: Statistical analysis
  • Matplotlib/Plotly: Data visualization
  • Apache Spark: Large-scale data processing

๐Ÿ“š Documentation & Links

๐ŸŽฏ Main Dashboard Links

๐Ÿ“‹ Technical Documentation

๐Ÿ” Security & Privacy

Data Privacy

  • No Personal Data: Only collects aggregate transportation data
  • Anonymized Data: All data is inherently anonymous
  • Compliance: Adheres to data protection regulations

Security Features

  • API key encryption
  • Secure configuration management
  • Network security best practices
  • Regular security updates

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

Development Setup

# Fork and clone the repository
git clone https://github.com/YOUR-USERNAME/MCP-traffic.git
cd MCP-traffic

# Create development branch
git checkout -b feature/your-feature-name

# Set up development environment
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt

# Run tests
python -m pytest tests/

Contribution Guidelines

  1. Code Style: Follow PEP 8 for Python, use meaningful variable names
  2. Testing: Add tests for new functionality
  3. Documentation: Update documentation for changes
  4. Commits: Use clear, descriptive commit messages

Types of Contributions

  • ๐Ÿ› Bug Fixes: Report and fix issues
  • โœจ Features: New functionality and improvements
  • ๐Ÿ“š Documentation: Improve guides and examples
  • ๐Ÿงช Testing: Enhance test coverage
  • ๐Ÿ”ง DevOps: Improve deployment and CI/CD

๐Ÿ“„ License

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

๐Ÿ†˜ Support

Getting Help

  1. Documentation: Check the docs/ directory
  2. Issues: Search existing issues
  3. Discussions: Join GitHub Discussions
  4. Dashboard Help: Read the User Guide

Reporting Issues

When reporting issues, please include:

  • Operating system and Python version
  • Error messages and stack traces
  • Steps to reproduce the issue
  • Configuration (without sensitive data)

๐Ÿ† Acknowledgments

Data Sources

Technology Stack

  • Python: Core programming language
  • Jekyll: Documentation site generator
  • GitHub Actions: CI/CD and deployment
  • Docker: Containerization
  • Chart.js: Interactive data visualization
  • Leaflet: Interactive mapping

Community

Special thanks to all contributors who have helped improve this project through code, documentation, testing, and feedback.


๐ŸŽฏ Ready to Explore Tokyo's Transportation System?

Launch Dashboard Read Guide

๐Ÿ”ด LIVE Demo Available Now!


GitHub issues GitHub pull requests Last commit

For more information, visit the project website or check out the live dashboard!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_traffic-1.0.0.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_traffic-1.0.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file mcp_traffic-1.0.0.tar.gz.

File metadata

  • Download URL: mcp_traffic-1.0.0.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mcp_traffic-1.0.0.tar.gz
Algorithm Hash digest
SHA256 20ae8a8a5121533f1fedce23e15753b4f4713ea38ac2a42d1fa5f07b92dbfd9e
MD5 72a44fd53db751b987ee87ff5fab81ce
BLAKE2b-256 4baebeb0c90faba42524afedeedc28fbc0b1787e6b63f37163045c1df40fbb9b

See more details on using hashes here.

File details

Details for the file mcp_traffic-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_traffic-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mcp_traffic-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b94d9efd649d11c5860e4a2e6b6069e2b7091c9c22fe3408f459edc50e96cd97
MD5 b257f7e33e9c940056854dda24836a19
BLAKE2b-256 c7332e7fda8764b01e9aa1201880b920c71c79981a4783424046387c3fcf23ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page