Magic Logistics is a full-stack web application developed for HackMTY 2025. It aims to optimize in-flight inventory management for airlines by predicting product consumption based on flight data. The application allows users to:
- Predict: Get stocking recommendations for new flights using a Machine Learning model.
- Record: Enter actual product return data after a flight completes to continuously improve the prediction model.
This helps airlines reduce waste and ensure adequate stock levels, minimizing instances of running out of popular items (ran out early) or having excessive leftovers (low demand).
- Dual Mode Interface: Simple switch to toggle between "Predict New Flight" and "Enter Return Data" modes.
- ML-Powered Predictions: Uses a
RandomForestRegressormodel (trained withscikit-learn) to predict consumption for each known product based on flight characteristics (route, date, passengers, service type). - Editable Recommendations: Displays predicted stock levels but allows users to adjust the final quantity before submitting.
- Data Feedback Loop: Enables users to input actual return quantities (including negative values if stock ran out) and crew feedback, which updates the database for future model re-training.
- Persistent Storage: Utilizes SQLite for lightweight and efficient data storage of flight logs and inventory records.
- Modern Web Stack: React frontend (built with Vite and TypeScript) communicating with a FastAPI backend (Python).
- Automated Training: Includes a Python script to easily re-train the prediction model with the latest data.
- Frontend:
- React (v18+)
- TypeScript
- Vite (Build tool)
- CSS (Potentially with a framework like Bootstrap, inferred from class names)
- Backend:
- Python (v3.11+)
- FastAPI (Web framework)
- Uvicorn (ASGI server)
- SQLite (Database)
- Pandas (Data manipulation for ML)
- Scikit-learn (Machine Learning model & pipeline)
- Joblib (Saving/Loading ML model)
- Database:
- SQLite
The project is organized into two main application directories: core (backend) and gui (frontend).
HackMty-2025/
├── app/
│ ├── core/ # Python Backend (FastAPI, ML, DB)
│ │ ├── main.py # FastAPI app entry point
│ │ ├── requirements.txt # Backend Python dependencies
│ │ └── src/
│ │ ├── db/
│ │ │ └── ConsumptionPrediction.db # SQLite database
│ │ ├── ml_model/
│ │ │ ├── flight_consumption_model.joblib # Trained ML model
│ │ │ └── training_pipeline.py # Model training script
│ │ ├── pydantic_models.py # API data validation models
│ │ ├── Resources/ # Constants and SQL queries
│ │ └── Utils/ # Core logic handlers
│ │ ├── ConnectionManagement/ # API & DB Handlers
│ │ └── logic_functions/ # Business & Prediction Logic
│ └── gui
│ ├── eslint.config.js
│ ├── index.html
│ ├── node_modules
│ │ ├── acorn
│ │ ├── acorn-jsx
│ │ ├── ajv
│ │ ├── ansi-styles
│ │ ├── argparse
│ │ ├── @babel
│ │ ├── balanced-match
│ │ ├── baseline-browser-mapping
│ │ ├── brace-expansion
│ │ ├── braces
│ │ ├── browserslist
│ │ ├── callsites
│ │ ├── caniuse-lite
│ │ ├── chalk
│ │ ├── color-convert
│ │ ├── color-name
│ │ ├── concat-map
│ │ ├── convert-source-map
│ │ ├── cross-spawn
│ │ ├── csstype
│ │ ├── debug
│ │ ├── deep-is
│ │ ├── electron-to-chromium
│ │ ├── @esbuild
│ │ ├── esbuild
│ │ ├── escalade
│ │ ├── escape-string-regexp
│ │ ├── @eslint
│ │ ├── eslint
│ │ ├── @eslint-community
│ │ ├── eslint-plugin-react-hooks
│ │ ├── eslint-plugin-react-refresh
│ │ ├── eslint-scope
│ │ ├── eslint-visitor-keys
│ │ ├── espree
│ │ ├── esquery
│ │ ├── esrecurse
│ │ ├── estraverse
│ │ ├── esutils
│ │ ├── fast-deep-equal
│ │ ├── fast-glob
│ │ ├── fast-json-stable-stringify
│ │ ├── fast-levenshtein
│ │ ├── fastq
│ │ ├── file-entry-cache
│ │ ├── fill-range
│ │ ├── find-up
│ │ ├── flat-cache
│ │ ├── flatted
│ │ ├── gensync
│ │ ├── globals
│ │ ├── glob-parent
│ │ ├── graphemer
│ │ ├── has-flag
│ │ ├── @humanfs
│ │ ├── @humanwhocodes
│ │ ├── ignore
│ │ ├── import-fresh
│ │ ├── imurmurhash
│ │ ├── isexe
│ │ ├── is-extglob
│ │ ├── is-glob
│ │ ├── is-number
│ │ ├── @jridgewell
│ │ ├── jsesc
│ │ ├── json5
│ │ ├── json-buffer
│ │ ├── json-schema-traverse
│ │ ├── json-stable-stringify-without-jsonify
│ │ ├── js-tokens
│ │ ├── js-yaml
│ │ ├── keyv
│ │ ├── levn
│ │ ├── locate-path
│ │ ├── lodash.merge
│ │ ├── lru-cache
│ │ ├── merge2
│ │ ├── micromatch
│ │ ├── minimatch
│ │ ├── ms
│ │ ├── nanoid
│ │ ├── natural-compare
│ │ ├── @nodelib
│ │ ├── node-releases
│ │ ├── optionator
│ │ ├── parent-module
│ │ ├── path-exists
│ │ ├── path-key
│ │ ├── picocolors
│ │ ├── picomatch
│ │ ├── p-limit
│ │ ├── p-locate
│ │ ├── postcss
│ │ ├── prelude-ls
│ │ ├── punycode
│ │ ├── queue-microtask
│ │ ├── react
│ │ ├── react-dom
│ │ ├── react-refresh
│ │ ├── resolve-from
│ │ ├── reusify
│ │ ├── @rolldown
│ │ ├── @rollup
│ │ ├── rollup
│ │ ├── run-parallel
│ │ ├── scheduler
│ │ ├── semver
│ │ ├── shebang-command
│ │ ├── shebang-regex
│ │ ├── source-map-js
│ │ ├── strip-json-comments
│ │ ├── supports-color
│ │ ├── tinyglobby
│ │ ├── to-regex-range
│ │ ├── ts-api-utils
│ │ ├── type-check
│ │ ├── @types
│ │ ├── typescript
│ │ ├── @typescript-eslint
│ │ ├── typescript-eslint
│ │ ├── undici-types
│ │ ├── update-browserslist-db
│ │ ├── uri-js
│ │ ├── vite
│ │ ├── @vitejs
│ │ ├── which
│ │ ├── word-wrap
│ │ ├── yallist
│ │ └── yocto-queue
│ ├── package.json
│ ├── package-lock.json
│ ├── public
│ │ └── vite.svg
│ ├── README.md
│ ├── src
│ │ ├── App.css
│ │ ├── App.tsx
│ │ ├── assets
│ │ ├── Components
│ │ ├── index.css
│ │ └── main.tsx
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.node.json
│ └── vite.config.ts
├── README.md
└── run.sh