# azure-samples/miyagi architecture

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

- Interactive diagram: https://gitdiagram.com/azure-samples/miyagi
- Repository: https://github.com/azure-samples/miyagi

## Overview

##### Main Components

a. Frontend Layer:
- React/TypeScript UI application (ui/typescript)
- VSCode extension for GitHub Copilot Agent
- Components for chat, personalization, and financial insights

b. Backend Services:
- User Service (Java)
- Order Service
- Expense Service (Python)
- Recommendation Service (.NET)
- SK Copilot Chat API (.NET)
- ChatGPT Plugin Service

c. AI/ML Components:
- Azure OpenAI integration
- Semantic Kernel orchestration
- Vector stores (Azure AI Search, Cosmos DB Postgres pgvector)
- LangChain and LlamaIndex implementations
- AutoGen and TaskWeaver components

d. Infrastructure:
- Azure Kubernetes Service (AKS)
- Azure Container Apps (ACA)
- Event-driven architecture components (Service Bus, Event Grid)
- Storage solutions (Cosmos DB, PostgreSQL, Redis Cache)

##### Relationship Flows

- User interactions flowing from UI to backend services
- Event flows between microservices
- Data flows to/from AI services
- Memory and context management paths
- Authentication and authorization flows

##### Architectural Patterns to Highlight

a. Event-Driven Architecture:
- Event bus connections between services
- Asynchronous communication patterns

b. AI Integration Patterns:
- Demonstrate RAG (Retrieval-Augmented Generation) flow
- Prompt engineering pipeline
- Vector store integration

c. Microservices Architecture:
- Service boundaries and communication
- API gateway pattern
- Service mesh if applicable

**[Azure Infrastructure]**
- AKS/ACA Cluster
- Network Security
- Monitoring & Logging

**[Storage Solutions]**
- Cosmos DB
- PostgreSQL
- Redis Cache
- Vector Stores

**[Microservices]**
- User Service
- Order Service
- Expense Service
- Recommendation Service

**[AI Components]**
- Azure OpenAI
- Semantic Kernel
- Vector Embeddings
- Custom Models

##### Implementation Notes

- Maintain consistent sizing and spacing
- Version/environment indicators
- Deployment pipeline indicators
- Integration with DevOps tools

Remember to include a separate view for the AI orchestration flow, showing how Semantic Kernel, LangChain, and other AI components interact within the system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI["React/TypeScript UI"]
        Chat["Chat Components"]
        Person["Personalization UI"]
        VSCode["VSCode Extension"]
    end

    subgraph Backend
        UserSvc["User Service (Java)"]
        OrderSvc["Order Service (.NET)"]
        ExpenseSvc["Expense Service (Python)"]
        RecSvc["Recommendation Service (.NET)"]
        SKChat["SK Copilot Chat API"]
        Plugin["ChatGPT Plugin Service"]
    end

    subgraph AI_ML["AI/ML Layer"]
        AzureAI["Azure OpenAI"]
        SK["Semantic Kernel"]
        Vector["Vector Stores"]
        LC["LangChain"]
        AG["AutoGen"]
        TW["TaskWeaver"]
    end

    subgraph Infrastructure
        AKS["Azure Kubernetes"]
        ACA["Azure Container Apps"]
        SB["Service Bus"]
        EG["Event Grid"]
    end

    subgraph Storage
        Cosmos["Cosmos DB"]
        Postgres["PostgreSQL"]
        Redis["Redis Cache"]
    end

    UI --> |API Requests| Backend
    Chat --> |Real-time| SKChat
    Person --> |Preferences| UserSvc
    VSCode --> |Code Analysis| Plugin

    UserSvc --> |Events| SB
    OrderSvc --> |Events| SB
    ExpenseSvc --> |Events| SB
    RecSvc --> |Events| SB

    Backend --> |AI Requests| AI_ML
    AI_ML --> |Vector Search| Storage
    SK --> AzureAI
    Vector --> Postgres
    Vector --> Cosmos

    Infrastructure --> Backend
    SB --> EG
    EG --> Backend

    %% Click Events
    click UI "https://github.com/Azure-Samples/miyagi/tree/main/ui/typescript/"
    click Chat "https://github.com/Azure-Samples/miyagi/tree/main/ui/typescript/src/components/chat/"
    click Person "https://github.com/Azure-Samples/miyagi/tree/main/ui/typescript/src/components/personalize/"
    click VSCode "https://github.com/Azure-Samples/miyagi/tree/main/sandbox/usecases/code-modernization/vscode-gh-copilot-extension/"
    click UserSvc "https://github.com/Azure-Samples/miyagi/tree/main/services/user-service/java/"
    click OrderSvc "https://github.com/Azure-Samples/miyagi/tree/main/services/order-service/dotnet/"
    click ExpenseSvc "https://github.com/Azure-Samples/miyagi/tree/main/services/expense-service/python/"
    click RecSvc "https://github.com/Azure-Samples/miyagi/tree/main/services/recommendation-service/dotnet/"
    click SKChat "https://github.com/Azure-Samples/miyagi/tree/main/services/sk-copilot-chat-api/dotnet/"
    click AzureAI "https://github.com/Azure-Samples/miyagi/tree/main/agents/assistants-api/azure-openai/"
    click SK "https://github.com/Azure-Samples/miyagi/tree/main/sandbox/experiments/semantic-kernel/"
    click LC "https://github.com/Azure-Samples/miyagi/tree/main/sandbox/experiments/langchain/"
    click AG "https://github.com/Azure-Samples/miyagi/tree/main/agents/autogen/"
    click Vector "https://github.com/Azure-Samples/miyagi/tree/main/sandbox/experiments/qdrant-embeddings/"
    click AKS "https://github.com/Azure-Samples/miyagi/tree/main/deploy/infrastructure/kubernetes/"
    click Cosmos "https://github.com/Azure-Samples/miyagi/blob/main/deploy/infrastructure/terraform/module_cosmosdb.tf"
    click Redis "https://github.com/Azure-Samples/miyagi/blob/main/deploy/infrastructure/terraform/module_redis_cache.tf"
    click Postgres "https://github.com/Azure-Samples/miyagi/blob/main/deploy/infrastructure/terraform/module_postgres.tf"

    classDef frontend fill:#2196F3,stroke:#fff,stroke-width:2px,color:#fff
    classDef backend fill:#4CAF50,stroke:#fff,stroke-width:2px,color:#fff
    classDef ai fill:#9C27B0,stroke:#fff,stroke-width:2px,color:#fff
    classDef infra fill:#FF9800,stroke:#fff,stroke-width:2px,color:#fff
    classDef storage fill:#795548,stroke:#fff,stroke-width:2px,color:#fff

    class UI,Chat,Person,VSCode frontend
    class UserSvc,OrderSvc,ExpenseSvc,RecSvc,SKChat,Plugin backend
    class AzureAI,SK,Vector,LC,AG,TW ai
    class AKS,ACA,SB,EG infra
    class Cosmos,Postgres,Redis storage
```
