http:
  routers:
    iam-service-router:
      rule: "PathPrefix(`/api/v1/auth`)"
      service: iam-service
      priority: 100
      middlewares:
        - auth-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    iam-service-users-router:
      rule: "PathPrefix(`/api/v1/users`) || PathPrefix(`/api/v1/identity`) || PathPrefix(`/api/v1/access`) || PathPrefix(`/api/v1/governance`) || PathPrefix(`/api/v1/rbac`) || PathPrefix(`/api/v1/mfa`) || PathPrefix(`/api/v1/sessions`)"
      service: iam-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: IdentityServer OAuth2/OIDC Endpoints
    # VI: IdentityServer OAuth2/OIDC Endpoints
    iam-oidc-router:
      rule: "PathPrefix(`/connect`) || PathPrefix(`/.well-known`)"
      service: iam-service
      priority: 150
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    web-admin-router:
      rule: "Host(`admin.goodgo.vn`) || Host(`admin.localhost`)"
      service: web-admin
      middlewares:
        - cors
        - secure-headers
      entryPoints:
        - web

    web-client-router:
      rule: "Host(`goodgo.vn`) || Host(`localhost`)"
      service: web-client
      middlewares:
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Storage Service - File Management
    # VI: Storage Service - Quản lý File
    storage-service-router:
      rule: "PathPrefix(`/api/v1/files`) || PathPrefix(`/api/v1/quota`) || PathPrefix(`/api/v1/uploads`)"
      service: storage-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Membership Service - Member & Level Management
    # VI: Membership Service - Quản lý Member & Level
    membership-service-router:
      rule: "PathPrefix(`/api/v1/members`) || PathPrefix(`/api/v1/levels`)"
      service: membership-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Merchant Service - Merchant & Shop Management
    # VI: Merchant Service - Quản lý Merchant & Shop
    merchant-service-router:
      rule: "PathPrefix(`/api/v1/merchants`) || PathPrefix(`/api/v1/shops`) || PathPrefix(`/api/v1/subscriptions`)"
      service: merchant-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Order Service - Order Management & POS API
    # VI: Order Service - Quản lý Order & POS API
    order-service-router:
      rule: "PathPrefix(`/api/v1/orders`)"
      service: order-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Order Service - POS/KDS SignalR Hub (WebSocket)
    # VI: Order Service - POS/KDS SignalR Hub (WebSocket)
    order-service-hub-router:
      rule: "PathPrefix(`/hubs/pos`)"
      service: order-service
      priority: 110
      middlewares:
        - hub-ratelimit
        - cors
      entryPoints:
        - web

    # EN: FnB Engine - Kitchen, Sessions, Tables, Recipes, Reservations
    # VI: FnB Engine - Bếp, Phiên, Bàn, Công thức, Đặt bàn
    fnb-engine-router:
      rule: "PathPrefix(`/api/v1/kitchen`) || PathPrefix(`/api/v1/fnb`)"
      service: fnb-engine
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Inventory Service - Stock Management & Deduction
    # VI: Inventory Service - Quản lý Tồn kho & Trừ kho
    inventory-service-router:
      rule: "PathPrefix(`/api/v1/inventory`) || PathPrefix(`/api/v1/stock`)"
      service: inventory-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Wallet Service - Wallet & Payment Management
    # VI: Wallet Service - Quản lý Ví & Thanh toán
    wallet-service-router:
      rule: "PathPrefix(`/api/v1/wallets`) || PathPrefix(`/api/v1/payments`) || PathPrefix(`/api/v1/points`)"
      service: wallet-service
      priority: 100
      middlewares:
        - payment-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Catalog Service - Product & Category Management
    # VI: Catalog Service - Quản lý Sản phẩm & Danh mục
    catalog-service-router:
      rule: "PathPrefix(`/api/v1/products`) || PathPrefix(`/api/v1/categories`)"
      service: catalog-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Booking Service - Booking & Reservation Management
    # VI: Booking Service - Quản lý Đặt lịch & Đặt chỗ
    booking-service-router:
      rule: "PathPrefix(`/api/v1/bookings`) || PathPrefix(`/api/v1/reservations`) || PathPrefix(`/api/v1/therapists`) || PathPrefix(`/api/v1/appointments`)"
      service: booking-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Marketing Services — Facebook, WhatsApp, X (Twitter), Zalo integrations
    # VI: Marketing Services — Tich hop Facebook, WhatsApp, X (Twitter), Zalo
    mkt-facebook-router:
      rule: "PathPrefix(`/api/v1/mkt/facebook`)"
      service: mkt-facebook-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    mkt-whatsapp-router:
      rule: "PathPrefix(`/api/v1/mkt/whatsapp`)"
      service: mkt-whatsapp-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    mkt-x-router:
      rule: "PathPrefix(`/api/v1/mkt/x`)"
      service: mkt-x-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    mkt-zalo-router:
      rule: "PathPrefix(`/api/v1/mkt/zalo`)"
      service: mkt-zalo-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Chat Service - Messaging, Conversations & Keys
    # VI: Chat Service - Tin nhan, Cuoc tro chuyen & Khoa
    chat-service-router:
      rule: "PathPrefix(`/api/v1/chats`) || PathPrefix(`/api/v1/messages`) || PathPrefix(`/api/v1/conversations`)"
      service: chat-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Chat Service - SignalR WebSocket Hub
    # VI: Chat Service - SignalR WebSocket Hub
    chat-service-hub-router:
      rule: "PathPrefix(`/hubs/chat`)"
      service: chat-service
      priority: 110
      middlewares:
        - hub-ratelimit
        - cors
      entryPoints:
        - web

    # EN: Social Service - Social Feed, Blocks & Relationships
    # VI: Social Service - Mang xa hoi, Chan & Quan he
    social-service-router:
      rule: "PathPrefix(`/api/v1/social`) || PathPrefix(`/api/v1/blocks`) || PathPrefix(`/api/v1/relationships`)"
      service: social-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Mining Service - Data Mining, Circles & Referrals
    # VI: Mining Service - Khai thac du lieu, Vong ket noi & Gioi thieu
    mining-service-router:
      rule: "PathPrefix(`/api/v1/mining`) || PathPrefix(`/api/v1/circles`) || PathPrefix(`/api/v1/referrals`)"
      service: mining-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Mission Service - Gamification Missions & Check-ins
    # VI: Mission Service - Nhiem vu game hoa & Diem danh
    mission-service-router:
      rule: "PathPrefix(`/api/v1/missions`) || PathPrefix(`/api/v1/checkins`)"
      service: mission-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Promotion Service - Promotions & Vouchers
    # VI: Promotion Service - Khuyen mai & Voucher
    promotion-service-router:
      rule: "PathPrefix(`/api/v1/promotions`) || PathPrefix(`/api/v1/vouchers`)"
      service: promotion-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Ads Manager Service - Campaign & Ad Set Management
    # VI: Ads Manager Service - Quan ly Chien dich & Nhom quang cao
    ads-manager-service-router:
      rule: "PathPrefix(`/api/v1/ads`) || PathPrefix(`/api/v1/campaigns`) || PathPrefix(`/api/v1/adsets`) || PathPrefix(`/api/v1/audiences`)"
      service: ads-manager-service
      priority: 90
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Ads Serving Service - Ad Delivery & Auction
    # VI: Ads Serving Service - Phan phoi quang cao & Dau gia
    ads-serving-service-router:
      rule: "PathPrefix(`/api/v1/ads-serving`)"
      service: ads-serving-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Ads Billing Service - Ad Billing Accounts & Invoices
    # VI: Ads Billing Service - Tai khoan thanh toan & Hoa don quang cao
    ads-billing-service-router:
      rule: "PathPrefix(`/api/v1/ads-billing`) || PathPrefix(`/api/v1/ad-invoices`) || PathPrefix(`/api/v1/credit-lines`)"
      service: ads-billing-service
      priority: 100
      middlewares:
        - payment-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Ads Tracking Service - Conversion Events, Pixels & Tracking
    # VI: Ads Tracking Service - Su kien chuyen doi, Pixel & Theo doi
    ads-tracking-service-router:
      rule: "PathPrefix(`/api/v1/ad-events`) || PathPrefix(`/api/v1/pixels`) || PathPrefix(`/api/v1/conversions`)"
      service: ads-tracking-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

    # EN: Ads Analytics Service - Insights, Metrics & Reports
    # VI: Ads Analytics Service - Phan tich, Chi so & Bao cao quang cao
    ads-analytics-service-router:
      rule: "PathPrefix(`/api/v1/ad-analytics`) || PathPrefix(`/api/v1/ad-insights`) || PathPrefix(`/api/v1/ad-reports`)"
      service: ads-analytics-service
      priority: 100
      middlewares:
        - api-ratelimit
        - cors
        - secure-headers
      entryPoints:
        - web

  services:
    iam-service:
      loadBalancer:
        servers:
          - url: "http://iam-service-net:8080"
    
    web-admin:
      loadBalancer:
        servers:
          - url: "http://web-admin:3000"
    
    web-client:
      loadBalancer:
        servers:
          - url: "http://web-client:3001"

    # EN: Storage Service
    # VI: Storage Service  
    storage-service:
      loadBalancer:
        servers:
          - url: "http://storage-service:8080"

    # EN: Membership Service
    # VI: Membership Service
    membership-service:
      loadBalancer:
        servers:
          - url: "http://membership-service-net:8080"

    # EN: Merchant Service
    # VI: Merchant Service
    merchant-service:
      loadBalancer:
        servers:
          - url: "http://merchant-service-net:8080"

    # EN: Order Service (POS/KDS hub + REST API)
    # VI: Order Service (POS/KDS hub + REST API)
    order-service:
      loadBalancer:
        servers:
          - url: "http://order-service-net:8080"

    # EN: FnB Engine
    # VI: FnB Engine
    fnb-engine:
      loadBalancer:
        servers:
          - url: "http://fnb-engine-net:8080"

    # EN: Inventory Service
    # VI: Inventory Service
    inventory-service:
      loadBalancer:
        servers:
          - url: "http://inventory-service-net:8080"

    # EN: Wallet Service
    # VI: Wallet Service
    wallet-service:
      loadBalancer:
        servers:
          - url: "http://wallet-service-net:8080"

    # EN: Catalog Service
    # VI: Catalog Service
    catalog-service:
      loadBalancer:
        servers:
          - url: "http://catalog-service-net:8080"

    # EN: Booking Service
    # VI: Booking Service
    booking-service:
      loadBalancer:
        servers:
          - url: "http://booking-service-net:8080"

    # EN: Marketing Services — Social Media Integrations
    # VI: Marketing Services — Tich hop mang xa hoi
    mkt-facebook-service:
      loadBalancer:
        servers:
          - url: "http://mkt-facebook-service-net:8080"

    mkt-whatsapp-service:
      loadBalancer:
        servers:
          - url: "http://mkt-whatsapp-service-net:8080"

    mkt-x-service:
      loadBalancer:
        servers:
          - url: "http://mkt-x-service-net:8080"

    mkt-zalo-service:
      loadBalancer:
        servers:
          - url: "http://mkt-zalo-service-net:8080"

    # EN: Chat Service
    # VI: Chat Service
    chat-service:
      loadBalancer:
        servers:
          - url: "http://chat-service-net:8080"

    # EN: Social Service
    # VI: Social Service
    social-service:
      loadBalancer:
        servers:
          - url: "http://social-service-net:8080"

    # EN: Mining Service
    # VI: Mining Service
    mining-service:
      loadBalancer:
        servers:
          - url: "http://mining-service-net:8080"

    # EN: Mission Service
    # VI: Mission Service
    mission-service:
      loadBalancer:
        servers:
          - url: "http://mission-service-net:8080"

    # EN: Promotion Service
    # VI: Promotion Service
    promotion-service:
      loadBalancer:
        servers:
          - url: "http://promotion-service-net:8080"

    # EN: Ads Manager Service
    # VI: Ads Manager Service
    ads-manager-service:
      loadBalancer:
        servers:
          - url: "http://ads-manager-service-net:8080"

    # EN: Ads Serving Service
    # VI: Ads Serving Service
    ads-serving-service:
      loadBalancer:
        servers:
          - url: "http://ads-serving-service-net:8080"

    # EN: Ads Billing Service
    # VI: Ads Billing Service
    ads-billing-service:
      loadBalancer:
        servers:
          - url: "http://ads-billing-service-net:8080"

    # EN: Ads Tracking Service
    # VI: Ads Tracking Service
    ads-tracking-service:
      loadBalancer:
        servers:
          - url: "http://ads-tracking-service-net:8080"

    # EN: Ads Analytics Service
    # VI: Ads Analytics Service
    ads-analytics-service:
      loadBalancer:
        servers:
          - url: "http://ads-analytics-service-net:8080"