Skip to content

ayushkaneriya05/FleetFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Django PostgreSQL HTMX Tailwind CSS Docker

πŸš› FleetFlow β€” Modular Fleet & Logistics Management System

FleetFlow is a full-stack fleet management system built with Django. It provides real-time visibility into vehicle operations, driver management, trip dispatching, expense tracking, and operational analytics β€” all through a polished, responsive web interface with HTMX-powered interactions.


✨ Key Features

🎯 Command Center (Dashboard)

  • Real-time KPI cards: Total Fleet, Available, On Trip, In Maintenance
  • Vehicle type & region filters with pending cargo tracking
  • Recent activity feed with status-coded trip history

πŸš— Vehicle Registry

  • Full vehicle lifecycle management (Available β†’ On Trip β†’ In Shop β†’ Retired)
  • Track name, license plate, type (Truck / Van / Bike), capacity, odometer, acquisition cost, and region
  • Modal-based create/edit forms with inline validation
  • Retire/reactivate vehicles with audit logging

πŸ“‹ Trip Dispatch & Management

  • Draft β†’ Dispatched β†’ Completed / Cancelled lifecycle
  • Create trips with vehicle, driver, origin, destination, cargo weight, and revenue
  • Save-time validation: vehicle/driver availability, cargo capacity, license validity, vehicle–driver category matching
  • Edit draft trips; dispatch with instant toast error feedback
  • Complete trips with odometer end reading
  • HTMX-powered inline row updates without page reload

πŸ‘¨β€βœˆοΈ Driver Safety & Compliance

  • Driver profiles with license tracking and expiry warnings (30-day alert)
  • Vehicle category certification (Truck / Van / Bike / All)
  • Safety score tracking and trip completion rate metrics
  • Status management: Available, On Trip, Off Duty, Suspended
  • Detail pages with trip history

πŸ’° Expenses & Fuel Tracking

  • Log fuel, toll, and other expenses linked to vehicles and trips
  • Vehicle–trip mismatch validation (ensures expense vehicle matches trip vehicle)
  • Three-tab interface:
    • Expense Log β€” all expenses with category filter
    • Completed Trips β€” recent completed trips summary
    • Vehicle Costs β€” per-vehicle fuel and maintenance cost breakdown

πŸ“Š Operational Analytics

  • All metrics respect vehicle type and region filters
  • Overview tab:
    • 4 primary KPIs: Utilization, Revenue, Ops Cost, Net Profit
    • 4 secondary metrics: Trips, KM Driven, Avg km/L, Vehicles
    • Revenue vs. Cost stacked bar chart per vehicle
    • Fleet composition breakdown by vehicle type
    • Top 5 Revenue Generators and Most Profitable Vehicles tables
  • Vehicle Performance tab:
    • Per-vehicle table with distance, fuel, efficiency, revenue, costs, profit, and ROI
    • Color-coded fuel efficiency and ROI indicators
  • CSV export (restricted to Manager / Analyst roles)

πŸ” Role-Based Access Control (RBAC)

Role Permissions
Fleet Manager Full access: create, edit, dispatch, retire, manage drivers, export data
Dispatcher Create/edit trips, log expenses, dispatch vehicles
Safety Officer Manage drivers, log maintenance records
Financial Analyst View analytics, export CSV reports
  • Server-side enforcement via @role_required decorator
  • UI-level enforcement: action buttons hidden based on user role

πŸ›‘οΈ Maintenance & Service Logs

  • Log maintenance records (Oil Change, Tire Rotation, Brake Service, Engine Repair, Inspection, Other)
  • Vehicles auto-transition to In Shop status when maintenance is logged
  • Resolve maintenance records; vehicle returns to Available when all records resolved
  • Filter by resolved/unresolved status

πŸ—οΈ Architecture

Tech Stack

Layer Technology
Backend Django 5.1, Python 3.12
Database PostgreSQL 16
Frontend HTMX 1.19, Tailwind CSS (CDN), native <dialog> modals
Serving Gunicorn, WhiteNoise (static files)
Containerization Docker, Docker Compose

Project Structure

fleetflow/
β”œβ”€β”€ accounts/          # Custom User model, auth views, RBAC roles
β”œβ”€β”€ core/              # Dashboard, audit trail, decorators, management commands
β”œβ”€β”€ fleet/             # Vehicle & Maintenance models, views, forms
β”œβ”€β”€ drivers/           # Driver model, compliance tracking, status management
β”œβ”€β”€ operations/        # Trip model, dispatch/complete/cancel services
β”œβ”€β”€ finance/           # Expense model, fuel tracking, cost analysis
β”œβ”€β”€ analytics/         # Analytics dashboard, CSV export, data visualizations
β”œβ”€β”€ templates/         # Django templates (base, partials, modals)
β”‚   β”œβ”€β”€ base.html      # Global layout, sidebar, modal system, tab/toast JS
β”‚   β”œβ”€β”€ core/          # Dashboard template
β”‚   β”œβ”€β”€ operations/    # Trip list, detail, form, row partials
β”‚   β”œβ”€β”€ fleet/         # Vehicle & maintenance templates
β”‚   β”œβ”€β”€ drivers/       # Driver templates
β”‚   β”œβ”€β”€ finance/       # Expense templates (tabbed)
β”‚   β”œβ”€β”€ analytics/     # Analytics dashboard (tabbed)
β”‚   └── accounts/      # Login, register, password reset
β”œβ”€β”€ static/            # Static assets
β”œβ”€β”€ fleetflow/         # Django project settings, URLs, WSGI
β”œβ”€β”€ Dockerfile         # Production container
β”œβ”€β”€ docker-compose.yml # Dev environment (PostgreSQL + Django)
└── requirements.txt   # Python dependencies

Data Model (ER Diagram)

erDiagram
    User ||--o{ Trip : creates
    User {
        string username
        string role
        string phone
    }
    Vehicle ||--o{ Trip : assigned_to
    Vehicle ||--o{ Expense : incurs
    Vehicle ||--o{ Maintenance : has
    Vehicle {
        string name
        string license_plate
        string vehicle_type
        decimal capacity
        decimal odometer
        string region
        string status
    }
    Driver ||--o{ Trip : drives
    Driver {
        string name
        string license_number
        date license_expiry
        string vehicle_category
        decimal safety_score
        string status
    }
    Trip ||--o{ Expense : generates
    Trip {
        string origin
        string destination
        decimal cargo_weight
        decimal revenue
        string status
        decimal odometer_start
        decimal odometer_end
    }
    Expense {
        string category
        decimal cost
        decimal liters
        date date
    }
    Maintenance {
        string service_type
        decimal cost
        date date
        boolean is_resolved
    }
Loading

πŸš€ Getting Started

Prerequisites

  • Python 3.10+
  • PostgreSQL 14+ (or use Docker)
  • pip or pipenv

Option 1: Docker (Recommended)

# Clone the repository
git clone https://github.com/ayushkaneriya05/FleetFlow.git
cd FleetFlow

# Start PostgreSQL + Django
docker compose up --build

# In another terminal, run migrations and create a superuser
docker compose exec web python manage.py migrate
docker compose exec web python manage.py createsuperuser

The app will be available at http://localhost:8000

Option 2: Local Development

# Clone the repository
git clone https://github.com/ayushkaneriya05/FleetFlow.git
cd FleetFlow

# Create and activate virtual environment
python -m venv .venv

# Windows
.venv\Scripts\activate

# macOS/Linux
source .venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Set up PostgreSQL database
# Create a database named 'fleetflow' in PostgreSQL

# Configure environment variables (create .env file)
echo 'export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/fleetflow"' > .env

# Run migrations
python manage.py migrate

# Create a superuser
python manage.py createsuperuser

# Start the development server
python manage.py runserver

The app will be available at http://localhost:8000

Environment Variables

Variable Default Description
DATABASE_URL β€” PostgreSQL connection string (takes priority)
DB_NAME fleetflow Database name (fallback)
DB_USER postgres Database user (fallback)
DB_PASSWORD postgres Database password (fallback)
DB_HOST localhost Database host (fallback)
DB_PORT 5432 Database port (fallback)
DJANGO_SECRET_KEY dev key Secret key (change in production!)
DJANGO_DEBUG True Debug mode
ALLOWED_HOSTS localhost,127.0.0.1 Comma-separated allowed hosts

πŸ§ͺ Usage

Creating Your First Fleet

  1. Register/Login β€” Create an account with the Fleet Manager role
  2. Add Vehicles β€” Go to Vehicle Registry β†’ Add Vehicle (name, plate, type, capacity, region)
  3. Add Drivers β€” Go to Driver Safety β†’ Add Driver (name, license, category, expiry)
  4. Create a Trip β€” Go to Trip Dispatch β†’ Create Trip (select vehicle, driver, route, cargo)
  5. Dispatch β€” Click the Dispatch button on a Draft trip (validates availability and capacity)
  6. Complete β€” Click Complete, enter odometer end reading
  7. Log Expenses β€” Go to Expenses & Fuel β†’ Log Expense (link to vehicle and trip)
  8. View Analytics β€” Go to Analytics for revenue, costs, fleet utilization, and per-vehicle ROI

HTMX Interactions

FleetFlow uses HTMX for a seamless single-page-like experience:

  • Modal forms β€” All create/edit operations open in a native <dialog> modal loaded via HTMX
  • Inline updates β€” Dispatch, cancel, and status changes update the table row in-place
  • Toast notifications β€” Success/error messages appear as floating toasts via HX-Trigger headers
  • Tab navigation β€” Client-side tabs for multi-section pages (Finance, Analytics)

πŸ“¦ Dependencies

Package Version Purpose
Django β‰₯5.1 Web framework
psycopg2-binary β‰₯2.9 PostgreSQL adapter
django-htmx β‰₯1.19 HTMX middleware and utilities
django-widget-tweaks β‰₯1.5 Template form rendering helpers
whitenoise β‰₯6.7 Static file serving in production
gunicorn β‰₯23.0 Production WSGI server
WeasyPrint β‰₯62.0 PDF report generation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.


Built with ❀️ by Ayush Kaneriya

About

Django-powered fleet management system featuring real-time vehicle tracking, driver management, trip dispatch, fuel/expense tracking, and operational analytics

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors