A complete web application that leverages machine learning and Generative AI (Gemini) to detect scam messages (SMS/WhatsApp) and provide real-time cybersecurity advice.
- Frontend: React.js (Vite), Tailwind CSS, Lucide Icons, Client-side JWT routing
- Backend: Python Flask REST API, Flask-JWT-Extended, Flask-SQLAlchemy, Cryptography
- Database: MySQL (tested, with automatic SQLite fallback for immediate out-of-the-box operation)
- AI & Machine Learning: Scikit-learn (TF-IDF Vectorizer + Logistic Regression), Gemini 2.5 Flash REST Integration
├── backend/ # Flask server, configurations, blueprints
│ ├── app.py # Entry point and admin account seeder
│ ├── auth.py # Registration & JWT Login router
│ ├── chatbot.py # CyberGuard AI Chatbot & message classifier endpoints
│ ├── config.py # Configuration parser (.env loader)
│ ├── database.py # SQLAlchemy setups (with MySQL check/SQLite fallback)
│ ├── models.py # User, Chat, and Report tables
│ ├── requirements.txt# Backend Python libraries
│ └── scam_detector.py# ML model interface & heuristic fallbacks
├── database/ # DDL queries
│ └── schema.sql # Database initializing query
├── datasets/ # ML dataset training
│ ├── generate_dataset.py # Generates simulated scam logs CSV
│ └── train_model.py # TF-IDF & Logistic Regression training pipeline
├── frontend/ # React single-page dashboard application (Vite)
│ ├── src/ # React codebase
│ │ ├── components/ # Login, Register, Chatbot, Scanner, Reporting, Admin panels
│ │ ├── api.js # Consolidated backend HTTP handlers
│ │ ├── App.jsx # Central layout & routing orchestrator
│ │ └── index.css # Stylesheets & animations
│ ├── package.json # Frontend dependency records
│ └── tailwind.config.js # Custom security dashboard styling rules
├── models/ # Output directories for trained classifiers
│ ├── scam_detector.pkl
│ └── vectorizer.pkl
└── README.md # Project Documentation
Ensure you have Python 3.10+ and Node.js 18+ installed.
-
Open a terminal and navigate to the backend folder:
cd backend -
Build the configuration
.envfile (already created by default):- Open
backend/.env - Insert your Gemini API Key in the
GEMINI_API_KEYslot. - Customize the MySQL credentials in
DATABASE_URL. (Note: If MySQL is not running or credentials fail, the server will fall back to SQLite automatically so you can run and test immediately!)
- Open
-
Run the Flask server:
python app.py
The backend will start running on
http://localhost:5000.
The project comes with a pre-trained model generated on a rich scam text dataset. If you ever want to re-train the classifier:
- Generate the CSV dataset:
python datasets/generate_dataset.py
- Train the model:
This will output newly updated
python datasets/train_model.py
.pklfiles in themodels/folder.
- Open a new terminal and navigate to the frontend folder:
cd frontend - Install npm dependencies:
npm install
- Start the dev server:
The application will boot up at
npm run dev
http://localhost:5173.
Upon launching the backend, it automatically seeds the database with a default administrator account. You can log in using these credentials to review reports and toggle case statuses:
- Admin Username:
admin - Admin Email:
admin@fraudshield.com - Admin Password:
admin123