tpt-transport

PHP

Open-source public transportation platform for cities & municipalities — real-time GPS fleet tracking, multi-modal journey planning, fare management, driver & passenger PWA. PHP + PostgreSQL + PostGIS. MIT.

0 stars0 forks0 watchersMIT License
gps-trackingjourney-planningmunicipalitiesopen-sourcephppostgispostgresqlpublic-transportpwatransit

Languages

PHP68.1%JavaScript16.6%Shell5.9%HTML5.7%CSS3.7%Dockerfile0.0%
README

🚌 TPT Transport Platform

License: MIT PHP Version Node.js Version Docker

A comprehensive, open-source public transportation platform designed specifically for cities, municipalities, and transport authorities. Unlike ride-sharing services, TPT Transport provides a complete solution for managing scheduled public transport services, real-time transit information, and passenger management systems. Built with modern technologies and optimized for high performance and scalability.

🎯 Public Transport Focus

Designed for Municipalities & Transport Authorities

TPT Transport is specifically engineered for public transportation systems, not ride-sharing services. It's a complete solution that helps cities and transport operators:

  • Manage Bus/Train/Tram Networks - Schedule management, route optimization, and fleet tracking
  • Real-time Passenger Information - Live updates, delay notifications, and service disruptions
  • Multi-modal Integration - Unified system for buses, trains, trams, and other public transport modes
  • Fare Management - Integrated ticketing, fare calculation, and revenue collection
  • Passenger Services - Journey planning, accessibility features, and customer support

Key Differences from Ride-Sharing

| Feature | TPT Transport (Public) | Ride-Sharing (Private) | |---------|----------------------|----------------------| | Target Users | General public, daily commuters | Individual travelers | | Service Model | Scheduled, fixed routes | On-demand, flexible routes | | Business Model | Municipal service, fare collection | Private company, commission-based | | Scale | City-wide infrastructure | Individual ride requests | | Integration | Multi-modal transport systems | Standalone ride service | | Accessibility | Universal design requirements | Commercial service standards |

🌟 Features

🚀 Core Platform Features

  • Real-time Transit Information: Live bus/train locations, arrival times, and service updates
  • Multi-modal Transport Integration: Unified system for buses, trains, trams, and ferries
  • GPS Fleet Tracking: Real-time vehicle location monitoring and geofencing
  • Fare Management System: Integrated ticketing, fare calculation, and revenue collection
  • Service Quality Monitoring: Performance tracking, delay notifications, and passenger feedback
  • Route Optimization: AI-powered scheduling and route planning for efficiency

📱 Progressive Web Applications

  • Passenger PWA: Cross-platform web app with native app-like experience
  • Driver PWA: Dedicated driver interface with earnings tracking
  • Admin Dashboard: Comprehensive management and analytics platform

🔒 Security & Compliance

  • End-to-end Encryption: All communications and data encrypted
  • GDPR Compliance: Privacy-first design with data anonymization
  • Fraud Detection: Advanced algorithms to prevent fraudulent activities
  • Audit Logging: Complete audit trail for all transactions
  • Device Fingerprinting: Enhanced security with device recognition

📊 Analytics & Insights

  • Real-time Analytics: Live dashboard with key performance indicators
  • Revenue Tracking: Detailed financial reporting and analytics
  • User Behavior Analysis: Insights into user patterns and preferences
  • Performance Monitoring: System health and performance metrics

🛠️ Developer Experience

  • RESTful API: Well-documented API with OpenAPI specification
  • SDK Support: PHP, JavaScript, and mobile SDKs
  • Webhook Integration: Real-time event notifications
  • Plugin Architecture: Extensible with custom plugins and modules

🏗️ Architecture

TPT Transport Platform
├── backend/                 # PHP API Backend
│   ├── src/Core/           # Core business logic
│   ├── src/Api/            # REST API controllers
│   ├── src/Models/         # Data models
│   └── config/             # Configuration files
├── frontend/               # Web Applications
│   ├── passenger/          # Passenger PWA
│   └── driver/             # Driver PWA
├── admin/                  # Admin Dashboard
├── database/               # Database schema & migrations
├── docs/                   # Documentation
├── scripts/                # Deployment & setup scripts
├── tests/                  # Test suites
└── tpt-transport-landing-page/  # WordPress Plugin

🚀 Quick Start

Prerequisites

  • Docker & Docker Compose (recommended)
  • PHP 8.1+ with extensions: pdo, pdo_pgsql, mbstring, gd, redis
  • PostgreSQL 13+ with PostGIS extension
  • Redis 6+ for caching
  • Node.js 18+ for frontend builds
  • Composer for PHP dependencies

Installation

Option 1: Docker (Recommended)

# Clone the repository
git clone https://github.com/PhillipC05/tpt-transport.git
cd tpt-transport

# Start all services
docker-compose up -d

# Run database migrations
docker-compose exec backend php setup.php

# Build frontend assets
docker-compose exec frontend npm run build

Option 2: Manual Installation

# Clone and setup backend
git clone https://github.com/PhillipC05/tpt-transport.git
cd tpt-transport/backend

# Install PHP dependencies
composer install

# Setup database
php setup.php

# Configure environment
cp config/config.php.example config/config.php
# Edit config.php with your database credentials

# Setup frontend
cd ../frontend/passenger
npm install
npm run build

Configuration

Create a .env file in the backend directory:

# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=tpt_transport
DB_USER=your_db_user
DB_PASSWORD=your_db_password

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=

# JWT Configuration
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRE=3600

# Payment Configuration
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...

# Email Configuration
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASSWORD=your_app_password

# CDN Configuration (optional)
CDN_URL=https://cdn.tpt-transport.com
CDN_ENABLED=true

📖 Documentation

📚 Available Documentation

🔗 Quick Links

🧪 Testing

Running Tests

# Backend tests
cd backend
composer test

# Frontend tests
cd frontend/passenger
npm test

# E2E tests
cd tests/E2E
npm run test:e2e

Test Coverage

  • Unit Tests: Core business logic testing
  • Integration Tests: API endpoint testing
  • E2E Tests: Full user journey testing
  • Security Tests: Penetration testing and vulnerability assessment
  • Load Tests: Performance and scalability testing

🚀 Deployment

Production Deployment

# Build production images
docker-compose -f docker-compose.prod.yml build

# Deploy to production
docker-compose -f docker-compose.prod.yml up -d

# Run database migrations
docker-compose -f docker-compose.prod.yml exec backend php setup.php

# Setup monitoring
docker-compose -f docker-compose.prod.yml exec backend php scripts/setup-monitoring.sh

Environment Setup Scripts

  • scripts/setup-production.sh - Production server setup
  • scripts/setup-cdn.sh - CDN configuration
  • scripts/setup-monitoring.sh - Monitoring and logging setup
  • scripts/setup-ssl.sh - SSL certificate setup

🔧 API Usage

Authentication

# Login
curl -X POST https://api.tpt-transport.com/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"password"}'

# Response
{
  "success": true,
  "data": {
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
    "user": {
      "id": 1,
      "name": "John Doe",
      "email": "user@example.com"
    }
  }
}

Get Real-time Transit Information

curl -X GET "https://api.tpt-transport.com/transit/stops/123/arrivals" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json"

Plan a Journey

curl -X POST https://api.tpt-transport.com/journey/plan \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {
      "lat": -36.8485,
      "lng": 174.7633,
      "address": "Auckland CBD"
    },
    "to": {
      "lat": -36.8509,
      "lng": 174.7645,
      "address": "Auckland Airport"
    },
    "departure_time": "2025-09-11T14:30:00Z",
    "modes": ["bus", "train", "walk"]
  }'

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Make your changes and add tests
  4. Run the test suite: composer test && npm test
  5. Submit a pull request

Code Standards

  • PHP: PSR-12 coding standards
  • JavaScript: ESLint with Airbnb config
  • CSS: BEM methodology
  • Testing: PHPUnit for PHP, Jest for JavaScript

📊 Performance Optimizations

Database Optimizations

  • Composite indexes for common query patterns
  • Query result caching with Redis
  • Connection pooling for high concurrency
  • Spatial indexes for location-based queries

Frontend Optimizations

  • Code splitting with webpack
  • Lazy loading for images and components
  • Service worker for offline functionality
  • CDN integration for static assets

Backend Optimizations

  • OPcache configuration for PHP
  • JIT compilation for performance
  • HTTP/2 and gzip compression
  • Database query optimization

🔒 Security

Security Features

  • Input Validation: Comprehensive input sanitization
  • Authentication: JWT-based authentication with refresh tokens
  • Authorization: Role-based access control (RBAC)
  • Encryption: End-to-end encryption for sensitive data
  • Rate Limiting: DDoS protection and abuse prevention
  • Audit Logging: Complete audit trail for compliance

Security Best Practices

  • Regular security audits and penetration testing
  • Dependency vulnerability scanning
  • Secure coding practices and code reviews
  • Regular security updates and patches

📈 Monitoring & Analytics

System Monitoring

  • Application Performance: Response times and error rates
  • Database Performance: Query performance and connection pooling
  • Server Resources: CPU, memory, and disk usage
  • User Activity: Real-time user behavior analytics

Business Analytics

  • Revenue Tracking: Payment processing and financial metrics
  • User Engagement: App usage and feature adoption
  • Geographic Analysis: Service area performance
  • Driver Performance: Earnings, ratings, and efficiency metrics

🌍 Internationalization

Supported Languages

  • English (en)
  • Spanish (es)
  • French (fr)
  • German (de)
  • Italian (it)
  • Portuguese (pt)
  • Chinese (zh)
  • Japanese (ja)
  • Korean (ko)
  • Arabic (ar)
  • Hindi (hi)
  • Bengali (bn)
  • Urdu (ur)
  • Turkish (tr)
  • Tamil (ta)
  • Telugu (te)
  • Marathi (mr)
  • Vietnamese (vi)
  • Thai (th)
  • Persian (fa)
  • Malay (ms)

Translation Management

// Add translation strings
__('Hello, World!', 'tpt-transport');

// Load language files
load_plugin_textdomain('tpt-transport', false, dirname(plugin_basename(__FILE__)) . '/languages/');

📞 Support

Getting Help

  • Documentation: Check our comprehensive docs
  • GitHub Issues: Report bugs and request features
  • Community Forum: Join discussions with other developers
  • Professional Support: Enterprise support available

Contact Information

  • Email: admin@transport.tptsolutions.co.nz
  • Website: https://tpt-transport.com
  • GitHub: https://github.com/PhillipC05/tpt-transport

📄 License

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

TPT Transport Platform
Copyright (c) 2025 TPT Transport

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

🙏 Acknowledgments

Core Contributors

  • TPT Solutions Team: Platform architecture and development
  • Open Source Community: Libraries, frameworks, and tools

Technologies Used

  • Backend: PHP 8.1+, PostgreSQL, Redis, Nginx
  • Frontend: JavaScript ES6+, React, Webpack
  • Progressive Web Apps: Service Workers, Web App Manifest, IndexedDB
  • DevOps: Docker, Kubernetes, CI/CD pipelines

Special Thanks

  • Transportation industry partners for domain expertise
  • Beta testers and early adopters
  • Security researchers and auditors

🎯 Roadmap

Version 2.0 (Q1 2026)

  • [ ] Multi-city support with region-specific features
  • [ ] Advanced AI-powered matching algorithms
  • [ ] Real-time traffic integration
  • [ ] Enhanced PWA features and offline capabilities
  • [ ] Advanced analytics dashboard

Version 2.1 (Q2 2026)

  • [ ] Electric vehicle integration
  • [ ] Carbon footprint tracking
  • [ ] Advanced payment options
  • [ ] Third-party integrations
  • [ ] Enhanced security features

Built with ❤️ by TPT Solutions

Revolutionizing public transportation, one city at a time. 🚌🚇�✨