# azure-samples/azure-search-openai-demo-java architecture

> Architecture diagram of the GitHub repository azure-samples/azure-search-openai-demo-java, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure-samples/azure-search-openai-demo-java
- Repository: https://github.com/azure-samples/azure-search-openai-demo-java

## Overview

##### Main Components

a. Frontend Layer:
- React-based web application (TypeScript)
- Authentication components
- Chat and Q&A interfaces
- Settings and configuration UI

b. Backend Services:
- Java Spring Boot API service
- Document Indexer service
- Authentication/Authorization service

c. Azure Services:
- Azure OpenAI Service
- Azure AI Search
- Azure Document Intelligence
- Azure Blob Storage
- Azure Monitor/Application Insights
- Azure Active Directory

##### Key Architectural Patterns to Highlight

a. Microservices Architecture:
- Clear separation between frontend, backend, and indexer services
- Containerization (Docker) for each service
- Deployment options (App Service, Container Apps, or AKS)

b. RAG Pattern Implementation:
- Document the flow from user input to response generation
- Different RAG approaches (Plain Java vs Semantic Kernel)
- Vector search and hybrid search paths

**[Web Frontend (React/TypeScript)]**

**[Authentication Layer (Azure AD)]**

**[Backend API Service]──────[Indexer Service]**

**[RAG Orchestration]────────[Document Processing]**

**[Azure OpenAI]──[Azure AI Search]──[Blob Storage]**

**[App Insights]──[Document Intelligence]──[Key Vault]**

- User interaction flow
- Document ingestion pipeline
- Search and retrieval paths
- Authentication flows
- Monitoring and logging paths

##### Additional Elements

- Scaling components (load balancers, etc.)
- Security boundaries and network isolation

##### Implementation Details

- Plain Java OpenAI SDK implementation
- Semantic Kernel implementation
- Vector store integration
- Prompt flow and construction

##### Deployment Views

- App Service deployment
- Azure Container Apps deployment
- AKS deployment

Remember to include:
- Version information
- Date of last update
- Author/team information
- Reference to source documentation
- Any relevant configuration details

Tools Recommendation:
- Microsoft Visio for enterprise environments

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#E1F5FE,stroke:#01579B
    classDef backend fill:#E8F5E9,stroke:#1B5E20
    classDef azure fill:#E3F2FD,stroke:#0D47A1
    classDef security fill:#FFF3E0,stroke:#E65100
    classDef indexer fill:#F3E5F5,stroke:#4A148C
    classDef rag fill:#FFEBEE,stroke:#B71C1C

    %% Frontend Layer
    subgraph Frontend
        WebApp["React Web App"]:::frontend
        AuthUI["Authentication UI"]:::frontend
        ChatUI["Chat Interface"]:::frontend
        SettingsUI["Settings UI"]:::frontend
    end

    %% Authentication Layer
    AzureAD["Azure AD"]:::security

    %% Backend Services Layer
    subgraph Backend
        APIService["Spring Boot API"]:::backend
        AuthConfig["Auth Configuration"]:::backend
        OpenAIConfig["OpenAI Configuration"]:::backend
    end

    %% RAG Implementation Layer
    subgraph RAGLayer
        CoreRAG["Core RAG Logic"]:::rag
        PlainJava["Plain Java Approach"]:::rag
        SemanticKernel["Semantic Kernel Approach"]:::rag
    end

    %% Indexer Service Layer
    subgraph Indexer
        IndexerCore["Core Indexing"]:::indexer
        DocProcessor["Document Processor"]:::indexer
        PDFParser["PDF Parser"]:::indexer
        EmbeddingService["Embeddings Service"]:::indexer
    end

    %% Azure Services Layer
    subgraph AzureServices
        OpenAI["Azure OpenAI"]:::azure
        AISearch["Azure AI Search"]:::azure
        BlobStorage["Azure Blob Storage"]:::azure
        DocIntelligence["Document Intelligence"]:::azure
        AppInsights["Application Insights"]:::azure
    end

    %% Connections
    WebApp --> AuthUI
    WebApp --> ChatUI
    WebApp --> SettingsUI
    AuthUI --> AzureAD
    ChatUI --> APIService
    APIService --> AuthConfig
    APIService --> OpenAIConfig
    APIService --> CoreRAG
    CoreRAG --> PlainJava
    CoreRAG --> SemanticKernel
    PlainJava --> OpenAI
    SemanticKernel --> OpenAI
    IndexerCore --> DocProcessor
    DocProcessor --> PDFParser
    DocProcessor --> EmbeddingService
    EmbeddingService --> OpenAI
    DocProcessor --> AISearch
    DocProcessor --> BlobStorage
    APIService --> AISearch
    DocProcessor --> DocIntelligence

    %% Click Events
    click WebApp "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/frontend/src"
    click AuthUI "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/frontend/src/components/LoginButton"
    click ChatUI "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/frontend/src/pages/chat/Chat.tsx"
    click SettingsUI "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/frontend/src/components/SettingsButton"
    click APIService "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/Application.java"
    click AuthConfig "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/config/AzureAuthenticationConfiguration.java"
    click OpenAIConfig "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/config/OpenAIConfiguration.java"
    click CoreRAG "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/approaches"
    click PlainJava "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/ask/approaches/PlainJavaAskApproach.java"
    click SemanticKernel "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/ask/approaches/semantickernel"
    click IndexerCore "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/indexer/core"
    click DocProcessor "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/indexer/core/src/main/java/com/microsoft/openai/samples/indexer/DocumentProcessor.java"
    click PDFParser "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/indexer/core/src/main/java/com/microsoft/openai/samples/indexer/parser"
    click EmbeddingService "https://github.com/Azure-Samples/azure-search-openai-demo-java/tree/main/app/indexer/core/src/main/java/com/microsoft/openai/samples/indexer/embeddings"
    click AISearch "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/config/AzureAISearchConfiguration.java"
    click BlobStorage "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/proxy/BlobStorageProxy.java"
    click OpenAI "https://github.com/Azure-Samples/azure-search-openai-demo-java/blob/main/app/backend/src/main/java/com/microsoft/openai/samples/rag/proxy/OpenAIProxy.java"
```
