- Machine Learning Model: Random Forest model for delivery time prediction
- Real-time Tracking: GPS-based position tracking and distance calculation
- Proximity Notifications: Smart notifications based on delivery proximity
- Historical Data Analysis: Learn from past delivery patterns
- Metabase Integration: Professional dashboards and reporting
- Performance Metrics: Driver performance scoring and analytics
- Trend Analysis: Historical data visualization and insights
fullstack-ai-dashboard/
βββ ai-service/ # Flask microservice with ML model
β βββ app.py # Main Flask application
β βββ model.pkl # Trained ML model
β βββ requirements.txt # Python dependencies
β βββ Dockerfile
β
βββ backend/ # Laravel API backend
β βββ app/Models/ # Driver, Violation, Feedback models
β βββ app/Http/Controllers/ # API controllers
β βββ database/migrations/ # Database schema
β βββ routes/api.php # API routes
β βββ Dockerfile
β
βββ frontend/ # Next.js + TypeScript frontend
β βββ app/ # App router pages
β βββ components/ # Reusable components
β βββ Dockerfile
β
βββ metabase/ # Analytics platform
β βββ docker-compose.yml
β
βββ docker-compose.yml # Main orchestrator
- Laravel 11: PHP framework for API development
- PostgreSQL: Primary database for driver and logistics data
- Redis: Caching and background job processing
- Flask: Python web framework
- Scikit-learn: Machine learning library
- Pandas/NumPy: Data processing
- Geopy: Geographic calculations
- Next.js 14: React framework with App Router
- TypeScript: Type-safe JavaScript
- Tailwind CSS: Utility-first CSS framework
- Radix UI: Accessible component library
- Metabase: Business intelligence and dashboards
- PostgreSQL: Data warehouse for analytics
- Docker: Containerization
- Docker Compose: Multi-container orchestration
- Docker and Docker Compose installed
- Git for version control
-
Clone the repository
git clone <repository-url> cd fullstack-ai-dashboard
-
Environment Setup
# Copy environment file for Laravel backend cp backend/.env.example backend/.env # Update database credentials in backend/.env DB_CONNECTION=pgsql DB_HOST=postgres DB_PORT=5432 DB_DATABASE=logistics_db DB_USERNAME=postgres DB_PASSWORD="password"
-
Start all services
docker-compose up -d
-
Initialize the database
# Run migrations docker-compose exec backend php artisan migrate # Seed sample data docker-compose exec backend php artisan db:seed
-
Train the AI model
# Train the ETA prediction model curl -X POST http://localhost:5000/train_model
| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:3000 | Main dashboard |
| Backend API | http://localhost:8000 | Laravel API |
| AI Service | http://localhost:5000 | ML prediction service |
| Metabase | http://localhost:3001 | Analytics dashboard |
| PostgreSQL | localhost:5432 | Database |
| Redis | localhost:6379 | Cache/Queue |
- View All Drivers: Navigate to
/driversto see the driver list - Driver Profile: Click on any driver to view detailed profile
- Performance Tracking: Monitor drug tests, violations, and feedback
- Credential Management: Track document validity and expiry dates
-
Get ETA: Send POST request to
/ai/predict_etawith coordinatescurl -X POST http://localhost:5000/predict_eta \ -H "Content-Type: application/json" \ -d '{ "current_lat": 14.5995, "current_lng": 120.9842, "dropoff_lat": 14.6091, "dropoff_lng": 121.0223 }'
-
Response: Get ETA in minutes and proximity-based message
- Setup Metabase: First-time setup at http://localhost:3001
- Connect Database: Use PostgreSQL connection details
- Create Dashboards: Build custom analytics dashboards
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/drivers |
List all drivers |
| POST | /api/drivers |
Create new driver |
| GET | /api/drivers/{id} |
Get driver details |
| GET | /api/drivers/{id}/profile |
Get driver profile with analytics |
| PUT | /api/drivers/{id} |
Update driver |
| DELETE | /api/drivers/{id} |
Delete driver |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| POST | /train_model |
Train ETA prediction model |
| POST | /predict_eta |
Predict delivery ETA |
| POST | /driver_analytics |
Get driver performance analytics |
drivers: Driver personal informationdrug_test_results: Drug testing historyviolations: Traffic violations and finesfeedback: Customer feedback and ratingscredentials: Driver licenses and certificationsinfractions: Work-related incidents
- One driver has many: drug tests, violations, feedback, credentials, infractions
- Comprehensive foreign key constraints for data integrity
-
Backend Development
cd backend composer install php artisan serve --host=0.0.0.0 --port=8000 -
Frontend Development
cd frontend npm install npm run dev -
AI Service Development
cd ai-service pip install -r requirements.txt python app.py
- Database Changes: Create migrations in
backend/database/migrations/ - API Endpoints: Add controllers in
backend/app/Http/Controllers/ - Frontend Pages: Create components in
frontend/app/ - AI Features: Extend
ai-service/app.py
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and commit:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is open-source and available under the MIT License.
-
Database Connection Error
- Ensure PostgreSQL container is running
- Check database credentials in
.env
-
Frontend Build Errors
- Run
npm installto ensure dependencies are installed - Check Node.js version compatibility
- Run
-
AI Model Training Fails
- Verify Python dependencies are installed
- Check Redis connection for caching
-
Docker Issues
- Run
docker-compose down && docker-compose up -dto restart - Check Docker logs:
docker-compose logs [service-name]
- Run
For technical support, please create an issue in the repository with:
- Detailed error description
- Steps to reproduce
- System information
- Docker logs if applicable