This is a production-ready RAG (Retrieval Augmented Generation) chat application that demonstrates best practices for creating ChatGPT-like experiences over enterprise data. The solution implements an event-driven microservices architecture using Java, React, and Azure AI services, with support for multiple deployment platforms (Azure Container Apps, Azure Kubernetes Service, and Azure App Service).
The application serves as a fictional Contoso Electronics employee portal where users can ask questions about benefits, policies, job descriptions, and roles. It features document upload management, role-based access control with EntraID, and real-time document indexing.
- Framework: Spring Boot 3.3.2
- Java Version: 17 (Microsoft JDK)
- AI Orchestration: Langchain4J 1.0.1
- Key Dependencies:
azure-ai-openai1.0.0-beta.16 - Azure OpenAI Service integrationlangchain4j-azure-open-ai- LangChain4J Azure adapterspring-cloud-azure5.14.0 - Azure service integrationsazure-search-documents11.7.2 - Azure AI Search SDK- Spring WebFlux - Reactive/streaming support
- Build Tool: Maven
- Features:
- Synchronous and asynchronous streaming chat endpoints
- RAG pattern orchestration between LLM and content retrieval
- Response tracking with citations, search keywords, and token usage
- CosmosDB integration for chat history
- Framework: React 18.3.1
- Build Tool: Vite 5.4.18
- Language: TypeScript 5.6.3
- UI Library: Fluent UI (React Components & Icons)
- Key Dependencies:
@azure/msal-react2.2.0 - Microsoft Authentication Library@azure/msal-browser3.26.1 - MSAL browser supportreact-router-dom6.28.0 - Routingreact-markdown9.0.1 - Markdown renderingreact-syntax-highlighter15.6.1 - Code highlightingi18next24.2.0 - Internationalizationidb8.0.0 - IndexedDB for browser-based chat history
- Web Server: Nginx (reverse proxy in production)
- Node Version: >= 20.0.0
- Framework: Spring Boot 3.3.2
- Java Version: 17
- AI Components: Langchain4J 1.0.1
- Key Dependencies:
azure-ai-documentintelligence4.1.4 - Document parsingazure-sdk-bom1.2.33 - Azure SDK managementpicocli4.7.5 - CLI interface (for CLI module)itextpdf5.5.13.3 - PDF processing
- Modules:
- Core: Shared indexing logic and utilities
- CLI: Command-line interface for batch indexing
- Microservice: Event-driven indexing service
- Functions: Azure Functions implementation for blob processing
- Build Tool: Maven
- Azure OpenAI Service: GPT-4o-mini model for chat completions
- Azure AI Search: Vector and hybrid search for document retrieval
- Azure Document Intelligence: Structured text and table extraction from PDFs
- Azure Cosmos DB: Chat conversation history storage
- Azure Blob Storage: Document storage (staging and default containers)
- Azure Service Bus: Message queue for async indexing triggers
- Azure Event Grid: Real-time blob upload notifications
- Azure Application Insights: Monitoring and telemetry
- Azure Container Apps / AKS / App Service: Hosting platforms
- Azure Key Vault: Secrets management
- Azure Monitor: Observability and diagnostics
- EntraID (Azure Active Directory): Authentication and authorization
- IaC Tool: Bicep (Azure native)
- Orchestration: Azure Developer CLI (azd)
- Containerization: Docker
- Container Orchestration Options:
- Docker Compose (local development)
- Azure Container Apps (serverless containers)
- Azure Kubernetes Service (full Kubernetes)
- CI/CD: Azure Pipelines, GitHub Actions
- Development Environment: Dev Containers support
- Framework: Python-based evaluation scripts
- Test Types:
- Ground truth evaluation
- Safety evaluation
- Response quality metrics
- Dependencies: Python 3.x with custom evaluation requirements
| File/Folder | Description |
|---|---|
README.md |
Main project documentation with quick start guides |
CHANGELOG.md |
Version history and release notes |
CONTRIBUTING.md |
Contribution guidelines for developers |
LICENSE / LICENSE.md |
MIT License files |
SECURITY.md |
Security policy and vulnerability reporting |
CODEOWNERS |
GitHub code ownership definitions |
ps-rule.yaml |
Azure PSRule configuration for infrastructure validation |
Main application directory containing all microservices and frontend code.
Spring Boot API service implementing the RAG chat orchestration.
- Key Files:
pom.xml- Maven build configuration with dependenciesDockerfile- Container image definitionmanifest.yml- Azure deployment manifestapplicationinsights.json- Application Insights configurationmvnw,mvnw.cmd- Maven wrapper scripts
- Subdirectories:
src/main/- Java source code (controllers, services, models)manifests/- Kubernetes deployment manifestsbackend-deployment.tmpl.yml- Backend deployment templatebackend-service.yml- Kubernetes service definitioningress.yml- Ingress configuration
The backend follows a layered architecture pattern with clear separation of concerns:
-
Application.java- Spring Boot application entry point and main class -
approaches/- RAG pattern configuration and options- Defines retrieval strategies, search modes, and RAG types
- Contains
RAGOptions,RAGResponse,RetrievalMode,RAGTypeenums ContentSourceinterface for content retrieval abstraction
-
ask/- Single-turn question/answer implementationcontroller/- REST endpoints for one-shot Q&A interactions- Implements simple RAG flow without conversation history
-
chat/- Multi-turn conversational chat implementationlangchain4j/- Langchain4J-based chat orchestration services- Manages conversation context and history integration
- Implements streaming and synchronous chat responses
-
common/- Shared utilities and helper classesChatGPTConversation- Conversation state managementChatGPTMessage- Message abstraction and formattingChatGPTUtils- Azure OpenAI API utilitiesResponseMessageUtils- Response formatting helpers
-
config/- Spring configuration classes and beansAppConfigurationProperties- Application-wide settingsAppAuthConfigurationProperties- Authentication configurationAzureAISearchConfiguration- Azure AI Search client setupAzureAuthenticationConfiguration- Azure SDK authenticationCosmosConfiguration- CosmosDB client configurationLangchain4JConfiguration- Langchain4J components wiringOpenAIConfiguration- Azure OpenAI client setupWebSecurityConfiguration- Spring Security settings
-
content/- Document content managementContentController- REST APIs for content operationsIndexService- Azure AI Search indexing operationsFilenameRequest,IndexClientRequest- Request DTOs- Handles document upload, retrieval, and management
-
controller/- Additional REST controllersauth/- Authentication and authorization endpointsconfig/- Configuration exposure endpoints
-
history/- Chat conversation history managementChatHistoryService- Business logic for history operationsChatHistoryRepository- CosmosDB data access layerChatHistoryItem- Entity model for conversation persistenceChatHistoryRequest- History query/update requestsChatHistoryItemHierarchicalPartitionKey- CosmosDB partitioningSession,MessagePair- Conversation data structures
-
model/- Data Transfer Objects (DTOs) and API modelsChatAppRequest- Incoming chat request structureChatAppResponse- Chat response envelopeChatAppRequestOverrides- User-configurable optionsChatAppRequestContext- Request context metadataResponseMessage,ResponseChoice,ResponseContext- Response componentsResponseThought,ResponseDataPoint- Response metadata
-
proxy/- External service proxies and adaptersBlobStorageProxy- Azure Blob Storage operations wrapper- Abstracts storage operations for content management
-
security/- Authentication and authorization servicesLoggedUserService- Current user context managementLoggedUser- User principal and claims extraction- Integrates with EntraID/MSAL authentication
React-based web application with TypeScript and Vite.
- Key Files:
package.json- NPM dependencies and scriptstsconfig.json- TypeScript compiler configurationvite.config.ts- Vite build tool configurationindex.html- HTML entry pointDockerfile- Container image for standard deploymentDockerfile-aks- Optimized container for AKS
- Subdirectories:
src/- React source codecomponents/- Reusable React componentspages/- Page-level componentsapi/- API client codeassets/- Static assets (images, fonts)locales/- i18n translation filesi18n/- Internationalization configurationauthConfig.ts- MSAL authentication setuploginContext.tsx- Authentication context providerindex.tsx- Application entry point
public/- Static public assetsnginx/- Nginx configuration for productionmanifests/- Kubernetes manifests for frontend deployment
Document indexing service with multiple deployment modes.
- Key Files:
pom.xml- Parent Maven POM for multi-module projectmvnw,mvnw.cmd- Maven wrapper scripts
- Subdirectories:
core/- Shared indexing logic, document processing, embedding generationcli/- Command-line interface for batch document indexingdependency-reduced-pom.xml- Shaded JAR configuration
microservice/- Spring Boot service for event-driven indexingDockerfile- Container image definitionapplicationinsights.json- Monitoring configuration
manifests/- Kubernetes deployment manifests
The indexer follows a modular architecture with three deployment modules sharing a common core:
Shared indexing pipeline implementation used by all deployment modes:
-
langchain4j/- Langchain4J-based document processing pipeline-
ConfigUtils.java- Configuration utilities and helpers -
Langchain4JIndexingPipeline.java- Main indexing orchestration pipeline -
PagedDocument.java/DefaultPagedDocument.java- Document page abstraction -
DocumentLoader.java- Document loading from various sources -
PipelineContext.java- Execution context and metadata -
IndexingMetadata.java- Tracking and monitoring metadata -
IndexingConfigException/IndexingProcessingException- Custom exceptions -
embedding/- Text embedding generation- Azure OpenAI embeddings integration
- Batch processing and optimization
-
loader/- Document loaders for various sources- Blob storage loader
- File system loader
- HTTP/URL loaders
-
parser/- Document format parsers- PDF parser (Azure Document Intelligence integration)
- HTML parser with markdown conversion
- Office document parsers (DOCX, XLSX, PPTX)
- Plain text and markdown parsers
- Table extraction and preservation
-
providers/- Service provider implementations- Azure AI Search embedding store provider
- Azure OpenAI service provider
- Document Intelligence service provider
-
splitter/- Document chunking strategies- Recursive character text splitters
- Sentence-based splitting
- Token-aware splitting with overlap
- Custom splitting strategies
-
-
storage/- Azure Blob Storage operationsBlobManager.java- Blob upload/download/move operations- Container management and SAS token handling
Command-line interface for batch document indexing:
cli/- CLI implementation packageCLI.java- Main CLI entry point with picocli frameworklangchain4j/- CLI-specific Langchain4J integrationsUploadCommand.java- Document upload command implementation- Batch processing commands
- Index management commands
Spring Boot event-driven microservice for automated indexing:
service/- Main service package-
IndexerApplication.java- Spring Boot application entry point -
config/- Spring configuration classesIngestionConfigurationProperties.java- Indexing settingsAzureAISearchEmbeddingStoreConfiguration.java- Search client setupAzureBlobStorageConfiguration.java- Blob storage client setupAzureAuthenticationConfiguration.java- Azure SDK authenticationDocumentIntelligenceConfiguration.java- Document Intelligence setupOpenAIConfiguration.java- Azure OpenAI client configurationServiceBusConfig.java/ServiceBusProcessorClientConfiguration.java- Service Bus setup
-
controller/- REST API endpointsIndexController.java- Indexing REST API controllerIndexingRequest.java- Request DTO for manual indexing triggers- Exposes endpoints for on-demand document indexing
-
events/- Event-driven message processingBlobMessageListener.java- Service Bus message consumerBlobUpsertEventGridEvent.java- Event Grid event modelBlobEventGridData.java- Blob event data extraction- Processes blob upload events for automatic indexing
-
langchain4j/- Microservice-specific Langchain4J servicesLangchain4JIndexerService.java- Main indexing service orchestration- Integrates core pipeline with Spring Boot lifecycle
- Async processing and error handling
-
Indexer Architecture Flow:
- Document uploaded → Event Grid notification → Service Bus queue
BlobMessageListenerreceives message → extracts blob URLLangchain4JIndexerServiceorchestrates processing- Core pipeline: Load → Parse (Document Intelligence) → Chunk → Embed → Index
- Document moved from staging to default container
- Metadata and status tracked throughout process
Sample documents and test data for the Contoso Electronics scenario (benefits PDFs, policies, job descriptions).
Infrastructure-as-Code and deployment scripts for different Azure platforms.
Serverless container platform deployment.
- Key Files:
azure.yaml- Azure Developer CLI configurationcompose.yaml- Docker Compose for local developmentstart-compose.ps1/start-compose.sh- Local startup scripts
- Subdirectories:
infra/- Bicep infrastructure templatesmain.bicep- Main infrastructure definitionmain.parameters.json- Environment parametersapp/- Application-specific resources
scripts/- Automation scriptsauth_init.*- EntraID authentication setupauth_update.*- Authentication configuration updatesload_azd_env.*- Environment variable loading- Python and PowerShell utilities
Full Kubernetes orchestration deployment.
- Key Files:
azure.yaml- AKS-specific azd configurationcompose.yaml- Local Docker Compose setupingress-tls.yml- TLS ingress configurationstart-compose.ps1/start-compose.sh- Local startup scripts
- Subdirectories:
infra/- Bicep templates for AKS cluster and resourcesscripts/- Deployment automation scriptseasyauth/- Easy Auth proxy configuration for authentication
Traditional PaaS web app deployment option.
- Contains scripts and configurations for deploying to Azure App Service
Common Bicep modules used across deployment types.
- Key Files:
abbreviations.json- Azure resource naming conventionsabbreviations-old.json- Legacy naming patternsbackend-dashboard.bicep- Azure Dashboard configuration
- Subdirectories:
ai/- Azure OpenAI and AI Search modulesentra/- EntraID authentication modulesevent/- Event Grid and Service Bus moduleshost/- Container hosting modules (ACA/AKS)monitor/- Application Insights and monitoringsearch/- Azure AI Search configurationsecurity/- Key Vault and security modulesservicebus/- Service Bus queue modulesstorage/- Blob Storage modules
Azure Container Apps deployment guides.
README-ACA.md- Complete ACA deployment documentationlocal-development-intellij.md- IntelliJ IDEA setuplogin_and_acl.md- Authentication and access controlevaluation.md- Model evaluation guidesafety_evaluation.md- Safety and content filtering
Azure Kubernetes Service deployment guides.
README-AKS.md- Complete AKS deployment documentationlogin_and_acl.md- Authentication and RBAC setup
Azure App Service deployment guide.
README-App-Service.md- App Service deployment instructions
Python-based evaluation framework for testing chat quality and safety.
- Key Files:
evaluate.py- Main evaluation scriptevaluate_config.json- Evaluation configurationsafety_evaluation.py- Safety and content moderation testsgenerate_ground_truth.py- Ground truth dataset generatorground_truth.jsonl- Test dataset in JSONL formatground_truth_kg.json- Knowledge graph ground truthsafety_results.json- Safety evaluation resultsrequirements.txt- Python dependencies
- Subdirectories:
results/baseline/- Baseline evaluation results
Chat Flow (Backend API):
- User query received
- Query embedding generated (Azure OpenAI)
- Vector/hybrid search executed (Azure AI Search)
- Relevant document chunks retrieved
- Context + query sent to LLM (GPT-4o-mini)
- Response streamed back with citations
Ingestion Flow (Indexer Service):
- Document uploaded to Blob Storage
- Event Grid triggers Service Bus message
- Indexer service processes blob URL
- Azure Document Intelligence extracts text/tables
- Document chunked and embedded
- Chunks indexed in Azure AI Search
- Document moved to default container
- API Service: Stateless REST API, horizontally scalable
- Frontend: Static React SPA served via Nginx
- Indexer Service: Event-driven worker, scales on queue depth
- Persistence: CosmosDB (chat history), Azure AI Search (vectors), Blob Storage (documents)
- Communication: Service Bus for async messaging, HTTPS for synchronous APIs
- Docker Compose for full stack local testing
- Dev Containers for consistent development environment
- Hot reload enabled for frontend (Vite) and backend (Spring Boot DevTools)
- Infrastructure Provisioning:
azd provisionusing Bicep templates - Application Deployment:
azd deploycontainerized services - Authentication Setup: Run auth scripts for EntraID configuration
- Azure Container Apps: Serverless, auto-scaling, event-driven
- Azure Kubernetes Service: Full control, advanced networking, production-grade
- Azure App Service: Simple PaaS deployment for smaller workloads
- Text Search: Traditional full-text search with BM25 ranking
- Vector Search: Semantic similarity using embeddings
- Hybrid Search: Combined text + vector with score fusion
- Semantic Ranking: Azure AI Search semantic reranking
- EntraID Integration: OAuth 2.0 / OpenID Connect via MSAL
- Document ACLs: Role-based access control for documents
- Anonymous Mode: Browser-local storage for unauthenticated users
- Application Insights: Telemetry, traces, metrics
- Azure Monitor: Infrastructure monitoring
- Logging: Structured logging with correlation IDs
- Supported Formats: PDF, HTML, Markdown, DOCX, XLSX, PPTX
- Extraction Methods:
- Azure Document Intelligence (tables, images, structure)
- Langchain4J parsers (alternative)
- Chunking: Configurable chunk size and overlap strategies
- Java 17+ (Microsoft JDK recommended)
- Node.js 20+
- Docker Desktop
- Azure subscription
- Azure Developer CLI (azd)
# Clone repository
git clone <repository-url>
# Choose deployment target and follow guide
# For ACA: docs/aca/README-ACA.md
# For AKS: docs/aks/README-AKS.md
# For App Service: docs/app-service/README-App-Service.md
# Local development with Docker Compose
cd deploy/aca # or deploy/aks
./start-compose.sh # or start-compose.ps1 on Windows# Backend
cd app/backend
./mvnw clean package
# Frontend
cd app/frontend
npm install
npm run build
# Indexer
cd app/indexer
./mvnw clean packageLast Updated: February 2026
Version: 1.4.0-SNAPSHOT