@startuml Surfline Frontend Container Redesign 2022
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml

title Surfline Frontend Container - Redesign 2022

Person(customerSl, "Surfline Customer", "Surfline customers.")

System_Boundary(cloudflare, 'Cloudflare Edge') {
  System_Boundary(routingSystem, 'Routing System') {
    System_Ext(dns, "DNS", "Cloudflare DNS.")
    System_Ext(waf, "WAF", "Cloudflare WAF used.")
    System_Ext(pagerules, "PageRules", "Cloudflare Pagerules handle HTTP->HTTPS redirects.")
    System_Ext(webProxyWorker, "Web Proxy Worker", "Worker replicates web proxy function.")
  }
}

Container_Ext(ecomm, "Ecommerce", "Shopify store.")

System_Boundary(ecs, 'ECS Cluster') {
  Container(content, "Content", "Homepage, travel and editorial.")
  Container(kbyg, "KBYG", "KBYG + Charts + Wave buoys + sessions clip.")
  Container(user, "User App", "User Auth + Subscription Management + Settings + Onboarding.")

  System(services, "Services System", "Internal services APIs.")
}

System_Boundary(packages, 'Core Packages') {
  Container(margins, "Margins NPM Package", "Header/footer only NPM package.")
  Container(auth, "Auth NPM Package", "Functions for token and entitlement management.")
  Container(theme, "Material UI Theme", "Material UI theme.")
  Container_Ext(materialui, "Material UI", "Material UI package.")
}

Rel_D(customerSl, dns, "HTTPS", "1.i Returns itself.")
Rel_R(dns, waf, "HTTPS", "1.ii WAF rules executed and DDoS protection.")
Rel_R(waf, pagerules, "HTTPS", "1.iii No page rules will get hit.")
Rel_R(pagerules, webProxyWorker, "HTTP", "1.iv Proxy worker implements custom redirects and fetches from upstream.")

Rel_D(webProxyWorker, ecs, "HTTP", "HTTP request from upstream.")
Rel_D(dns, ecomm, "HTTPS", "https://store.surfline.com/")

Rel(kbyg, services, "HTTP(S)", "Services requests.")
Rel(content, services, "HTTP(S)", "Services requests.")
Rel(ecomm, services, "HTTP(S)", "Services requests.")
Rel(user, services, "HTTP(S)", "Services requests.")

Rel_D(kbyg, packages, "NPM Package", "Package include.")
Rel_D(content, packages, "NPM Package", "Package include.")
Rel_D(user, packages, "NPM Package", "Package include.")

Rel_D(theme, materialui, "NPM Package", "Package include.")

SHOW_DYNAMIC_LEGEND()

@enduml
