.devcontainer | ||
.github/workflows | ||
.vscode | ||
ShoppingAssistantApi.Api | ||
ShoppingAssistantApi.Application | ||
ShoppingAssistantApi.Domain | ||
ShoppingAssistantApi.Infrastructure | ||
ShoppingAssistantApi.Persistance | ||
ShoppingAssistantApi.Tests | ||
ShoppingAssistantApi.UnitTests | ||
.gitignore | ||
README.md | ||
ShoppingAssistantApi.sln |
shopping-assistant-api
.NET Back-end API with OpenAI integration for a Shopping Assistant that utilizes Natural Language Processing (NLP) technology to interpret user queries for products and gifts. Users interact through a chat-style interface to communicate their shopping requirements.
Table of Contents
Features
- Chat-style interface that processes natural language queries for product and gift recommendations.
- Integration with OpenAI API to generate intelligent product search responses.
- Server-Sent Events (SSE) streaming product search results to clients in real-time.
- Personal wishlist management with CRUD operations.
- Role and user management with authorization and JWT-based authentication.
- GraphQL API implemented with HotChocolate for flexible queries and mutations.
- Pagination support for roles, users, wishlists, messages, and products.
Stack
- Language: C# (.NET 7)
- Frameworks & Libraries:
- ASP.NET Core Web API
- HotChocolate GraphQL
- MongoDB with official C# driver
- Authentication & Security:
- JWT Bearer Authentication
- Password hashing with PBKDF2 (Rfc2898DeriveBytes)
- Cloud & DevOps:
- Azure App Configuration
- GitHub Actions for CI/CD workflows
- External APIs:
- OpenAI API for natural language processing and chat completions
- Tools & Extensions:
- Swagger / OpenAPI for API documentation
- Server-Sent Events for realtime streaming responses
- Visual Studio Code DevContainer for development environment
Installation
Prerequisites
- .NET 7 SDK
- MongoDB instance (local or hosted)
- An OpenAI API key to access the OpenAI services
Setup Instructions
-
Clone the repository:
git clone https://github.com/Shchoholiev/shopping-assistant-api.git cd shopping-assistant-api
-
Navigate to the API project and restore dependencies:
dotnet restore ShoppingAssistantApi.Api/ShoppingAssistantApi.Api.csproj
-
Build the solution:
dotnet build ShoppingAssistantApi.sln
-
Configure the environment variables (see Configuration section).
-
Run the API locally:
cd ShoppingAssistantApi.Api dotnet run
-
The API will start and Swagger UI will be available (usually at
https://localhost:7268/swagger
). -
Use GraphQL Playground or REST clients to interact with the API.
Configuration
The application uses configuration files and environment variables to configure key settings. Important configuration values are:
-
MongoDB connection:
- Set your MongoDB connection string (default database name is
ShoppingAssistant
) inappsettings.json
or environment variable:"ConnectionStrings": { "MongoDatabaseName": "ShoppingAssistant" }
- The connection string URL is typically configured externally.
- Set your MongoDB connection string (default database name is
-
JWT Authentication: Configure JWT validation parameters in your configuration with keys like:
"JsonWebTokenKeys": { "ValidateIssuer": true, "ValidateAudience": true, "ValidateLifetime": true, "ValidateIssuerSigningKey": true, "ValidIssuer": "<your-issuer>", "ValidAudience": "<your-audience>", "IssuerSigningKey": "<your-secret-key>" }
-
OpenAI API: API endpoint and API key settings:
"OpenAi": { "ApiUrl": "https://api.openai.com/v1/chat/completions", "ApiKey": "<your_openai_api_key>" }
Set the API key securely via environment variables or Azure App Configuration.