SmartHomes is a full-stack e-commerce web application developed using Java Servlets (backend), React.js (frontend), and Python services for integrating Gen AI tools and Elasticsearch. The platform supports various functionalities for customers, salesmen, and store managers. Features include product management, order placement, reviews, analytics, ticket handling, and advanced search and recommendations using OpenAI embeddings.
The application also integrates Docker for containerization and JavaMail for order confirmation and cancellation emails.
- User Roles: StoreManager, Customers, Salesmen.
- Product Management: Add/Delete/Update products.
- Customer Account Management: Create/Delete/Update accounts.
- Order Management: Place, cancel, and check the status of orders.
- Product Reviews: Customers can submit and view reviews.
- Warranty: Purchase additional warranties for products.
- Cart Management: Add or remove items in the cart within the session.
- Customer Service:
- Open tickets with images and text.
- Status check of tickets (Refund, Replace, or Escalate).
- Decision-making using OpenAI GPT-4o-mini.
- Search and Recommendations:
- Semantic search for product reviews and recommendations.
- Powered by Elasticsearch and OpenAI embeddings.
- Reports:
- Inventory and Sales Reports with Google Charts.
- Email Notifications:
- JavaMail used for sending email notifications for order placement and cancellations.
Ensure you have the following installed:
- Java (OpenJDK 17.0.12 or above)
- Apache Tomcat 9.x
- Node.js (v18 or higher)
- Python (3.8 or higher)
- MySQL (8.x)
- MongoDB (Compass preferred for GUI)
- Docker
- Elasticsearch
- npm (for React dependencies)
git clone https://github.com/YourUsername/SmartHomes.git
cd SmartHomes
- Compile the Java Servlets:
javac -d WEB-INF/classes src/com/smarthomes/*.java
- Deploy the WAR file to Tomcat:
- Place the WAR file in
webapps/
of your Tomcat directory. - Start Tomcat server:
catalina.sh start
- Place the WAR file in
- Navigate to the frontend folder:
cd frontend
- Install dependencies:
npm install
- Start the React development server:
npm start
- Navigate to the Python services directory:
cd python_services
- Install dependencies:
pip install -r requirements.txt
- Start the Python Flask API:
python app.py
- MySQL:
- Import the provided
schema.sql
file to set up tables.
mysql -u root -p < schema.sql
- Import the provided
- MongoDB:
- Run the Python script
mongo_setup.py
to populate the MongoDB database.
- Run the Python script
- Elasticsearch:
- Start Elasticsearch via Docker:
docker run -d -p 9200:9200 -e "discovery.type=single-node" elasticsearch:7.17.0
- Use
elasticsearch_loader.py
to load product embeddings.
- Start Elasticsearch via Docker:
Set up the following environment variables in your system:
- MySQL:
DB_HOST
,DB_USER
,DB_PASSWORD
,DB_NAME
- MongoDB:
MONGO_URI
- OpenAI:
OPENAI_API_KEY
- JavaMail:
MAIL_USERNAME
,MAIL_PASSWORD
To containerize the application:
- Build Docker images:
docker-compose build
- Start containers:
docker-compose up
- Frontend:
- Open http://localhost:3000 in your browser.
- Backend:
- Ensure the Tomcat server is running.
- Python API:
- Ensure Flask API is running on port
5000
.
- Ensure Flask API is running on port
- Customer Service:
- Navigate to the "Customer Service" tab.
- Submit a ticket with text and an image.
- View ticket status and decisions (Refund/Replace/Escalate).
- Search and Recommendations:
- Use "Search Reviews" or "Recommend Product" buttons.
- Enter keywords for semantic searches.
- Order Management:
- Add items to the cart and proceed to checkout.
- Receive an email confirmation for placed orders.
- Inventory and Sales Reports:
- Accessible via the Store Manager dashboard.
- Java:
MySQLDataStoreUtilities.java
: MySQL operations.MongoDBDataStoreUtilities.java
: MongoDB operations.CustomerServiceServlet.java
: Handles ticket operations.
- Python:
app.py
: Flask API for LLM and Elasticsearch interactions.elasticsearch_loader.py
: Embedding upload to Elasticsearch.
- Frontend:
CustomerService.js
: Handles customer service UI and backend calls.SearchAndRecommend.js
: Search and recommendation UI.