This document provides a detailed overview of the Travel Advisor application architecture, components, and data flow.
Travel Advisor is a .NET 9 Blazor Server application that helps users find the best transportation options for their journeys. It combines natural language processing with real-world travel data to provide personalized recommendations based on user preferences.
┌─────────────────────────────────────────────────────────────────┐
│ TravelAdvisor.Web │
│ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ Blazor Pages │ │ Shared Layout │ │ Services │ │
│ └───────┬───────┘ └───────────────┘ └───────────────┘ │
│ │ │
└──────────┼──────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ TravelAdvisor.Infrastructure │
│ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ AI Integration│ │ Map Services │ │Cloud Foundry │ │
│ │ Services │ │ │ │ Integration │ │
│ └───────┬───────┘ └───────┬───────┘ └───────────────┘ │
│ │ │ │
└──────────┼────────────────────┼─────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────┐ ┌─────────────────────┐
│ LLM Service │ │ Google Maps API │
│ (OpenAI/Azure) │ │ │
└─────────────────────┘ └─────────────────────┘
▲ ▲
│ │
┌──────────┴────────────────────┴─────────────────────────────────┐
│ TravelAdvisor.Core │
│ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │Domain Models │ │ Interfaces │ │ Utilities │ │
│ └───────────────┘ └───────────────┘ └───────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
The application follows a clean architecture pattern with three main projects:
Contains the domain models, interfaces, and core business logic.
Key components:
- Models: Domain entities like
TravelQueryandTravelRecommendation - Interfaces: Service contracts like
ITravelAdvisorServiceandIMapService - Utilities: Helper classes for environment variable loading and other utilities
Implements the services defined in the Core project and handles external integrations.
Key components:
- Services: Implementation of core interfaces
TravelAdvisorService: Processes queries and generates recommendations using LLMsGoogleMapsService: Retrieves travel data from Google Maps API
- Clients: AI client implementations
AIClientFactory: Creates appropriate AI clients based on configurationAzureOpenAIClientAdapter: Adapter for Azure OpenAICustomEndpointChatClient: Client for custom OpenAI-compatible endpoints
- CloudFoundry: Integration with Tanzu Platform for Cloud Foundry
ServiceBindingConfiguration: Handles service bindings for GenAI services
The Blazor Server web application that provides the user interface.
Key components:
- Pages: Blazor pages for user interaction
Advisor.razor: Main page for travel recommendationsIndex.razor: Landing pageAbout.razor: Information about the application
- Shared: Shared UI components
MainLayout.razor: Main layout templateNavMenu.razor: Navigation menu
- Utilities: Web-specific utilities
MarkdownRenderer.cs: Renders markdown content in the UI
-
User Query Processing:
- User enters a natural language query on the Advisor page
TravelAdvisorService.ProcessNaturalLanguageQueryAsyncsends the query to the LLM- LLM extracts structured data (origin, destination, preferences)
- Result is returned as a
TravelQueryobject
-
Recommendation Generation:
TravelAdvisorService.GenerateRecommendationsAsyncprocesses the structured query- For each transportation mode, it calls
GoogleMapsServiceto get distance and duration - It calculates scores for environmental impact, convenience, and preference match
- It returns a list of
TravelRecommendationobjects sorted by overall score
-
Explanation Generation:
TravelAdvisorService.GenerateExplanationAsynccreates a natural language explanation- It sends the recommendation details to the LLM
- LLM generates a conversational explanation of why the mode is recommended
-
Follow-up Questions:
- User can ask follow-up questions about a recommendation
TravelAdvisorService.AnswerFollowUpQuestionAsyncprocesses the question- It sends the question, recommendation details, and original query to the LLM
- LLM generates a natural language answer
- .NET 9: The latest version of the .NET framework
- Blazor Server: For interactive web UI
- Microsoft.Extensions.AI: Microsoft's framework for LLM integration
- Steeltoe: Libraries for Cloud Foundry integration
- Tailwind CSS: Utility-first CSS framework for modern UI
The application can integrate with various LLM providers:
- OpenAI: Using the official OpenAI SDK
- Azure OpenAI: Using the Azure OpenAI SDK
- Custom Endpoints: Using a custom implementation for OpenAI-compatible endpoints
The integration is handled through the IChatClient interface from Microsoft.Extensions.AI.
The application integrates with Google Maps API to get real travel data:
- Distance and Duration: For different transportation modes
- Travel Steps: Detailed breakdown of the journey
- Mode Reasonability: Determining if a mode is reasonable for a given distance
The application uses Steeltoe for Cloud Foundry integration:
- Service Bindings: Automatically detects and uses GenAI services
- Actuators: Health monitoring and management endpoints
- Configuration: Cloud Foundry-specific configuration
- API Key Management: API keys are stored in environment variables or service bindings
- Logging: Sensitive information is masked in logs
- Input Validation: User input is validated before processing
- Caching: Responses can be cached to reduce API calls
- Async Processing: All operations are asynchronous for better responsiveness
- Error Handling: Comprehensive error handling to ensure reliability
The application is designed for extensibility:
- New Transportation Modes: Can be added by extending the
TransportModeenum - Alternative Map Services: Can be implemented by creating a new
IMapServiceimplementation - Different AI Providers: Can be added by implementing the
IChatClientinterface