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IAtesNk6nX8bdWKg2Qxv8zlRqN8gh0weIXYWZMTR_yKNPS60HGSGAY82ShmLRa0IaWTyOAP3WAz4dPGEZca1ER7TULWCGwwu63vGlL1-hbTemAd6hYgBv3ZxOzr0NKTBncfpOUZnAu2N8gXjZip9F9cmb5MKvqmlLuAPzE9PPyTw0VrBcXwHZqGOsi3h8-xgfgFVtq5-vJo8uXO2VW8TW7enc3J3lGUDo_ZSwOmz1hIO_Yoov_4DW0srjw

graph TB
    subgraph Clients
        Web["Web"]
        iOS["iOS"]
        Android["Android"]
        CMS["CMS Frontend"]
        SPecialist["Specialist Dashboard"]
    end

    FirebaseAnalytics["Firebase Analytics"]
    FirebaseAuth["Firebase Auth"]

    subgraph APIGateway["API L7 R-Proxy API Gateway"]
        TLS["TLS termination"]
        Caching["Caching"]
        Routing["Routing"]
        Auth["Auth"]
        LB["LB"]
    end

    subgraph Microservices
        Auth["Authentication"]
        Users["Users"]
        Graphs["Graphs"]
        Inventory["Inventory"]
        Messages["Messages"]
        Orders["Orders"]
        AI["AI Inference"]
        CMS["CMS"]
        Fulfillment["Fulfillment"]
        EHR["EHR"]
        Chat["Chat"]
        CMSB["CMS Backend"]
    end

    subgraph EventBus["Event Bus (Kafka)"]
        AuthEventTopic["Auth_event_topic"]
        UsersEventTopic["Users_event_topic"]
        GraphsEventTopic["Graphs_event_topic"]
        InventoryEventTopic["Inventory_event_topic"]
        MessagesEventTopic["Messages_event_topic"]
        OrdersEventTopic["Orders_event_topic"]
        AIEventTopic["AI_event_topic"]
        CMSEventTopic["CMS_event_topic"]
        FulfillmentEventTopic["Fulfillment_event_topic"]
        EHREventTopic["EHR_event_topic"]
        ChatEventTopic["Chat_event_topic"]
        CMSBEventTopic["CMS_Backend_event_topic"]
    end

    BigQuery["Big Query"]
    AnalyticsDashboard["Analytics Dashboard"]

    subgraph DataPipeline["Data Pipeline"]
        CDC["Change Data Capture"]
        Queue["Queue"]
        StreamIngestion["Stream Ingestion"]
        VectorDB["Vector DB"]
    end

    subgraph TrainingPipeline["Training Pipeline"]
        QdrantRetrievalClients["Qdrant Retrieval Clients"]
        DataToPromptLayer["Data to Prompt Layer"]
        LLMFineTuning["LLM Fine-tuning"]
        ModelRegistry["Model Registry (Comet)"]
    end

    Clients --> APIGateway
    Clients --> FirebaseAnalytics
    Clients --> FirebaseAuth
    APIGateway --> Microservices
    Microservices <--> EventBus
    EventBus --> BigQuery
    BigQuery --> AnalyticsDashboard

    CMSB --> CDC
    CDC --> Queue
    Queue --> StreamIngestion
    StreamIngestion --> VectorDB
    VectorDB --> TrainingPipeline

    QdrantRetrievalClients --> DataToPromptLayer
    DataToPromptLayer --> LLMFineTuning
    LLMFineTuning --> ModelRegistry

    %% Databases and Redis for microservices
    Users -.- UsersDB[(DB)]
    Users -.- UsersRedis((Redis))
    Graphs -.- GraphsDB[(DB)]
    Inventory -.- InventoryDB[(DB)]
    Inventory -.- InventoryRedis((Redis))
    Messages -.- MessagesDB[(DB)]
    Messages -.- MessagesRedis((Redis))
    Orders -.- OrdersDB[(DB)]
    Orders -.- OrdersRedis((Redis))
    AI -.- AIDB[(DB)]
    AI -.- AIRedis((Redis))
    CMSB -.- CMSDB[(DB)]
    CMSB -.- CMSRedis((Redis))
    Fulfillment -.- FulfillmentDB[(DB)]
    Fulfillment -.- FulfillmentRedis[(Redis)]
    EHR -.- EHRDB[(DB)]
    EHR -.- EHRRedis((Redis))
    Chat -.- ChatDB[(DB)]
    Chat -.- ChatRedis((Redis))

Components

  1. Client-Side Applications
  2. Firebase Services
  3. API Gateway (Envoy)
  4. Microservices
  5. Data Storage
  6. Event Bus (Kafka)
  7. Big Query
  8. Analytics Dashboard
  9. Data Pipeline
  10. Training Pipeline

High Level Data Flow

  1. Client applications interact with the system through the API Gateway.
  2. The API Gateway routes requests to appropriate microservices.
  3. Microservices process requests, interact with their respective databases and Redis instances, and communicate with each other through the Event Bus.
  4. Firebase services handle basic analytics and authentication.