diff --git a/Data/create_search_resources.py b/Data/create_search_resources.py new file mode 100644 index 000000000..bdd8fde0b --- /dev/null +++ b/Data/create_search_resources.py @@ -0,0 +1,78 @@ +import os +from dotenv import load_dotenv +from azure.core.credentials import AzureKeyCredential +from azure.search.documents.indexes import SearchIndexClient, SearchIndexerClient +from azure.search.documents.indexes.models import ( + SearchIndexerDataSourceConnection, + SearchIndexer, + SearchIndex, + SimpleField, + SearchableField, + SearchFieldDataType +) + +# Load environment variables from .env file +load_dotenv() + +# Retrieve environment variables +SEARCH_ENDPOINT = os.getenv("SEARCH_ENDPOINT") +SEARCH_API_KEY = os.getenv("SEARCH_API_KEY") +BLOB_CONNECTION_STRING = os.getenv("BLOB_CONNECTION_STRING") +BLOB_CONTAINER_NAME = os.getenv("BLOB_CONTAINER_NAME") + +# Validate required environment variables +required_vars = [SEARCH_ENDPOINT, SEARCH_API_KEY, BLOB_CONNECTION_STRING, BLOB_CONTAINER_NAME] +if any(var is None for var in required_vars): + raise ValueError("One or more required environment variables are missing.") + +def create_search_resources(): + """Create Azure AI Search resources: data source, index, and indexer.""" + try: + # Initialize SearchIndexClient for index operations + index_client = SearchIndexClient( + endpoint=SEARCH_ENDPOINT, + credential=AzureKeyCredential(SEARCH_API_KEY) + ) + + # Initialize SearchIndexerClient for data source and indexer operations + indexer_client = SearchIndexerClient( + endpoint=SEARCH_ENDPOINT, + credential=AzureKeyCredential(SEARCH_API_KEY) + ) + + # Define data source connection + data_source = SearchIndexerDataSourceConnection( + name="macae-blob-datasets", + type="azureblob", + connection_string=BLOB_CONNECTION_STRING, + container={"name": BLOB_CONTAINER_NAME} + ) + indexer_client.create_or_update_data_source_connection(data_source) + print("Data source 'macae-blob-datasets' created successfully.") + + # Define index schema + index = SearchIndex( + name="macae-index", + fields=[ + SimpleField(name="id", type=SearchFieldDataType.String, key=True), + SearchableField(name="content", type=SearchFieldDataType.String), + SearchableField(name="metadata", type=SearchFieldDataType.String) + ] + ) + index_client.create_or_update_index(index) + print("Index 'macae-index' created successfully.") + + # Define indexer + indexer = SearchIndexer( + name="macae-indexer", + data_source_name="macae-blob-datasets", + target_index_name="macae-index" + ) + indexer_client.create_or_update_indexer(indexer) + print("Indexer 'macae-indexer' created successfully.") + + except Exception as e: + print(f"An error occurred while creating search resources: {e}") + +if __name__ == "__main__": + create_search_resources() diff --git a/Data/data_upload.py b/Data/data_upload.py new file mode 100644 index 000000000..f75859a36 --- /dev/null +++ b/Data/data_upload.py @@ -0,0 +1,21 @@ +from azure.storage.blob import BlobServiceClient +import os +from dotenv import load_dotenv + +load_dotenv() + +# Retrieve environment variables +BLOB_CONNECTION_STRING = os.getenv("BLOB_CONNECTION_STRING") +BLOB_CONTAINER_NAME = os.getenv("BLOB_CONTAINER_NAME") +local_folder = "./datasets" + +blob_service_client = BlobServiceClient.from_connection_string(BLOB_CONNECTION_STRING) +container_client = blob_service_client.get_container_client(BLOB_CONTAINER_NAME) + +for filename in os.listdir(local_folder): + file_path = os.path.join(local_folder, filename) + if os.path.isfile(file_path): + print(f"Uploading {filename}...") + with open(file_path, "rb") as data: + container_client.upload_blob(name=filename, data=data, overwrite=True) +print("Upload complete!") diff --git a/Data/datasets/Competitor_Pricing_Analysis.csv b/Data/datasets/Competitor_Pricing_Analysis.csv new file mode 100644 index 000000000..79c8aeedc --- /dev/null +++ b/Data/datasets/Competitor_Pricing_Analysis.csv @@ -0,0 +1,5 @@ +ProductCategory,ContosoAveragePrice,CompetitorAveragePrice +Dresses,120,100 +Shoes,100,105 +Accessories,60,55 +Sportswear,80,85 diff --git a/Data/datasets/Customer_Churn_Analysis.csv b/Data/datasets/Customer_Churn_Analysis.csv new file mode 100644 index 000000000..eaa4c9c24 --- /dev/null +++ b/Data/datasets/Customer_Churn_Analysis.csv @@ -0,0 +1,6 @@ +ReasonForCancellation,Percentage +Service Dissatisfaction,40 +Financial Reasons,3 +Competitor Offer,15 +Moving to a Non-Service Area,5 +Other,37 diff --git a/Data/datasets/Email_Marketing_Engagement.csv b/Data/datasets/Email_Marketing_Engagement.csv new file mode 100644 index 000000000..5d89be28c --- /dev/null +++ b/Data/datasets/Email_Marketing_Engagement.csv @@ -0,0 +1,6 @@ +Campaign,Opened,Clicked,Unsubscribed +Summer Sale,Yes,Yes,No +New Arrivals,Yes,No,No +Exclusive Member Offers,No,No,No +Personal Styling Invite,No,No,No +Autumn Collection Preview,Yes,Yes,No diff --git a/Data/datasets/Loyalty_Program_Overview.csv b/Data/datasets/Loyalty_Program_Overview.csv new file mode 100644 index 000000000..334261e34 --- /dev/null +++ b/Data/datasets/Loyalty_Program_Overview.csv @@ -0,0 +1,2 @@ +TotalPointsEarned,PointsRedeemed,CurrentPointBalance,PointsExpiringNextMonth +4800,3600,1200,1200 diff --git a/Data/datasets/Subscription_benefits_utilization.csv b/Data/datasets/Subscription_benefits_utilization.csv new file mode 100644 index 000000000..c8f07966b --- /dev/null +++ b/Data/datasets/Subscription_benefits_utilization.csv @@ -0,0 +1,5 @@ +Benefit,UsageFrequency +Free Shipping,7 +Early Access to Collections,2 +Exclusive Discounts,1 +Personalized Styling Sessions,0 diff --git a/Data/datasets/Unauthorized_Access_Attempts.csv b/Data/datasets/Unauthorized_Access_Attempts.csv new file mode 100644 index 000000000..2b66bc4b2 --- /dev/null +++ b/Data/datasets/Unauthorized_Access_Attempts.csv @@ -0,0 +1,4 @@ +Date,IPAddress,Location,SuccessfulLogin +2023-06-20,192.168.1.1,Home Network,Yes +2023-07-22,203.0.113.45,Unknown,No +2023-08-15,198.51.100.23,Office Network,Yes diff --git a/Data/datasets/Warehouse_Incident_Reports.csv b/Data/datasets/Warehouse_Incident_Reports.csv new file mode 100644 index 000000000..e7440fcb2 --- /dev/null +++ b/Data/datasets/Warehouse_Incident_Reports.csv @@ -0,0 +1,4 @@ +Date,IncidentDescription,AffectedOrders +2023-06-15,Inventory system outage,100 +2023-07-18,Logistics partner strike,250 +2023-08-25,Warehouse flooding due to heavy rain,150 diff --git a/Data/datasets/customer_feedback_surveys.csv b/Data/datasets/customer_feedback_surveys.csv new file mode 100644 index 000000000..126f0ca64 --- /dev/null +++ b/Data/datasets/customer_feedback_surveys.csv @@ -0,0 +1,3 @@ +SurveyID,Date,SatisfactionRating,Comments +O5678,2023-03-16,5,"Loved the summer dress! Fast delivery." +O5970,2023-09-13,4,"Happy with the sportswear. Quick delivery." diff --git a/Data/datasets/customer_profile.csv b/Data/datasets/customer_profile.csv new file mode 100644 index 000000000..88bc93b9d --- /dev/null +++ b/Data/datasets/customer_profile.csv @@ -0,0 +1,2 @@ +CustomerID,Name,Age,MembershipDuration,TotalSpend,AvgMonthlySpend,PreferredCategories +C1024,Emily Thompson,35,24,4800,200,"Dresses, Shoes, Accessories" diff --git a/Data/datasets/customer_service_interactions.json b/Data/datasets/customer_service_interactions.json new file mode 100644 index 000000000..f8345bff2 --- /dev/null +++ b/Data/datasets/customer_service_interactions.json @@ -0,0 +1,3 @@ +{"InteractionID":"1","Channel":"Live Chat","Date":"2023-06-20","Customer":"Emily Thompson","OrderID":"O5789","Content":["Agent: Hello Emily, how can I assist you today?","Emily: Hi, I just received my order O5789, and wanted to swap it for another colour","Agent: Sure, that's fine- feel free to send it back or change it in store.","Emily: Ok, I'll just send it back then","Agent: Certainly. I've initiated the return process. You'll receive an email with the return instructions.","Emily: Thank you."]} +{"InteractionID":"2","Channel":"Phone Call","Date":"2023-07-25","Customer":"Emily Thompson","OrderID":"O5890","Content":["Agent: Good afternoon, this is Contoso customer service. How may I help you?","Emily: I'm calling about my order O5890. I need the gown for an event this weekend, and just want to make sure it will be delivered on time as it's really important.","Agent: Let me check... it seems like the delivery is on track. It should be there on time.","Emily: Ok thanks."]} +{"InteractionID":"3","Channel":"Email","Date":"2023-09-15","Customer":"Emily Thompson","OrderID":"","Content":["Subject: Membership Cancellation Request","Body: Hello, I want to cancel my Contoso Plus subscription. The cost is becoming too high for me."]} diff --git a/Data/datasets/delivery_performance_metrics.csv b/Data/datasets/delivery_performance_metrics.csv new file mode 100644 index 000000000..9678102bb --- /dev/null +++ b/Data/datasets/delivery_performance_metrics.csv @@ -0,0 +1,8 @@ +Month,AverageDeliveryTime,OnTimeDeliveryRate,CustomerComplaints +March,3,98,15 +April,4,95,20 +May,5,92,30 +June,6,88,50 +July,7,85,70 +August,4,94,25 +September,3,97,10 diff --git a/Data/datasets/product_return_rates.csv b/Data/datasets/product_return_rates.csv new file mode 100644 index 000000000..6c5c4c3f3 --- /dev/null +++ b/Data/datasets/product_return_rates.csv @@ -0,0 +1,6 @@ +Category,ReturnRate +Dresses,15 +Shoes,10 +Accessories,8 +Outerwear,12 +Sportswear,9 diff --git a/Data/datasets/product_table.csv b/Data/datasets/product_table.csv new file mode 100644 index 000000000..79037292c --- /dev/null +++ b/Data/datasets/product_table.csv @@ -0,0 +1,6 @@ +ProductCategory,ReturnRate,ContosoAveragePrice,CompetitorAveragePrice +Dresses,15,120,100 +Shoes,10,100,105 +Accessories,8,60,55 +Outerwear,12,, +Sportswear,9,80,85 diff --git a/Data/datasets/purchase_history.csv b/Data/datasets/purchase_history.csv new file mode 100644 index 000000000..ebc4c312e --- /dev/null +++ b/Data/datasets/purchase_history.csv @@ -0,0 +1,8 @@ +OrderID,Date,ItemsPurchased,TotalAmount,DiscountApplied,DateDelivered,ReturnFlag +O5678,2023-03-15,"Summer Floral Dress, Sun Hat",150,10,2023-03-19,No +O5721,2023-04-10,"Leather Ankle Boots",120,15,2023-04-13,No +O5789,2023-05-05,Silk Scarf,80,0,2023-05-25,Yes +O5832,2023-06-18,Casual Sneakers,90,5,2023-06-21,No +O5890,2023-07-22,"Evening Gown, Clutch Bag",300,20,2023-08-05,No +O5935,2023-08-30,Denim Jacket,110,0,2023-09-03,Yes +O5970,2023-09-12,"Fitness Leggings, Sports Bra",130,25,2023-09-18,No diff --git a/Data/datasets/social_media_sentiment_analysis.csv b/Data/datasets/social_media_sentiment_analysis.csv new file mode 100644 index 000000000..78ed2ec2d --- /dev/null +++ b/Data/datasets/social_media_sentiment_analysis.csv @@ -0,0 +1,8 @@ +Month,PositiveMentions,NegativeMentions,NeutralMentions +March,500,50,200 +April,480,60,220 +May,450,80,250 +June,400,120,300 +July,350,150,320 +August,480,70,230 +September,510,40,210 diff --git a/Data/datasets/store_visit_history.csv b/Data/datasets/store_visit_history.csv new file mode 100644 index 000000000..de5b300a7 --- /dev/null +++ b/Data/datasets/store_visit_history.csv @@ -0,0 +1,4 @@ +Date,StoreLocation,Purpose,Outcome +2023-05-12,Downtown Outlet,Browsing,"Purchased a Silk Scarf (O5789)" +2023-07-20,Uptown Mall,Personal Styling,"Booked a session but didn't attend" +2023-08-05,Midtown Boutique,Browsing,"No purchase" diff --git a/Data/datasets/website_activity_log.csv b/Data/datasets/website_activity_log.csv new file mode 100644 index 000000000..0f7f6c557 --- /dev/null +++ b/Data/datasets/website_activity_log.csv @@ -0,0 +1,6 @@ +Date,PagesVisited,TimeSpent +2023-09-10,"Homepage, New Arrivals, Dresses",15 +2023-09-11,"Account Settings, Subscription Details",5 +2023-09-12,"FAQ, Return Policy",3 +2023-09-13,"Careers Page, Company Mission",2 +2023-09-14,"Sale Items, Accessories",10 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..b7bdd534d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +pyodbc +sqlalchemy +pandas +azure-storage-blob +azure-search-documents +langchain +openai diff --git a/src/backend/services/plan_service.py b/src/backend/services/plan_service.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/backend/test_plan_service.py b/src/backend/test_plan_service.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/frontend/src/pages/PlanCreatePage.tsx b/src/frontend/src/pages/PlanCreatePage.tsx new file mode 100644 index 000000000..e69de29bb diff --git a/src/frontend/src/styles/PlanCreatePage.css b/src/frontend/src/styles/PlanCreatePage.css new file mode 100644 index 000000000..e69de29bb