@startuml
title live-wind collection
!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/master/C4_Component.puml

ContainerDb(liveWindDb, "S3 bucket", "S3 bucket which will contain the raw live wind data collect for a stations")
System(weatherLinkApi, "WeatherLink API", "Returns list of stations roughly 600")
System(liveWindSqs, "SQS", "Queue which triggers live-wind lambda")
System(eventBridge, "EventBridge", "trigger an event every 1 min from event bridge into SQS")


Container_Boundary(liveWindLambda, "Live wind lambda") {
    Component(getStationList, "Generate batches", "Get request to retrieve list of stations and build batches of x number of stations")
    Container_Boundary(batchGroup, "Per station batch (x30)") {
        Component(batch, "Trigger request batch", "Schedule batch of station requests at least 1 second apart to make sure we don't hit our throttle limits on weatherlink api. Combine the results into a file and save it to live wind S3 bucket. If a request fails push it into an array of failed stations and put a message into SQS")
        Container_Boundary(stationGroup, "Per station request (x20)") {
            Component(request, "Request per station", "Make request to weatherlink for each station ID.")
        }
    }
}

eventBridge -right-> liveWindSqs
liveWindSqs -right-> liveWindLambda
getStationList -right-> weatherLinkApi
getStationList -down-> batch

batch -right-> liveWindSqs
batch --> request
request --> weatherLinkApi
batch --> liveWindDb


@enduml