Tokyo traffic data collection and analysis system using ODPT API
Project description
๐ MCP Traffic - Tokyo Traffic Data Collection System
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 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
- ๐ Live Dashboard - Interactive Tokyo traffic visualization
- ๐ Dashboard User Guide - Complete tutorial and help
- ๐ Project Website - Main documentation site
๐ Technical Documentation
- Deployment Guide: Complete deployment instructions
- API Documentation: API reference and examples
- Configuration Guide: System configuration options
- Troubleshooting: Common issues and solutions
๐ 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
- Code Style: Follow PEP 8 for Python, use meaningful variable names
- Testing: Add tests for new functionality
- Documentation: Update documentation for changes
- 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
- Documentation: Check the docs/ directory
- Issues: Search existing issues
- Discussions: Join GitHub Discussions
- 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
- ODPT (Open Data Platform for Transportation): Primary data source
- Tokyo Metropolitan Government: Open data initiatives
- Transportation Operators: Real-time operational data
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.
For more information, visit the project website or check out the live dashboard!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20ae8a8a5121533f1fedce23e15753b4f4713ea38ac2a42d1fa5f07b92dbfd9e
|
|
| MD5 |
72a44fd53db751b987ee87ff5fab81ce
|
|
| BLAKE2b-256 |
4baebeb0c90faba42524afedeedc28fbc0b1787e6b63f37163045c1df40fbb9b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b94d9efd649d11c5860e4a2e6b6069e2b7091c9c22fe3408f459edc50e96cd97
|
|
| MD5 |
b257f7e33e9c940056854dda24836a19
|
|
| BLAKE2b-256 |
c7332e7fda8764b01e9aa1201880b920c71c79981a4783424046387c3fcf23ae
|