Skip to content

A Fleet Management System built with Flutter for managing vehicles, drivers, trips, and documents. It provides trip logs, route stops, and local data storage using Hive. Cross-platform support for Windows and Web with clean UI. Future updates will include authentication and cloud sync.

Notifications You must be signed in to change notification settings

ayax-khan/FleetManagementSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fleet Management System - New Architecture

πŸ—οΈ Architecture Overview

πŸ“± Flutter App (Frontend)
🐍 Python FastAPI Backend  
    ↓ (Excel Processing + Business Logic)
πŸ“Š Pandas/OpenPyXL (Excel Handling)
    ↓ (Data Validation & Transformation)
πŸ—ƒοΈ Hive Database (Local Storage)

This implementation follows your requested architecture with:

  • Flutter for cross-platform frontend
  • Python FastAPI for robust backend APIs
  • Pandas/OpenPyXL for powerful Excel processing
  • Hive-style JSON storage for local database

πŸš€ Quick Start

1. Start the Backend

# Double-click to run
start_backend.bat

Or manually:

cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python main.py

The backend will start on http://localhost:8000

2. Start the Frontend

# Double-click to run (in a separate terminal)
start_frontend.bat

Or manually:

flutter pub get
flutter run -d windows

πŸ“ Project Structure

FleetManagementSystem/
β”œβ”€β”€ backend/                     # Python FastAPI Backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”‚   └── config.py        # Configuration & settings
β”‚   β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”‚   └── hive_manager.py  # Hive-style JSON database
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   └── schemas.py       # Pydantic models
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ vehicles.py      # Vehicle CRUD APIs
β”‚   β”‚   β”‚   β”œβ”€β”€ drivers.py       # Driver CRUD APIs
β”‚   β”‚   β”‚   β”œβ”€β”€ trips.py         # Trip management APIs
β”‚   β”‚   β”‚   β”œβ”€β”€ fuel.py          # Fuel entry APIs
β”‚   β”‚   β”‚   β”œβ”€β”€ maintenance.py   # Maintenance APIs
β”‚   β”‚   β”‚   └── excel_import.py  # Excel processing APIs
β”‚   β”‚   └── services/
β”‚   β”‚       └── excel_service.py # Pandas/OpenPyXL service
β”‚   β”œβ”€β”€ main.py                  # FastAPI application
β”‚   └── requirements.txt         # Python dependencies
β”œβ”€β”€ lib/                         # Flutter Frontend
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── api_service.dart     # HTTP client for backend
β”‚   β”œβ”€β”€ main.dart                # Flutter entry point
β”‚   └── app.dart                 # Main app widget
β”œβ”€β”€ pubspec.yaml                 # Flutter dependencies (cleaned)
β”œβ”€β”€ start_backend.bat            # Backend startup script
└── start_frontend.bat           # Frontend startup script

πŸ—ƒοΈ Database Storage

Following your rule, the Hive database is stored at:

C:\Users\{USERNAME}\Documents\fleetManagementSystem\

Database files:

  • vehicles.json
  • drivers.json
  • trips.json
  • fuel_entries.json
  • maintenance.json
  • And more...

πŸ”§ Key Features

Backend (FastAPI)

  • βœ… RESTful APIs for all entities
  • βœ… Automatic API documentation (Swagger)
  • βœ… Data validation with Pydantic
  • βœ… Excel import/export with Pandas
  • βœ… File-based JSON database (Hive-style)
  • βœ… CORS enabled for Flutter communication
  • βœ… Comprehensive error handling

Frontend (Flutter)

  • βœ… Modern Material 3 UI
  • βœ… Riverpod state management
  • βœ… HTTP client (Dio) with interceptors
  • βœ… Cross-platform compatibility
  • βœ… Clean architecture separation
  • βœ… Minimal dependencies

Excel Processing

  • βœ… Smart sheet detection
  • βœ… Automatic field mapping
  • βœ… Data validation & transformation
  • βœ… Batch import/export
  • βœ… Error reporting

πŸ“Š API Endpoints

Core Entities

  • GET/POST/PUT/DELETE /api/v1/vehicles/
  • GET/POST/PUT/DELETE /api/v1/drivers/
  • GET/POST/PUT/DELETE /api/v1/trips/
  • GET/POST /api/v1/fuel/
  • GET/POST /api/v1/maintenance/

Excel Operations

  • POST /api/v1/excel/analyze - Analyze Excel file structure
  • POST /api/v1/excel/import - Import Excel data
  • GET /api/v1/excel/export - Export data to Excel
  • GET /api/v1/excel/database/stats - Database statistics

Utilities

  • GET /api/health - Health check
  • POST /api/v1/excel/database/clear/{table} - Clear table data

πŸ’» Development

Backend Development

cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Frontend Development

flutter pub get
flutter run -d windows

Testing APIs

Visit http://localhost:8000/docs for interactive API documentation.

⚑ Benefits of This Architecture

  1. Separation of Concerns: Clear separation between UI, business logic, and data
  2. Excel Powerhouse: Pandas provides industrial-strength Excel processing
  3. Local Storage: No need for external database servers
  4. API-Driven: RESTful APIs make the backend reusable
  5. Cross-Platform: Flutter works on desktop, mobile, and web
  6. Type Safety: Pydantic ensures data validation
  7. Documentation: Auto-generated API docs
  8. Minimal Setup: Few dependencies, easy to deploy

πŸ”§ Configuration

Backend Configuration

Edit backend/app/core/config.py:

class Settings:
    DEBUG: bool = True
    PORT: int = 8000
    HIVE_DB_PATH: str = "C:\\Users\\{username}\\Documents\\fleetManagementSystem"

Frontend Configuration

Edit lib/services/api_service.dart:

static const String _baseUrl = 'http://localhost:8000/api/v1';

🎯 Next Steps

The architecture is fully implemented and ready to use. You can now:

  1. Run the backend with start_backend.bat
  2. Run the frontend with start_frontend.bat
  3. Import Excel data using the Excel Import tab
  4. Manage vehicles, drivers, trips through the API
  5. View data in the Hive database files

The system follows your requested architecture exactly and provides a solid foundation for fleet management operations!

πŸ†˜ Troubleshooting

Backend Issues

  • Port 8000 in use: Change port in config.py
  • Python not found: Install Python 3.8+
  • Dependencies fail: Try pip install --upgrade pip

Frontend Issues

  • Flutter not found: Install Flutter SDK
  • Dependency conflicts: Run flutter clean && flutter pub get
  • Backend not responding: Ensure backend is running on localhost:8000

Database Issues

  • Permission denied: Check Windows folder permissions
  • Data not saving: Check the Hive directory path in config

About

A Fleet Management System built with Flutter for managing vehicles, drivers, trips, and documents. It provides trip logs, route stops, and local data storage using Hive. Cross-platform support for Windows and Web with clean UI. Future updates will include authentication and cloud sync.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published