Comprehensive real-time public transportation information system for Costa Rica
InfobΓΊs is a modern Django-based platform that processes GTFS Schedule and Realtime feeds to deliver live transit information across multiple channels. Designed for Universidad de Costa Rica (UCR), it provides real-time passenger information through digital displays at bus stops and stations, APIs, and web interfaces.
InfobΓΊs is a production-ready, containerized platform that transforms raw GTFS transit data into accessible, real-time information for passengers across Costa Rica. The system processes multiple data sources and delivers information through various channels including digital displays, mobile apps, and web interfaces.
- π Real-time Transit Updates: Live arrival/departure information from GTFS Realtime feeds
- πΊ Digital Display Network: Geographic screen management with PostGIS integration
- π Live Data Streaming: WebSocket-powered real-time updates to connected devices
- π’ Multi-agency Support: Unified platform for multiple transit providers
- π¦οΈ Weather Integration: Location-based weather information for displays
- π± Social Media Integration: Curated transit-related social content
- π Emergency Alerts: CAP (Common Alerting Protocol) integration for critical updates
- Containerized Deployment: Docker-based dev/production environments
- Scalable Architecture: Nginx reverse proxy with load balancing ready
- High Availability: Redis-backed caching and session management
- Security Hardened: Rate limiting, security headers, and container isolation
- Monitoring Ready: Health check endpoints and structured logging
- GTFS Realtime Integration: Vehicle positions, trip updates, and service alerts
- Background Task Processing: Celery-powered async data collection
- Geospatial Analysis: PostGIS-enabled location-based services
- Data Validation: Robust data quality checks and error handling
- Multi-source Aggregation: Unified data from various transit agencies
- Geographic Screen Positioning: GPS-coordinated display locations
- Dynamic Content Rendering: Context-aware information display
- WebSocket Live Updates: Real-time screen content synchronization
- Kiosk Mode Support: Raspberry Pi deployment optimizations
- Responsive Design: Multi-device and screen size support
- Django 5.2+: Modern Python web framework with GeoDjango/PostGIS
- Django REST Framework: RESTful API development
- Django Channels: WebSocket support for real-time features
- Daphne ASGI Server: Production-ready async server
- Python 3.12+: Latest Python with modern async support
- PostgreSQL 16: Primary database with ACID compliance
- PostGIS 3.4: Advanced geospatial data processing
- Redis 7: High-performance caching and message broker
- Docker Volumes: Persistent data storage
- Docker & Docker Compose: Containerized development and production
- Nginx: Reverse proxy with security headers and rate limiting
- Multi-stage Builds: Optimized container images
- uv: Fast Python package management
- Celery: Distributed task processing
- Celery Beat: Periodic task scheduling
- WebSockets: Live data streaming to displays
- GTFS Realtime: Transit data processing bindings
- Environment-based Config: Secure secrets management
- Rate Limiting: API and admin protection
- Security Headers: OWASP recommended protections
- Health Checks: Application and service monitoring
-
Clone the repository
git clone https://github.com/simovilab/infobus.git cd infobus -
Initialize submodules
git submodule update --init --recursive
-
Start development environment
./scripts/dev.sh
This single command will:
- π¦ Build all Docker containers
- πΎ Set up PostgreSQL with PostGIS
- π Start Redis for caching
- βοΈ Run database migrations
- π₯ Create admin user (admin/admin)
- π Launch the development server with hot reload
-
Access the application
- Website: http://localhost:8000
- Admin Panel: http://localhost:8000/admin (admin/admin)
- API: http://localhost:8000/api/
-
Configure production environment
# Copy and edit production settings cp .env.prod.example .env.prod # Generate a secure SECRET_KEY python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
-
Start production environment
./scripts/prod.sh
Production includes:
- π Nginx reverse proxy with SSL-ready config
- π‘οΈ Security headers and rate limiting
- π Performance optimizations and caching
- π Health check endpoints
-
Access production
- Website: http://localhost (via Nginx)
- Admin: http://localhost/admin
- Health Check: http://localhost/health/
# View logs
docker-compose logs -f
# Run Django commands
docker compose exec web uv run python manage.py migrate
docker compose exec web uv run python manage.py createsuperuser
docker compose exec web uv run python manage.py shell
# Run tests
docker compose exec web uv run python manage.py test
# Stop all services
docker compose downπ Internet β πͺ Nginx (Port 80) β π Django/Daphne (Port 8000)
β
πΎ PostgreSQL (PostGIS)
β
π΄ Redis β π Celery Workers/Beat
- π‘ Data Collection: Celery tasks periodically fetch GTFS Realtime feeds from transit agencies
- βοΈ Data Processing: Information is validated, processed, and classified by screen relevance
- πΆ Real-time Distribution: Django Channels WebSockets push live updates to connected displays
- π₯οΈ Display Rendering: Raspberry Pi devices in kiosk mode render the passenger information
website: Main site pages, user management, and public interfacesalerts: Screen management, real-time data display via WebSocketsgtfs: GTFS Schedule and Realtime data management (submodule: django-app-gtfs)feed: Information service providers and WebSocket consumersapi: RESTful API endpoints with DRF integration
/api/- Main API endpoints with DRF browsable interface/api/gtfs/- GTFS Schedule and Realtime data/api/alerts/- Screen management and alert systems/api/weather/- Weather information for display locations
/ws/alerts/- Real-time screen updates/ws/feed/- Live transit data streaming
infobus/
βββ π scripts/ # Management scripts (dev.sh, prod.sh)
βββ π nginx/ # Nginx configuration
βββ π datahub/ # Django project settings
βββ π website/ # Main web application
βββ π alerts/ # Display and alert management
βββ π gtfs/ # GTFS data processing (submodule)
βββ π feed/ # Data feed management
βββ π api/ # REST API endpoints
βββ π¦ docker-compose.yml # Development environment
βββ π¦ docker-compose.production.yml # Production environment
βββ π Dockerfile # Multi-stage container build
βββ π WARP.md # AI assistant guidance
.env- Base configuration (committed).env.dev- Development overrides (committed).env.prod- Production template (committed, no secrets).env.local- Local secrets (git-ignored)
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test with
./scripts/dev.sh - Run security scan:
gitleaks detect --source . --verbose - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- βοΈ Cloud Platforms: AWS, GCP, Azure with Docker
- π₯οΈ VPS Deployment: Ubuntu/CentOS with Docker Compose
- π₯° Raspberry Pi: Kiosk mode for display devices
- π» Local Development: Full-featured local environment
- Generate secure
SECRET_KEYin production - Update database passwords
- Configure domain names in
ALLOWED_HOSTS - Set up SSL certificates
- Configure backup strategy
- Set up monitoring and logging
- Test health check endpoints
- Documentation: See
WARP.mdfor detailed guidance - Scripts: Use
./scripts/dev.sh --helpfor command help - Health Checks: Monitor
/health/endpoint in production - Logs: Use
docker-compose logs -ffor troubleshooting
Universidad de Costa Rica (UCR) | Laboratorio SIMOVI | Costa Rica