Skip to content

nikhilij/AI-Based-Review-Classfier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 AI-Based Review Classifier

πŸ“Œ Overview

The AI-Based Review Classifier is a machine learning-powered web application designed to classify customer reviews as Positive, Negative, or Neutral. The system integrates a Flask-based AI model with a Node.js backend and supports real-time classification.


πŸš€ Features

  • βœ… Machine Learning-Based Sentiment Analysis
  • βœ… RESTful API for Classification
  • βœ… Preprocessing & Model Training Scripts
  • βœ… Flask API for AI Model Deployment
  • βœ… Secure Node.js Backend
  • βœ… Scalable & Modular Architecture
  • βœ… Automated Training & Evaluation
  • βœ… CI/CD & Deployment Support

πŸ—οΈ System Architecture

User ➝ Frontend ➝ Backend (Node.js) ➝ AI Model (Flask) ➝ Database (MongoDB)

πŸ“‚ Project Structure

(for %i in (file1.txt test.js ) do type nul > %i)    #To create multiple files at once
AI-Based-Review-Classifier/
│── πŸ“‚ backend/                   # Backend (Node.js & Express)
β”‚   β”œβ”€β”€ πŸ“‚ src/                    # Source Code
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ config/             # Configuration files
β”‚   β”‚   β”‚   β”œβ”€β”€ db.js              # MongoDB connection
β”‚   β”‚   β”‚   β”œβ”€β”€ envConfig.js       # Environment variables handler
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ controllers/        # Route controllers
β”‚   β”‚   β”‚   β”œβ”€β”€ authController.js  # Authentication logic
β”‚   β”‚   β”‚   β”œβ”€β”€ reviewController.js# Review-related logic
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ middleware/         # Middlewares
β”‚   β”‚   β”‚   β”œβ”€β”€ authMiddleware.js  # JWT authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ errorMiddleware.js # Error handling
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ models/             # Mongoose models
β”‚   β”‚   β”‚   β”œβ”€β”€ User.js            # User schema
β”‚   β”‚   β”‚   β”œβ”€β”€ Review.js          # Review schema
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ routes/             # API route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ authRoutes.js      # Authentication routes
β”‚   β”‚   β”‚   β”œβ”€β”€ reviewRoutes.js    # Review management routes
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ services/           # Business logic services
β”‚   β”‚   β”‚   β”œβ”€β”€ authService.js     # User authentication logic
β”‚   β”‚   β”‚   β”œβ”€β”€ reviewService.js   # Review processing logic
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ utils/              # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ jwtHelper.js       # JWT token helpers
β”‚   β”‚   β”‚   β”œβ”€β”€ emailHelper.js     # Email notifications
β”‚   β”‚   β”‚   β”œβ”€β”€ responseHandler.js # Standardized API responses
β”‚   β”‚   β”œβ”€β”€ app.js                 # Express app configuration
β”‚   β”‚   β”œβ”€β”€ server.js              # Main server entry point
β”‚   β”œβ”€β”€ πŸ“‚ tests/                  # Backend tests
β”‚   β”‚   β”œβ”€β”€ authTests.js           # Tests for authentication
β”‚   β”‚   β”œβ”€β”€ reviewTests.js         # Tests for review management
β”‚   β”œβ”€β”€ .env                        # Environment variables
β”‚   β”œβ”€β”€ .gitignore                  # Ignore unnecessary files
β”‚   β”œβ”€β”€ Dockerfile                  # Dockerization support
β”‚   β”œβ”€β”€ package.json                 # Dependencies & scripts
β”‚   β”œβ”€β”€ package-lock.json            # Lock file for package versions
β”‚   β”œβ”€β”€ postman_collection.json      # API testing collection
β”‚
│── πŸ“‚ ai_model/                  # AI Model (Python & Machine Learning)
β”‚   β”œβ”€β”€ πŸ“‚ data/                    # Dataset storage
β”‚   β”‚   β”œβ”€β”€ reviews.csv             # Raw dataset
β”‚   β”‚   β”œβ”€β”€ preprocessed.pkl        # Preprocessed data
β”‚   β”‚   β”œβ”€β”€ model.pkl               # Trained ML model
β”‚   β”‚   β”œβ”€β”€ vectorizer.pkl          # TF-IDF vectorizer
β”‚   β”œβ”€β”€ πŸ“‚ training/                 # Training scripts
β”‚   β”‚   β”œβ”€β”€ preprocess.py           # Data preprocessing
β”‚   β”‚   β”œβ”€β”€ train_model.py          # Model training & saving
β”‚   β”‚   β”œβ”€β”€ evaluate.py             # Model evaluation
β”‚   β”œβ”€β”€ πŸ“‚ api/                     # Flask API to expose model
β”‚   β”‚   β”œβ”€β”€ app.py                  # Flask API for predictions
β”‚   β”‚   β”œβ”€β”€ model_loader.py         # Model loading utility
β”‚   β”‚   β”œβ”€β”€ requirements.txt        # Python dependencies
β”‚   β”œβ”€β”€ πŸ“‚ notebooks/               # Jupyter notebooks for experiments
β”‚   β”‚   β”œβ”€β”€ DataExploration.ipynb   # Dataset exploration
β”‚   β”‚   β”œβ”€β”€ ModelTesting.ipynb      # Model evaluation
β”‚   β”œβ”€β”€ πŸ“‚ tests/                   # Model testing scripts
β”‚   β”‚   β”œβ”€β”€ test_predictions.py     # API testing for model predictions
β”‚   β”‚   β”œβ”€β”€ test_preprocessing.py   # Test data preprocessing steps
β”‚   β”œβ”€β”€ ai_service.py               # Python client to call Flask API
β”‚
│── πŸ“‚ frontend/                  # (Optional) React/Angular Frontend
β”‚   β”œβ”€β”€ src/                       # Source code
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ components/          # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ ReviewForm.js       # Review submission form
β”‚   β”‚   β”‚   β”œβ”€β”€ ReviewList.js       # Review display
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.js           # Navbar UI
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ pages/               # Application pages
β”‚   β”‚   β”‚   β”œβ”€β”€ HomePage.js         # Home page UI
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.js        # User dashboard
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ services/            # API call handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ api.js              # Backend API calls
β”‚   β”‚   β”œβ”€β”€ App.js                  # Main React component
β”‚   β”‚   β”œβ”€β”€ index.js                # React app entry point
β”‚   β”œβ”€β”€ public/                     # Static files (HTML, CSS)
β”‚   β”œβ”€β”€ package.json                 # Dependencies
β”‚
│── πŸ“‚ docs/                      # Documentation
β”‚   β”œβ”€β”€ API_Documentation.md       # API usage and endpoints
β”‚   β”œβ”€β”€ AI_Model_Documentation.md  # AI model details
β”‚
└── README.md                      # Project documentation



πŸ› οΈ Tech Stack

Backend (API & Server)

  • Node.js, Express.js, MongoDB, Socket.io
  • Nodemailer (Email notifications)

AI Model

  • Python, Flask, Scikit-Learn, TF-IDF
  • Jupyter Notebooks (Experiments)

Frontend (Optional)

  • React.js, TailwindCSS

πŸ“‘ API Endpoints

1️⃣ AI Model API (Flask)

Method Endpoint Description
POST /predict Classifies review

2️⃣ Backend API (Node.js)

Method Endpoint Description
POST /api/ai/classify Classifies user review
GET /api/reviews Fetches all classified reviews

βš™οΈ Installation & Setup

1️⃣ Clone Repository

git clone https://github.com/yourusername/AI-Based-Review-Classifier.git
cd AI-Based-Review-Classifier

2️⃣ Install Dependencies

Backend (Node.js)

cd backend
npm install

AI Model (Python)

cd ai_model/api
pip install -r requirements.txt

3️⃣ Setup Environment Variables

Create a .env file in the backend/ folder:

MONGO_URI=your_mongo_db_connection_string
PORT=5000

πŸš€ Running the Application

1️⃣ Start Backend (Node.js)

cd backend
npm start

2️⃣ Start AI Model API (Flask)

cd ai_model/api
python app.py

3️⃣ Test in Postman

POST http://localhost:5000/api/ai/classify
Body: { "review": "This product is amazing!" }

πŸ› οΈ Deployment

Backend Deployment

  • Deploy on Heroku, AWS, or Vercel
  • Use PM2 for process management

AI Model Deployment

  • Deploy Flask API on Render or Google Cloud
  • Use Docker for containerization

πŸ” Security Enhancements

  • JWT Authentication
  • CORS Handling
  • Input Validation

πŸ“Š Monitoring & Visualization

  • Grafana & Prometheus for API monitoring
  • MLflow for AI model tracking

🀝 Contributing

We welcome contributions! Follow these steps:

  1. Fork the repo
  2. Create a new branch (feature-branch)
  3. Commit your changes
  4. Create a Pull Request

πŸ“œ License

This project is licensed under the MIT License. Feel free to modify and use it!

πŸš€ Happy Coding! πŸŽ‰

About

The AI-Based Review Classifier backend uses NLP models like TF-IDF or BERT to analyze and classify reviews. Built with Node.js, it integrates ML via TensorFlow.js or Python APIs, supports MongoDB/PostgreSQL, Redis caching, and JWT authentication, and deploys via Docker on AWS/GCP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors