This project is an anonymous real-time chat application that detects the sentiment of messages using Azure Text Analytics API. The application is built with ASP.NET Core 8, Vite, React, TypeScript, and CSS, and is deployed on Azure.
- Anonymous Chat: Users can participate in chat conversations without requiring authentication.
- Real-Time Communication: Leverages Azure SignalR Service for real-time messaging.
- Sentiment Analysis: Uses Azure Text Analytics API to analyze the sentiment of each message (positive, neutral, negative).
- Scalable and Secure: Deployed on Azure, ensuring scalability and security.
- Backend: ASP.NET Core 8
- Frontend: Vite, React, TypeScript, CSS
- Real-Time Messaging: Azure SignalR Service
- Sentiment Analysis: Azure Text Analytics API
- Deployment Platform: Azure
- Node.js: Ensure you have Node.js installed.
- .NET SDK: Make sure the .NET SDK 8 is installed.
- Azure Account: You need an Azure account to deploy the application and use Azure services.
-
Clone the Repository:
git clone <repository-url> cd <repository-name>```
-
Install Frontend Dependencies
Navigate to the client
directory where the React frontend is located, and install the necessary dependencies using Vite:
cd client
npm install
-
Change Values Such As URLs
-
Set Up Azure Services
Before running the application, set up the required Azure services:
Azure SignalR Service
- Log in to the Azure Portal.
- Create a new Azure SignalR Service instance.
- Retrieve the connection string from the SignalR Service's settings and note it down.
Azure Text Analytics API
- In the Azure Portal, create a new Cognitive Services resource.
- Choose the "Text Analytics" service.
- Once created, get the endpoint URL and API key from the resource's "Keys and Endpoint" section.
Copy code
Securely store your sensitive information using Azure Key Vault to enhance the security of your application by keeping secrets out of your codebase.
-
Log in to Azure Portal:
- Visit Azure Portal and log in with your credentials.
-
Create a New Key Vault Resource:
- Navigate to "Create a resource".
- Search for "Key Vault" and select "Key Vault" from the list.
- Click "Create".
- Fill in the required information such as Subscription, Resource Group, Key Vault Name, and Region.
- Click "Review + Create" and then "Create".
-
Navigate to Your Key Vault:
- Once the Key Vault is created, go to your Key Vault by selecting it from the dashboard or through the Resource Group.
-
Add Secrets:
-
In the Key Vault, go to the "Secrets" section in the left-hand menu.
-
Click "Generate/Import" to add a new secret.
-
Add the following secrets one by one, providing a name and value for each:
-
Name:
SignalRConnectionString
Value:<your-signalr-connection-string>
-
Name:
TextAnalyticsEndpoint
Value:<your-text-analytics-endpoint>
-
Name:
CognitiveServicesApiKey
Value:<your-congnitive-service-key>
-
Name:
CognitiveServicesEndpoint
Value:<your-congnitive-service-endpoint>
-
Name:
DbConnection
Value:<your-database-connection-string>
-
Click "Create" for each secret to save them.
-
-
Navigate to Your App Service:
- In the Azure Portal, go to your App Service that will host the backend of your application.
-
Assign a Managed Identity:
- In the App Service menu, go to "Identity".
- Turn on the System Assigned Managed Identity and click "Save".
- Note down the Object ID assigned to your App Service.
-
Grant Access to the Key Vault:
- Return to your Key Vault.
- In the Key Vault menu, go to "Access control".
- Click "Add".
- Select Add Role Assignment in dropdown.
- Choose Key Vault Crypto User and click next.
- Choose Assign access to Managed identity
- Click Select members
- Choose your backend api resourse as a managed identity.
- Click "Select" and then "Review + asign" to apply the policy.
For Backend Part:
Under "API", select "CORS". Add allowed origins such as your frontend domain (https://your-frontend-domain.com).
In SignalR service asign Contributor role for a Web App Service that contains backend part.
In Sql Server int the left panell navigate to Security < Neworking. Click Add a firewall rule, add name, and enter backend api in Start IP and End IP
Deployed Application - https://white-river-01e1da10f.5.azurestaticapps.net (deactivated)