A comprehensive Django-based fleet management system with REST API, JWT authentication, and mobile app integration.
- Python 3.11+
- pip
- Git
# 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-
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
-
Install dependencies:
pip install -r requirements.txt
-
Setup database and test users:
cd CarFleetManagement python manage.py migrate python manage.py setup_dev_users -
Run development server:
python manage.py runserver
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 |
- Web Interface: http://localhost:8000/
- Login Page: http://localhost:8000/accounts/login/
- Registration: http://localhost:8000/accounts/register/
- Admin Panel: http://localhost:8000/admin/
- API Root: http://localhost:8000/api/
- API Documentation: http://localhost:8000/api/schema/swagger-ui/
# Test API credentials
python test_dev_credentials.py# Quick test run
.\run_tests.ps1
# Manual test execution
pytest -q
# With coverage report
pytest --cov=CarFleetManagement --cov-report=html- Coverage: 56% (improved from 17%)
- Total Tests: 167 tests across all modules
- Status: Most core functionality tested, authentication tests require patches
# Development
docker-compose up --build
# Production (when available)
docker-compose -f docker-compose.prod.yml up -d- 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
- 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
POST /api/auth/login/- User login (JWT tokens)POST /api/auth/register/- User registrationGET /api/auth/profile/- User profilePOST /api/auth/validate-token/- Token validation
GET|POST /api/vehicles/- Vehicle list/createGET|PUT|DELETE /api/vehicles/{id}/- Vehicle detail operationsGET|POST /api/drivers/- Driver list/createGET|PUT|DELETE /api/drivers/{id}/- Driver detail operationsGET|POST /api/maintenance/- Maintenance recordsGET|POST /api/emergencies/- Emergency incidents
POST /api/screenshots/analyze/- Single screenshot analysisPOST /api/screenshots/batch-analyze/- Batch analysisPOST /api/screenshots/generate-report/- Generate reports
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
- 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
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>- 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
- Test stability improvements
- Authentication test patches
- API documentation completion
- Frontend enhancements
- Stabilize Tests: Fix authentication-related test failures
- Improve Coverage: Increase test coverage to 80%+
- API Consistency: Standardize error responses and status codes
- Documentation: Complete API documentation with examples
- Production Setup: Add production deployment guides
- Performance: Optimize database queries and add caching
- Follow PEP 8 guidelines
- Use type hints where appropriate
- Maintain comprehensive docstrings
- Write tests for new features
- Fork the repository
- Create a feature branch
- Write tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Complete Documentation: See DOCUMENTATION.md
- Project Specification: See CurrentProjectSpecSheet.md
- Current State: See CurrentStateOfTheProject.md
- API Schema: Available at
/api/schema/when running
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
- Check the DOCUMENTATION.md for detailed guides
- Review test logs in
test_logs/directory - Check Django debug output for detailed error information
This project is licensed under the MIT License - see the LICENSE file for details.