Skip to content

JGITSol/fleet_mgmt_django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Car Fleet Management System

A comprehensive Django-based fleet management system with REST API, JWT authentication, and mobile app integration.

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • pip
  • Git

🎯 Automated Development Setup (Recommended)

# Clone and set up the project
git clone <repository-url>
cd fleet_mgmt_django

# Create and activate virtual environment
python -m venv venv
# Windows PowerShell:
.\venv\Scripts\Activate.ps1
# Linux/Mac:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Start development server with test credentials
python start_dev_server.py

πŸ”§ Manual Development Setup

  1. Clone and setup environment:

    git clone <repository-url>
    cd fleet_mgmt_django
    
    # Create virtual environment
    python -m venv venv
    
    # Activate virtual environment
    # Windows PowerShell:
    .\venv\Scripts\Activate.ps1
    # Linux/Mac:
    source venv/bin/activate
  2. Install dependencies:

    pip install -r requirements.txt
  3. Setup database and test users:

    cd CarFleetManagement
    python manage.py migrate
    python manage.py setup_dev_users
  4. Run development server:

    python manage.py runserver

πŸ” Development Test Credentials

The system comes with pre-configured test accounts for development:

Role Username Password Access Level
Admin admin admin123! Full system access, Django admin
Driver testuser user123! Limited access, driver functions

🌐 Access Points

πŸ§ͺ Test Your Setup

# Test API credentials
python test_dev_credentials.py

πŸ§ͺ Testing

Run Tests

# Quick test run
.\run_tests.ps1

# Manual test execution
pytest -q

# With coverage report
pytest --cov=CarFleetManagement --cov-report=html

Current Test Status

  • Coverage: 56% (improved from 17%)
  • Total Tests: 167 tests across all modules
  • Status: Most core functionality tested, authentication tests require patches

🐳 Docker Deployment

# Development
docker-compose up --build

# Production (when available)
docker-compose -f docker-compose.prod.yml up -d

πŸ“‹ Features

Core Functionality

  • Vehicle Management: Track vehicles, status, assignments, maintenance history
  • Driver Management: Driver profiles, licenses, vehicle assignments
  • Maintenance Scheduling: Schedule and track maintenance with cost tracking
  • Emergency Response: Incident reporting and response coordination
  • User Roles: Admin, Manager, Coordinator, Driver, TestUser permissions

Technical Features

  • JWT Authentication: Secure API access with token-based auth
  • REST API: Complete API for mobile app integration (Lynx JS)
  • AI Integration: Screenshot analysis using OpenRouter/Google AI
  • Internationalization: Multi-language support
  • Comprehensive Testing: pytest with coverage reporting
  • API Documentation: Auto-generated with drf-spectacular

πŸ”§ API Endpoints

Authentication

  • POST /api/auth/login/ - User login (JWT tokens)
  • POST /api/auth/register/ - User registration
  • GET /api/auth/profile/ - User profile
  • POST /api/auth/validate-token/ - Token validation

Core Resources

  • GET|POST /api/vehicles/ - Vehicle list/create
  • GET|PUT|DELETE /api/vehicles/{id}/ - Vehicle detail operations
  • GET|POST /api/drivers/ - Driver list/create
  • GET|PUT|DELETE /api/drivers/{id}/ - Driver detail operations
  • GET|POST /api/maintenance/ - Maintenance records
  • GET|POST /api/emergencies/ - Emergency incidents

AI Features

  • POST /api/screenshots/analyze/ - Single screenshot analysis
  • POST /api/screenshots/batch-analyze/ - Batch analysis
  • POST /api/screenshots/generate-report/ - Generate reports

πŸ—οΈ Architecture

Project Structure

CarFleetManagement/
β”œβ”€β”€ accounts/           # User management & authentication
β”œβ”€β”€ api/               # REST API endpoints & middleware
β”œβ”€β”€ vehicles/          # Vehicle management
β”œβ”€β”€ maintenance/       # Maintenance scheduling
β”œβ”€β”€ emergency/         # Emergency incident management
β”œβ”€β”€ static/           # Static files (CSS, JS, images)
β”œβ”€β”€ templates/        # HTML templates
└── tests/            # Shared test utilities

Technology Stack

  • Backend: Django 5.1.7 + Django REST Framework 3.16.0
  • Authentication: JWT (djangorestframework-simplejwt 5.5.0)
  • Database: SQLite (dev), PostgreSQL (production ready)
  • Testing: pytest-django 4.11.1
  • AI: Google Generative AI
  • Documentation: drf-spectacular 0.28.0

πŸ” Authentication

The system uses JWT authentication for API access:

# Login to get tokens
POST /api/auth/login/
{
    "username": "your_username",
    "password": "your_password"
}

# Use access token in API calls
Authorization: Bearer <access_token>

πŸ“Š Current Status

βœ… Completed

  • Core models (Vehicle, Driver, Maintenance, Emergency)
  • JWT authentication system
  • REST API endpoints
  • Basic web interface
  • Test infrastructure (56% coverage)
  • Docker configuration
  • AI screenshot analysis integration

πŸ”„ In Progress

  • Test stability improvements
  • Authentication test patches
  • API documentation completion
  • Frontend enhancements

πŸ“‹ Next Steps

  1. Stabilize Tests: Fix authentication-related test failures
  2. Improve Coverage: Increase test coverage to 80%+
  3. API Consistency: Standardize error responses and status codes
  4. Documentation: Complete API documentation with examples
  5. Production Setup: Add production deployment guides
  6. Performance: Optimize database queries and add caching

πŸ› οΈ Development

Code Style

  • Follow PEP 8 guidelines
  • Use type hints where appropriate
  • Maintain comprehensive docstrings
  • Write tests for new features

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

πŸ“š Documentation

πŸ› Troubleshooting

Common Issues

Authentication Errors:

  • Ensure JWT tokens are properly formatted
  • Check token expiry and refresh as needed

Test Failures:

  • Use patched test runners for authentication tests
  • Clear pytest cache: pytest --cache-clear

Import Errors:

  • Verify virtual environment is activated
  • Check INSTALLED_APPS configuration

Getting Help

  • Check the DOCUMENTATION.md for detailed guides
  • Review test logs in test_logs/ directory
  • Check Django debug output for detailed error information

πŸ“„ License

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors