Skip to content
/ infobus Public
forked from simovilab/infobus

Information distribution platform providing GraphQL and REST APIs for passenger transit information services

License

Notifications You must be signed in to change notification settings

OJEM22/infobus

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

179 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚌 Infobús

Ruff License: Apache 2.0 Python 3.12+ Django 5.2+ Docker

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

  • Docker Desktop (Download)
  • Git (Download)
  • 8GB+ RAM recommended for all services

πŸ› οΈ Development Setup (Recommended)

  1. Clone the repository

    git clone https://github.com/simovilab/infobus.git
    cd infobus
  2. Initialize submodules

    git submodule update --init --recursive
  3. 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
  4. Access the application

🏭 Production Deployment

  1. 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())"
  2. 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
  3. Access production

πŸ“ 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

  1. πŸ“‘ Data Collection: Celery tasks periodically fetch GTFS Realtime feeds from transit agencies
  2. βš™οΈ Data Processing: Information is validated, processed, and classified by screen relevance
  3. πŸ“Ά Real-time Distribution: Django Channels WebSockets push live updates to connected displays
  4. πŸ–₯️ Display Rendering: Raspberry Pi devices in kiosk mode render the passenger information

πŸ’± Application Structure

  • website: Main site pages, user management, and public interfaces
  • alerts: Screen management, real-time data display via WebSockets
  • gtfs: GTFS Schedule and Realtime data management (submodule: django-app-gtfs)
  • feed: Information service providers and WebSocket consumers
  • api: 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

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test with ./scripts/dev.sh
  4. Run security scan: gitleaks detect --source . --verbose
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. 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_KEY in 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.md for detailed guidance
  • Scripts: Use ./scripts/dev.sh --help for command help
  • Health Checks: Monitor /health/ endpoint in production
  • Logs: Use docker-compose logs -f for troubleshooting

Built With Love ❀️

Universidad de Costa Rica (UCR) | Laboratorio SIMOVI | Costa Rica

About

Information distribution platform providing GraphQL and REST APIs for passenger transit information services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 36.6%
  • CSS 28.7%
  • Python 21.0%
  • Shell 11.2%
  • HTML 1.9%
  • Dockerfile 0.6%