Bug Description
Three critical runtime issues were identified across the system components:
- Express Backend Startup Crash:
backend/server.js attempts to mount routes onto app (app.use(...)) before const app = express(); is initialized, resulting in an immediate ReferenceError: app is not defined on launch.
- Flask API Pipeline Bypassed:
backend/api.py contains a premature return jsonify(...) statement at line 655 inside the predict() function. This renders ~140 lines of downstream logic (language translation, URL scanning, XAI explanation generation, spam severity scoring, and label decoding) unreachable dead code.
- Streamlit App Launch Failure:
Streamlit/app.py attempts to load model .pkl files from a non-existent models/ subdirectory, causing a FileNotFoundError when launched.
Steps to Reproduce
- Server Startup Issue: Run
node backend/server.js and observe the immediate unhandled ReferenceError.
- Flask Prediction Issue: Run
python backend/api.py and send a POST request to /predict with {"text": "Win free lottery tickets now", "type": "message"}. Observe that language translation, URL checking, XAI explanations, and label decoding are completely skipped, returning a raw unencoded integer index instead of a full JSON analysis.
- Streamlit Issue: Run
streamlit run Streamlit/app.py and observe the app crash with FileNotFoundError.
Expected Behavior
backend/server.js should declare app = express() prior to mounting routes and start listening successfully.
backend/api.py /predict route should execute the entire inference pipeline, returning human-readable labels ("ham", "spam", "smishing"), confidence metrics, and XAI explanation data.
Streamlit/app.py should resolve model paths relative to the repository root and launch the UI without error.
Actual Behavior
backend/server.js throws ReferenceError: app is not defined and terminates the process immediately.
backend/api.py /predict returns premature raw predictions ({"prediction": 1}), bypassing 140+ lines of detection and explainability features.
Streamlit/app.py crashes on launch with FileNotFoundError: [Errno 2] No such file or directory: 'models/linear_svm_model.pkl'.
Screenshots
N/A
Additional Information
- Environment: macOS / Linux / Docker
- Runtime: Node.js (v18+), Python (3.9+)
- Affected Files:
backend/server.js
backend/api.py
Streamlit/app.py
Bug Description
Three critical runtime issues were identified across the system components:
backend/server.jsattempts to mount routes ontoapp(app.use(...)) beforeconst app = express();is initialized, resulting in an immediateReferenceError: app is not definedon launch.backend/api.pycontains a prematurereturn jsonify(...)statement at line 655 inside thepredict()function. This renders ~140 lines of downstream logic (language translation, URL scanning, XAI explanation generation, spam severity scoring, and label decoding) unreachable dead code.Streamlit/app.pyattempts to load model.pklfiles from a non-existentmodels/subdirectory, causing aFileNotFoundErrorwhen launched.Steps to Reproduce
node backend/server.jsand observe the immediate unhandledReferenceError.python backend/api.pyand send a POST request to/predictwith{"text": "Win free lottery tickets now", "type": "message"}. Observe that language translation, URL checking, XAI explanations, and label decoding are completely skipped, returning a raw unencoded integer index instead of a full JSON analysis.streamlit run Streamlit/app.pyand observe the app crash withFileNotFoundError.Expected Behavior
backend/server.jsshould declareapp = express()prior to mounting routes and start listening successfully.backend/api.py/predictroute should execute the entire inference pipeline, returning human-readable labels ("ham","spam","smishing"), confidence metrics, and XAI explanation data.Streamlit/app.pyshould resolve model paths relative to the repository root and launch the UI without error.Actual Behavior
backend/server.jsthrowsReferenceError: app is not definedand terminates the process immediately.backend/api.py/predictreturns premature raw predictions ({"prediction": 1}), bypassing 140+ lines of detection and explainability features.Streamlit/app.pycrashes on launch withFileNotFoundError: [Errno 2] No such file or directory: 'models/linear_svm_model.pkl'.Screenshots
N/A
Additional Information
backend/server.jsbackend/api.pyStreamlit/app.py