I'm getting a syntax error in combination of class and package description

0 votes
asked May 23, 2023 in Question / help by Li
Hi I have the following but I'm getting a syntax error but can't tell why - complaint is about line 20 but when I break it down each part works fine on its own. Any insight is appreciated. I'm very new to this ....

@startuml

package "Web Server Application" {
    [Web Server]
    [Database]
    [Client Browser]
    [Load Balancer]

    [Web Server] --> [Database] : Read/Write Data
    [Web Server] --> [Client Browser] : Serve Web Pages
    [Client Browser] --> [Web Server] : Send HTTP Requests
    [Client Browser] --> [Load Balancer] : Send HTTP Requests
    [Load Balancer] --> [Web Server] : Distribute Requests
}

package "Python Code" {
    [Web Server] --> [Python Code] : Handle HTTP Requests
    [Python Code] --> [Database] : Query Database
    [Python Code] --> [Client Browser] : Send HTTP Responses
    
    class PythonCode {
        +handle_request(request: HttpRequest) : HttpResponse
    }

    class HttpRequest {
        +method : str
        +path : str
        +headers : dict
        +body : str
    }

    class HttpResponse {
        +status_code : int
        +headers : dict
        +body : str
    }

    class Database {
        +query(sql: str) : Result
    }

    class Result {
        +rows : list
    }
}

@enduml
commented May 24, 2023 by Li
Thank you for the response - I'm just starting to learn -

I wanted to show both the high level communications interfaces/components and the functions/objects  together - just as a way of documenting.
commented Jun 13, 2023 by kirchsth (4,960 points)

A possible documentation approach could be the https://c4model.com/
It offers different views and with C4-PlantUML you have a implementation which is integrated in PlantUML as C4 Standard Library too.

BR Helmut

1 Answer

0 votes
answered May 23, 2023 by The-Lu (64,340 points)

Hi Li., and all,

  • What are your goals?
    You can not directly mix component and class....

If you want to mix `component diagram` with `class diagram`, for that use dummy label and sub-diagram like:

@startuml

package "Web Server Application" {
    [Web Server]
    [Database]
    [Client Browser]
    [Load Balancer]

    [Web Server] --> [Database] : Read/Write Data
    [Web Server] --> [Client Browser] : Serve Web Pages
    [Client Browser] --> [Web Server] : Send HTTP Requests
    [Client Browser] --> [Load Balancer] : Send HTTP Requests
    [Load Balancer] --> [Web Server] : Distribute Requests
}

package "Python Code" {
    [Web Server] --> [Python Code] : Handle HTTP Requests
    [Python Code] --> [Database] : Query Database
    [Python Code] --> [Client Browser] : Send HTTP Responses
    
    label l [{{
    class "PythonCode" {
        +handle_request(request: HttpRequest) : HttpResponse
    }

    class HttpRequest {
        +method : str
        +path : str
        +headers : dict
        +body : str
    }

    class HttpResponse {
        +status_code : int
        +headers : dict
        +body : str
    }

    class Database {
        +query(sql: str) : Result
    }

    class Result {
        +rows : list
    }
    }}]
}

@enduml

Regards.
Th.

...