This document provides detailed instructions for setting up and developing the Travel Advisor application.
The Travel Advisor application follows a clean architecture pattern with three main projects:
- TravelAdvisor.Core: Contains the domain models, interfaces, and core business logic
- TravelAdvisor.Infrastructure: Implements services defined in the Core project
- TravelAdvisor.Web: The Blazor Server web application
- .NET 9 SDK
- Visual Studio 2025 or VS Code with C# extensions
- Google Maps API key
- Access to an LLM service compatible with the OpenAI API format
git clone https://github.com/cf-toolsuite/tanzu-genai-showcase
cd tanzu-genai-showcase/dotnet-extensions-aiCreate a .env file in the src/TravelAdvisor.Web directory:
cp src/TravelAdvisor.Web/.env.example src/TravelAdvisor.Web/.envEdit the .env file to include:
GENAI__APIKEY=your_llm_api_key
GENAI__APIURL=your_llm_api_url
GENAI__MODEL=your_llm_model_name
GOOGLEMAPS__APIKEY=your_google_maps_api_key# Restore dependencies
dotnet restore
# Build the solution
dotnet build
# Run the web project
dotnet run --project src/TravelAdvisor.Web- Open the
TravelAdvisor.slnfile in Visual Studio - Right-click on the
TravelAdvisor.Webproject and select "Set as Startup Project" - Press F5 to build and run the application
The application uses Microsoft.Extensions.AI to interact with LLMs. The main integration is in:
TravelAdvisorService.cs: Handles communication with the LLM to process queries and generate recommendationsAIClientFactory.cs: Creates appropriate AI clients based on configurationAzureOpenAIClientAdapter.cs: Adapter for Azure OpenAICustomEndpointChatClient.cs: Client for custom OpenAI-compatible endpoints
The application uses the Google Maps API to get real travel data:
GoogleMapsService.cs: Provides methods to get distance, duration, and other travel information
The application uses Steeltoe for Cloud Foundry integration:
- Service bindings are configured in
ServiceBindingConfiguration.cs - Actuators for health monitoring and management are configured in
Program.cs
- Start by defining interfaces in the Core project
- Implement the interfaces in the Infrastructure project
- Wire up dependencies in the
DependencyInjection.csfile - Add UI components in the Web project
The application supports different testing approaches:
- Unit tests for core business logic
- Integration tests for services
- End-to-end tests for UI workflows
To run tests:
dotnet testThe application uses Tailwind CSS for styling. When making UI changes:
- Edit the Razor files in the
TravelAdvisor.Web/PagesandTravelAdvisor.Web/Sharedfolders - The application uses the Tailwind CDN, so styles will update automatically
- For production, consider setting up a build process to optimize Tailwind CSS
- Missing Environment Variables: Ensure the
.envfile is properly configured and loaded - API Key Issues: Verify your API keys are valid and have the necessary permissions
- Build Errors: Run
dotnet cleanfollowed bydotnet buildto resolve build issues
- Use
Console.WriteLinestatements for simple logging - For more advanced logging, configure Steeltoe's dynamic logger
- Use breakpoints in Visual Studio or VS Code to step through code
- Separation of Concerns: Keep business logic in the Core project
- Dependency Injection: Use interfaces and DI for testable components
- Error Handling: Use try-catch blocks and provide user-friendly error messages
- Environment Configuration: Use environment variables for all configuration
- Security: Never commit API keys or secrets to version control
- Create a feature branch for your changes
- Make your changes following the coding standards
- Write/update tests for your changes
- Ensure all tests pass
- Submit a pull request