π InfobΓΊs
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.
π Overview
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.
Key Capabilities
- π 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
β¨ Features
π Production Infrastructure
- 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
π‘ Real-time Data Processing
- 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
π₯οΈ Display Management
- 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
π οΈ Technology Stack
π Backend & APIs
- 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
π Data & Storage
- 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
πͺ Infrastructure & Deployment
- 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
π Real-time & Background Processing
- Celery: Distributed task processing
- Celery Beat: Periodic task scheduling
- WebSockets: Live data streaming to displays
- GTFS Realtime: Transit data processing bindings
π Security & Monitoring
- Environment-based Config: Secure secrets management
- Rate Limiting: API and admin protection
- Security Headers: OWASP recommended protections
- Health Checks: Application and service monitoring
π Quick Start
Prerequisites
π οΈ Development Setup (Recommended)
-
Clone the repository
bash git clone https://github.com/simovilab/infobus.git cd infobus -
Initialize submodules
bash git submodule update --init --recursive -
Start development environment
bash ./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/
π Production Deployment
-
Configure production environment
bash # 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
bash ./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/
π Common Commands
# 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
π§ Architecture
π Service Architecture
π Internet β πͺ Nginx (Port 80) β π Django/Daphne (Port 8000)
β
πΎ PostgreSQL (PostGIS)
β
π΄ Redis β π Celery Workers/Beat
π Data Flow
- π‘ 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
π± Application Structure
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 Documentation
REST API Endpoints
/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
WebSocket Endpoints
/ws/alerts/- Real-time screen updates/ws/feed/- Live transit data streaming
π οΈ Development
Project Structure
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
Environment Configuration
.env- Base configuration (committed).env.dev- Development overrides (committed).env.prod- Production template (committed, no secrets).env.local- Local secrets (git-ignored)
Contributing
- 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
π’ Production Deployment
Deployment Options
- βοΈ 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
Security Checklist
- [ ] 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
π« Support & Community
Getting Help
- 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