@startuml
!include https://raw.githubusercontent.com/adrianvlupu/C4-PlantUML/latest/C4_Component.puml

LAYOUT_WITH_LEGEND()

Container(spa, "Single Page Application", "javascript and Angular", "Provides all the Mizu-do System functionality to customers via their web browser.")
Container(ma, "Mobile App", "PWA", "Provides all the Mizu-do System to customers via their mobile device.")
Container(db, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.")

Container_Boundary(api, "API Application") {
    Component(tokenResource, "TokenResource", "JAX-RS Resource", "Allows users to authenticate in to the Mizu-do system providing a JWT token")
    Component(securityService, "SecurityService", "CDI Bean", "Provides functionality related to singing in, changing passwords, etc.")
    Component(JwtTokenService, "JwtTokenService", "CDI Bean", "Generates JWT tokens")
    Component(passwordService, "PasswordService", "CDI Bean", "Generates the password hashing.")

    Component(profileResource, "ProfileResource", "JAX-RS Resource", "Allows users to manage their profile data")
    
    Rel(tokenResource, securityService, "Uses")
    Rel(securityService, db, "Read & write to", "JPA/JDBC")
    Rel(securityService, JwtTokenService, "Read & write to", "JPA/JDBC")
    Rel(securityService, passwordService, "Read & write to", "JPA/JDBC")
}

Rel(spa, tokenResource, "Uses", "JSON/HTTPS")
Rel(ma, tokenResource, "Uses", "JSON/HTTPS")

Rel(spa, profileResource, "Uses", "JSON/HTTPS")
Rel(ma, profileResource, "Uses", "JSON/HTTPS")

@enduml
