Port Weather Navigator is a web application designed to provide insights into port congestion, predict potential shipping delays due to weather, and offer detailed weather forecasts for various ports.
- Port Selection: Easily select and view data for different ports.
- Weather Panel: Display current and forecasted weather conditions for the selected port.
- Delay Prediction: Predict potential shipping delays based on weather forecasts and historical data.
- Congestion Analytics: Analyze historical and predicted port congestion levels.
- Time Series Forecasting: View time series forecasts for weather and shipping metrics.
The project is divided into two main components:
- Frontend (
port-weather-navigator): A React-based single-page application built with Vite and TypeScript, providing the user interface. - Backend (
pbl2-ship-delay): A Python-based server that serves data, performs predictions, and exposes API endpoints consumed by the frontend.
- Node.js (v18 or later recommended)
- npm (or yarn/pnpm)
- Python (3.10 or later recommended)
- pip
-
Clone the repository:
git clone https://github.com/MatricalDefunkt/port-weather-navigator git clone https://github.com/MatricalDefunkt/pbl2-ship-delay
-
Setup and run the Backend (
pbl2-ship-delay):cd pbl2-ship-delay pip install -r requirements.txt python app.pyThe backend server will typically start on a local port
http://localhost:5000. -
Setup and run the Frontend (
port-weather-navigator): Open a new terminal window.cd port-weather-navigator npm install # or yarn install / pnpm install npm run dev
The frontend development server will typically start on
http://localhost:5173and will proxy API requests to the backend.
- React: A JavaScript library for building user interfaces.
- Vite: A fast build tool and development server for modern web projects.
- TypeScript: A typed superset of JavaScript.
- Tailwind CSS: A utility-first CSS framework.
- Shadcn/ui: Re-usable components built using Radix UI and Tailwind CSS.
- Recharts: A composable charting library.
- TanStack Query: For data fetching, caching, and state management.
- React Router DOM: For client-side routing.
- Python: Main programming language.
- Flask: Web framework for building APIs.
- Pandas & NumPy: For data manipulation and numerical operations.
- Scikit-learn: For machine learning tasks and preprocessing.
- Keras / TensorFlow: For deep learning models (e.g., RNN, CNN, MLP).
- Joblib & Pickle: For saving and loading machine learning models.
The frontend communicates with the backend via a set of API endpoints. The main Flask application (app.py) in the pbl2-ship-delay directory defines these routes.
GET /: Health check for the prediction server.- Returns: JSON with status, message, and list of available models.
POST /predict: Endpoint to make delay predictions.- Expects: JSON payload with
vessel_type,teu,arrival_timestamp_str,hourly_weather_forecast, andmodel_name. - Returns: JSON with prediction, model used, input summary, and processing time.
- Expects: JSON payload with
GET /weather: Fetches weather data from Open-Meteo API (with caching).- Query Parameters:
lat(latitude),lon(longitude),forecast(boolean, default true). - Returns: JSON with weather data (current or forecast).
- Query Parameters:
GET /weather/cache/stats: Retrieves statistics about the weather cache.- Returns: JSON with cache stats and configuration.
POST /forecast/arima/train: Trains a new ARIMA model.- Expects: JSON payload with
time_series_data(list of values),order(e.g., [1,1,1]),train_test_split. - Returns: JSON with training results (RMSE, MAE, etc.) or error.
- Expects: JSON payload with
POST /forecast/sarima/train: Trains a new SARIMA (Seasonal ARIMA) model.- Expects: JSON payload with
time_series_data,order,seasonal_order(e.g., [1,1,1,7]),train_test_split. - Returns: JSON with training results or error.
- Expects: JSON payload with
POST /forecast/arima/predict: Makes predictions using a trained ARIMA model.- Expects: JSON payload with
steps(number of future steps to predict). - Returns: JSON with forecasted values or error.
- Expects: JSON payload with
POST /forecast/sarima/predict: Makes predictions using a trained SARIMA model.- Expects: JSON payload with
steps. - Returns: JSON with forecasted values or error.
- Expects: JSON payload with
GET /forecast/arima/models: Lists available (trained) ARIMA/SARIMA models.- Returns: JSON with a list of model names and their status.




