# Deployment views


Deployment views allow you to visualize the deployment model, using same approach as [model views](/dsl/views/predicates) — predicates.

## View definition

```likec4 {17-23}
deployment {
  environment prod {
    zone eu {
      zone zone1 {
        instanceOf frontend.ui
        instanceOf backend.api
      }
      zone zone2 {
        instanceOf frontend.ui
        instanceOf backend.api
      }
      instanceOf database
    }    
  }
}
views {
  deployment view index {
    title 'Production Deployment'
    link https://likec4.dev

    include prod.**
    // ...
  }
}
```

## View predicates

Deployment views are based on same [predicates](/dsl/views/predicates) as model views.  
But they refer to deployment nodes and instances.

<Aside type='caution' title='In development'>
  The following features are not supported yet or do not work as expected:
 
  - `with` expressions
  - Shared styles and predicates
  - Relationships browser, Element and Relationship Details popups (work with logical model)

  ```likec4
  deployment view prod {
    include *                                   // works
    include * where tag is #next                // works (see details below)
    include * with { color: red }               // does not work

    include * -> *                              // works
    include * -> * where tag is #next           // works
    include * -> * where source.tag is #next    // works (see details below)
    include * -> * with { color: red }          // does not work

    global style applications                   // does not work    
  }
  ```
</Aside>

### Filtering
Filtering in deployment views use the same principles as in normal views but takes into account deployment nodes, relations and tags defined in deployment model.
When condition on element is checked the following rules are applied:
- For a deployment instances tags are combined from tags defined in model and tags defined in deployment model
- For a child of deployment instance the tags defined on child in model are used
- For a deployment node the tags defined in deployment model are used
- For a deployment instances the kind of the model element is used
- For a child of deployment instance the kind of this child is used
- For a deployment node the kind of this deployment node is used
- Tags are not inherited from parent nodes/elements

```likec4
model {
  element cloud {
    element frontend {
      #next
      -> backend "rel1"
    }
    element backend {
      #next
      -> db "rel2"
    }
    element db
  }
}
deployment {
  environment prod { // Resulting tags: #alpha
    #alpha
    zone eu { // Resulting tags: #beta
      #beta
      instanceOf frontend { // Resulting tags: #next, #gamma
          #gamma
      }
      instanceOf backend { // Resulting tags: #next, #sigma
          #sigma
      }
      eu -> prod.db "rel3"
    }
    instanceOf db { // Resulting tags: #delta
      #delta
    }
  }
}
views {
  deployment view some {
    include prod.eu.frontend -> prod.eu.backend
      where source.tag is #next // includes relation "rel1"
    include prod.eu.frontend -> prod.eu.backend
      where source.tag is #gamma // includes relation "rel1"
    include prod.eu -> prod.db
      where source.tag is #beta // includes relation "rel3"
    include prod.eu -> prod.db
      where source.tag is #sigma // does not include any relations
    include eu.* -> prod.db
      where source.tag is #sigma // includes relations "rel2"
  }
}
```

<br/>
<br/>
  <LinkCard
    title="Try it online"
    description="Open deployment example in LikeC4 playground"
    href="https://playground.likec4.dev/w/deployment/index/"
    target="_blank"
  />