Skip to content

SplashFleet is a complete multi-tenant SaaS platform for fleet and vehicle management built with pure PHP and MySQL. It provides comprehensive tools for managing vehicles, drivers, trips, fuel consumption, maintenance, spare parts, and generating insightful reports.

Notifications You must be signed in to change notification settings

ahmedsaadawi13/splash-fleet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SplashFleet - Fleet & Vehicle Management SaaS

SplashFleet is a complete multi-tenant SaaS platform for fleet and vehicle management built with pure PHP and MySQL. It provides comprehensive tools for managing vehicles, drivers, trips, fuel consumption, maintenance, spare parts, and generating insightful reports.

Features

Core Functionality

  • Multi-Tenant Architecture: Single database, complete tenant isolation
  • Vehicle Management: Track vehicles, documents, registration, insurance
  • Driver Management: Manage drivers, licenses, documents, incidents
  • Trip Tracking: Log trips, calculate distances, track usage
  • Fuel Management: Record fuel entries, analyze consumption, detect anomalies
  • Maintenance System: Schedule preventive maintenance, manage work orders, track costs
  • Spare Parts Inventory: Track parts, movements, low stock alerts
  • Alert System: Automated alerts for expiring documents, overdue maintenance
  • Reporting: Vehicle utilization, fuel consumption, maintenance costs, CSV export
  • Subscription Management: Multiple plans with usage quotas
  • Billing: Invoice and payment tracking
  • REST API: External integration for mobile apps and GPS systems

Technical Features

  • PHP 7.0+ Compatible: Works on PHP 7.x through 8.x
  • Custom Lightweight MVC: No framework dependencies
  • Role-Based Access Control: 8 different user roles
  • CSRF Protection: Secure forms and API endpoints
  • Session Management: Secure authentication
  • File Upload: Document management with validation
  • Pagination: Efficient data browsing
  • Activity Logging: Comprehensive audit trail
  • Multi-Currency Support: Configurable per tenant

Installation

Requirements

  • PHP 7.0 or higher
  • MySQL 5.7+ or MariaDB 10.2+
  • Apache or Nginx web server
  • PHP Extensions: pdo_mysql, mbstring, openssl, json, fileinfo

Setup Instructions

  1. Clone the repository

    git clone <repository-url>
    cd SplashFleet
  2. Configure environment

    cp .env.example .env

    Edit .env and configure your database:

    DB_HOST=localhost
    DB_NAME=splashfleet
    DB_USER=root
    DB_PASS=your_password
    BASE_URL=http://localhost
    
  3. Create database and import schema

    mysql -u root -p
    CREATE DATABASE splashfleet CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    exit;
    mysql -u root -p splashfleet < database.sql
  4. Set file permissions

    chmod -R 755 storage/uploads
    chmod -R 755 storage/logs
  5. Configure web server

    Apache (.htaccess already included):

    <VirtualHost *:80>
        DocumentRoot "/path/to/SplashFleet/public"
        ServerName splashfleet.local
        <Directory "/path/to/SplashFleet/public">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>

    Nginx:

    server {
        listen 80;
        server_name splashfleet.local;
        root /path/to/SplashFleet/public;
        index index.php;
    
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
    
        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
  6. Access the application

Database Schema

The system uses the following main tables:

Core Tables

  • tenants - Company/organization accounts
  • users - System users with role-based access
  • plans - Subscription plans
  • tenant_subscriptions - Active subscriptions
  • tenant_api_keys - API authentication keys

Fleet Management

  • vehicles - Vehicle information and status
  • vehicle_documents - Registration, insurance, inspection docs
  • drivers - Driver information and licenses
  • driver_documents - License, ID, certifications
  • trips - Trip logs with odometer readings
  • fuel_entries - Fuel refill records
  • fuel_cards - Fuel card assignments

Maintenance

  • service_types - Maintenance service definitions
  • service_schedules - Scheduled maintenance plans
  • maintenance_orders - Work orders
  • maintenance_order_items - Labor and parts used
  • spare_parts - Parts inventory
  • spare_part_movements - Stock movements

System

  • alerts - System alerts and notifications
  • notifications - Email notification queue
  • invoices - Billing invoices
  • payments - Payment records
  • activity_logs - Audit trail

User Roles & Permissions

Role Description Key Permissions
platform_admin SaaS platform owner Manage all tenants, view system-wide metrics
tenant_admin Fleet administrator Full control within tenant, manage users
fleet_manager Fleet operations Manage vehicles, drivers, trips, alerts
maintenance_manager Maintenance operations Manage maintenance, schedules, spare parts
fuel_manager Fuel operations Manage fuel entries, analyze consumption
driver_manager Driver operations Manage drivers, documents, assignments
accountant Financial reporting View costs, reports, invoices
viewer Read-only access View data, no modifications

API Documentation

Authentication

All API requests require an API key in the X-API-KEY header.

curl -H "X-API-KEY: your_api_key_here" http://localhost/api/vehicles/list

Endpoints

1. List Vehicles

GET /api/vehicles/list

Query Parameters:

  • status (optional): Filter by status
  • category (optional): Filter by category

Response:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "plate_number": "ABC-1234",
      "make": "Ford",
      "model": "Transit",
      "year": 2022,
      "status": "active",
      "current_odometer": 15000.00,
      "fuel_type": "diesel"
    }
  ]
}

2. Create Trip

POST /api/trips/create

Request Body:

{
  "vehicle_plate_number": "ABC-1234",
  "driver_identifier": "DRV001",
  "trip_type": "delivery",
  "start_datetime": "2025-01-15 08:00:00",
  "end_datetime": "2025-01-15 12:00:00",
  "start_odometer": 15000.00,
  "end_odometer": 15080.00,
  "start_location": "Warehouse A",
  "end_location": "Client Site B",
  "purpose": "Package delivery"
}

Response:

{
  "status": "success",
  "trip_id": 123,
  "distance_travelled": 80.00
}

3. Add Fuel Entry

POST /api/fuel/add

Request Body:

{
  "vehicle_plate_number": "ABC-1234",
  "driver_identifier": "DRV001",
  "fuel_type": "diesel",
  "quantity": 45.50,
  "quantity_unit": "liters",
  "price_per_unit": 1.75,
  "total_cost": 79.63,
  "vendor_name": "Shell Station",
  "odometer_reading": 15050.00,
  "date": "2025-01-15"
}

Response:

{
  "status": "success",
  "fuel_entry_id": 456
}

Running Tests

Execute the test suite:

# Database connection test
php tests/DatabaseTest.php

# Model CRUD tests
php tests/ModelTest.php

Scheduled Tasks (Cron Jobs)

Add these to your crontab for automated tasks:

# Generate alerts daily at 6 AM
0 6 * * * cd /path/to/SplashFleet && php -r "require 'app/core/Database.php'; require 'app/core/Model.php'; require 'app/models/Alert.php'; \$alert = new Alert(); \$alert->generateExpiryAlerts(1, 30); \$alert->generateMaintenanceAlerts(1);"

# Process pending notifications every hour
0 * * * * cd /path/to/SplashFleet && php cron/process_notifications.php

# Clean old logs weekly
0 0 * * 0 find /path/to/SplashFleet/storage/logs -name "*.log" -mtime +30 -delete

Deployment

Production Checklist

  1. Set environment to production in .env:

    APP_ENV=production
    APP_DEBUG=false
    
  2. Enable HTTPS: Use Let's Encrypt or SSL certificate

  3. Secure file permissions:

    chown -R www-data:www-data storage/
    chmod -R 755 storage/
  4. Database optimization:

    • Enable query caching
    • Add indexes for frequently queried columns
    • Regular backups
  5. PHP optimization:

    • Enable OPcache
    • Increase memory_limit if needed
    • Set appropriate upload_max_filesize
  6. Security:

    • Change default passwords
    • Restrict database access
    • Enable firewall rules
    • Regular security updates

Architecture

MVC Structure

SplashFleet/
├── app/
│   ├── controllers/     # Request handlers
│   ├── models/          # Data layer
│   ├── views/           # Templates
│   ├── core/            # Framework core
│   └── helpers/         # Utility classes
├── config/              # Configuration
├── public/              # Web root
│   ├── index.php        # Entry point
│   └── assets/          # CSS, JS, images
├── storage/             # Uploads and logs
├── tests/               # Test suite
└── database.sql         # Database schema

Key Design Patterns

  • Singleton: Database, Auth, Session
  • Factory: Model instantiation
  • MVC: Clean separation of concerns
  • Repository: Data access abstraction

Subscription & Quota System

Plans

  • Starter: 10 vehicles, 5 users, 500 trips/month
  • Professional: 50 vehicles, 20 users, 2000 trips/month
  • Enterprise: Unlimited resources

Quota Enforcement

The system automatically checks quotas before:

  • Creating new vehicles
  • Adding users
  • Recording trips
  • Creating maintenance orders

Users are notified when approaching or exceeding limits.

Security Features

  • Password Hashing: bcrypt (password_hash/password_verify)
  • CSRF Protection: Token validation on all forms
  • SQL Injection Prevention: Prepared statements only
  • XSS Protection: Output escaping (htmlspecialchars)
  • Session Security: Regeneration on login
  • File Upload Validation: MIME type and extension checks
  • Tenant Isolation: All queries scoped by tenant_id
  • Activity Logging: Comprehensive audit trail

Support & Contribution

  • Issues: Report bugs and feature requests via GitHub Issues
  • Documentation: Full documentation in /docs folder
  • License: MIT License

Future Enhancements

  • GPS Integration: Real-time vehicle tracking
  • Mobile App: iOS and Android applications
  • Telematics: Integration with vehicle telematics systems
  • Advanced Analytics: Machine learning for predictive maintenance
  • Multi-language: i18n support
  • Email Notifications: SMTP integration
  • Payment Gateway: Stripe/PayPal integration
  • Document OCR: Automatic data extraction from receipts

SplashFleet - Professional Fleet Management Made Simple

For questions and support, please open an issue on GitHub.

About

SplashFleet is a complete multi-tenant SaaS platform for fleet and vehicle management built with pure PHP and MySQL. It provides comprehensive tools for managing vehicles, drivers, trips, fuel consumption, maintenance, spare parts, and generating insightful reports.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published