Skip to content

Modern Docker Management, Designed for Everyone

feat: network ports and typology views (#2180)

Kyle Mendella0c9b016346f
diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go
index 0cff77fae..2c2f2bc43 100644
--- a/backend/internal/bootstrap/router_bootstrap.go
+++ b/backend/internal/bootstrap/router_bootstrap.go
@@ -145,6 +145,7 @@ func setupRouter(ctx context.Context, cfg *config.Config, appServices *Services)
Volume: appServices.Volume,
Container: appServices.Container,
Network: appServices.Network,
+ Port: appServices.Port,
Swarm: appServices.Swarm,
Notification: appServices.Notification,
Apprise: appServices.Apprise,
diff --git a/backend/internal/bootstrap/services_bootstrap.go b/backend/internal/bootstrap/services_bootstrap.go
index 732d090d7..ea6d45eb6 100644
--- a/backend/internal/bootstrap/services_bootstrap.go
+++ b/backend/internal/bootstrap/services_bootstrap.go
@@ -27,6 +27,7 @@ type Services struct {
BuildWorkspace *services.BuildWorkspaceService
Volume *services.VolumeService
Network *services.NetworkService
+ Port *services.PortService
Swarm *services.SwarmService
ImageUpdate *services.ImageUpdateService
Auth *services.AuthService
@@ -84,6 +85,7 @@ func initializeServices(ctx context.Context, db *database.DB, cfg *config.Config
svcs.Dashboard = services.NewDashboardService(db, svcs.Docker, svcs.Container, svcs.Settings, svcs.Vulnerability)
svcs.Volume = services.NewVolumeService(db, svcs.Docker, svcs.Event, svcs.Settings, svcs.Container, svcs.Image, cfg.BackupVolumeName)
svcs.Network = services.NewNetworkService(db, svcs.Docker, svcs.Event)
+ svcs.Port = services.NewPortService(svcs.Docker)
svcs.Swarm = services.NewSwarmService(svcs.Docker, svcs.Settings, svcs.KV, svcs.ContainerRegistry, svcs.Environment)
svcs.Template = services.NewTemplateService(ctx, db, httpClient, svcs.Settings)
svcs.Auth = services.NewAuthService(svcs.User, svcs.Settings, svcs.Event, cfg.JWTSecret, cfg)
diff --git a/backend/internal/huma/handlers/networks.go b/backend/internal/huma/handlers/networks.go
index ae0e72217..609b279fd 100644
--- a/backend/internal/huma/handlers/networks.go
+++ b/backend/internal/huma/handlers/networks.go
@@ -89,6 +89,19 @@ type GetNetworkOutput struct {
Body NetworkInspectApiResponse
}
+type NetworkTopologyApiResponse struct {
+ Success bool `json:"success"`
+ Data networktypes.Topology `json:"data"`
+}
+
+type GetNetworkTopologyInput struct {
+ EnvironmentID string `path:"id" doc:"Environment ID"`
+}
+
+type GetNetworkTopologyOutput struct {
+ Body NetworkTopologyApiResponse
+}
+
// NetworkMessageApiResponse is a dedicated response type
type NetworkMessageApiResponse struct {
Success bool `json:"success"`
@@ -152,6 +165,15 @@ func RegisterNetworks(api huma.API, networkSvc *services.NetworkService, dockerS
Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},
}, h.CreateNetwork)
+ huma.Register(api, huma.Operation{
+ OperationID: "get-network-topology",
+ Method: http.MethodGet,
+ Path: "/environments/{id}/networks/topology",
+ Summary: "Get network topology",
+ Tags: []string{"Networks"},
+ Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},
+ }, h.GetNetworkTopology)
+
huma.Register(api, huma.Operation{
OperationID: "get-network",
Method: http.MethodGet,
@@ -355,6 +377,20 @@ func (h *NetworkHandler) GetNetwork(ctx context.Context, input *GetNetworkInput)
}, nil
}
+func (h *NetworkHandler) GetNetworkTopology(ctx context.Context, input *GetNetworkTopologyInput) (*GetNetworkTopologyOutput, error) {
+ topology, err := h.networkService.GetNetworkTopology(ctx)
+ if err != nil {
+ return nil, huma.Error500InternalServerError("failed to build network topology")
+ }
+
+ return &GetNetworkTopologyOutput{
+ Body: NetworkTopologyApiResponse{
+ Success: true,
+ Data: *topology,
+ },
+ }, nil
+}
+
func (h *NetworkHandler) DeleteNetwork(ctx context.Context, input *DeleteNetworkInput) (*DeleteNetworkOutput, error) {
user, exists := humamw.GetCurrentUserFromContext(ctx)
if !exists {
diff --git a/backend/internal/huma/handlers/ports.go b/backend/internal/huma/handlers/ports.go
new file mode 100644
index 000000000..99894bae9
--- /dev/null
+++ b/backend/internal/huma/handlers/ports.go
@@ -0,0 +1,88 @@
+package handlers
+
+import (
+ "context"
+ "net/http"
+ "strings"
+
+ "github.com/danielgtaylor/huma/v2"
+ "github.com/getarcaneapp/arcane/backend/internal/services"
+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"
+ "github.com/getarcaneapp/arcane/types/base"
+ porttypes "github.com/getarcaneapp/arcane/types/port"
+)
+
+type PortHandler struct {
+ portService *services.PortService
+}
+
+type PortPaginatedResponse struct {
+ Success bool `json:"success"`
+ Data []porttypes.PortMapping `json:"data"`
+ Pagination base.PaginationResponse `json:"pagination"`
+}
+
+type ListPortsInput struct {
+ EnvironmentID string `path:"id" doc:"Environment ID"`
+ Search string `query:"search" doc:"Search query"`
+ Sort string `query:"sort" doc:"Column to sort by"`
+ Order string `query:"order" default:"asc" doc:"Sort direction (asc or desc)"`
+ Start int `query:"start" default:"0" doc:"Start index for pagination"`
+ Limit int `query:"limit" default:"20" doc:"Number of items per page"`
+}
+
+type ListPortsOutput struct {
+ Body PortPaginatedResponse
+}
+
+func RegisterPorts(api huma.API, portSvc *services.PortService) {
+ h := &PortHandler{portService: portSvc}
+
+ huma.Register(api, huma.Operation{
+ OperationID: "list-ports",
+ Method: http.MethodGet,
+ Path: "/environments/{id}/ports",
+ Summary: "List port mappings",
+ Tags: []string{"Ports"},
+ Security: []map[string][]string{{"BearerAuth": {}}, {"ApiKeyAuth": {}}},
+ }, h.ListPorts)
+}
+
+func (h *PortHandler) ListPorts(ctx context.Context, input *ListPortsInput) (*ListPortsOutput, error) {
+ if h.portService == nil {
+ return nil, huma.Error500InternalServerError("service not available")
+ }
+
+ params := pagination.QueryParams{
+ SearchQuery: pagination.SearchQuery{
+ Search: strings.TrimSpace(input.Search),
+ },
+ SortParams: pagination.SortParams{
+ Sort: strings.TrimSpace(input.Sort),
+ Order: pagination.SortOrder(input.Order),
+ },
+ PaginationParams: pagination.PaginationParams{
+ Start: input.Start,
+ Limit: input.Limit,
+ },
+ }
+
+ items, paginationResp, err := h.portService.ListPortsPaginated(ctx, params)
+ if err != nil {
+ return nil, huma.Error500InternalServerError("failed to list ports")
+ }
+
+ return &ListPortsOutput{
+ Body: PortPaginatedResponse{
+ Success: true,
+ Data: items,
+ Pagination: base.PaginationResponse{
+ TotalPages: paginationResp.TotalPages,
+ TotalItems: paginationResp.TotalItems,
+ CurrentPage: paginationResp.CurrentPage,
+ ItemsPerPage: paginationResp.ItemsPerPage,
+ GrandTotalItems: paginationResp.GrandTotalItems,
+ },
+ },
+ }, nil
+}
diff --git a/backend/internal/huma/huma.go b/backend/internal/huma/huma.go
index db156f220..8f613e658 100644
--- a/backend/internal/huma/huma.go
+++ b/backend/internal/huma/huma.go
@@ -160,6 +160,7 @@ type Services struct {
Volume *services.VolumeService
Container *services.ContainerService
Network *services.NetworkService
+ Port *services.PortService
Swarm *services.SwarmService
Notification *services.NotificationService
Apprise *services.AppriseService //nolint:staticcheck // Apprise still functional, deprecated in favor of Shoutrrr
@@ -323,6 +324,7 @@ func registerHandlers(api huma.API, svc *Services) {
var volumeSvc *services.VolumeService
var containerSvc *services.ContainerService
var networkSvc *services.NetworkService
+ var portSvc *services.PortService
var swarmSvc *services.SwarmService
var notificationSvc *services.NotificationService
var appriseSvc *services.AppriseService //nolint:staticcheck // Apprise still functional, deprecated in favor of Shoutrrr
@@ -360,6 +362,7 @@ func registerHandlers(api huma.API, svc *Services) {
volumeSvc = svc.Volume
containerSvc = svc.Container
networkSvc = svc.Network
+ portSvc = svc.Port
swarmSvc = svc.Swarm
notificationSvc = svc.Notification
appriseSvc = svc.Apprise
@@ -393,6 +396,7 @@ func registerHandlers(api huma.API, svc *Services) {
handlers.RegisterJobSchedules(api, jobScheduleSvc, environmentSvc)
handlers.RegisterVolumes(api, dockerSvc, volumeSvc)
handlers.RegisterContainers(api, containerSvc, dockerSvc)
+ handlers.RegisterPorts(api, portSvc)
handlers.RegisterNetworks(api, networkSvc, dockerSvc)
handlers.RegisterSwarm(api, swarmSvc, environmentSvc, eventSvc, cfg)
handlers.RegisterNotifications(api, notificationSvc, appriseSvc, cfg)
diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.go
index 344b5e769..2c8707eec 100644
--- a/backend/internal/services/container_service.go
+++ b/backend/internal/services/container_service.go
@@ -1020,6 +1020,11 @@ func (s *ContainerService) buildContainerSortBindings() []pagination.SortBinding
return strings.Compare(a.Status, b.Status)
},
},
+ {
+ Key: "ports",
+ Fn: compareContainerPortsForSortInternal,
+ DescFn: compareContainerPortsForSortDescInternal,
+ },
{
Key: "created",
Fn: func(a, b containertypes.Summary) int {
@@ -1035,6 +1040,83 @@ func (s *ContainerService) buildContainerSortBindings() []pagination.SortBinding
}
}
+func compareContainerPortsForSortInternal(a, b containertypes.Summary) int {
+ hasPortsA, portA := lowestContainerPortSortValueInternal(a.Ports)
+ hasPortsB, portB := lowestContainerPortSortValueInternal(b.Ports)
+
+ switch {
+ case !hasPortsA && !hasPortsB:
+ return compareContainerNamesForSortInternal(a, b)
+ case !hasPortsA:
+ return 1
+ case !hasPortsB:
+ return -1
+ case portA < portB:
+ return -1
+ case portA > portB:
+ return 1
+ default:
+ return compareContainerNamesForSortInternal(a, b)
+ }
+}
+
+func compareContainerPortsForSortDescInternal(a, b containertypes.Summary) int {
+ hasPortsA, portA := lowestContainerPortSortValueInternal(a.Ports)
+ hasPortsB, portB := lowestContainerPortSortValueInternal(b.Ports)
+
+ switch {
+ case !hasPortsA && !hasPortsB:
+ return compareContainerNamesForSortInternal(a, b)
+ case !hasPortsA:
+ return 1
+ case !hasPortsB:
+ return -1
+ case portA > portB:
+ return -1
+ case portA < portB:
+ return 1
+ default:
+ return compareContainerNamesForSortInternal(a, b)
+ }
+}
+
+func lowestContainerPortSortValueInternal(ports []containertypes.Port) (bool, int) {
+ if len(ports) == 0 {
+ return false, 0
+ }
+
+ lowestPublished := 0
+ lowestPrivate := 0
+ for _, port := range ports {
+ if port.PublicPort > 0 && (lowestPublished == 0 || port.PublicPort < lowestPublished) {
+ lowestPublished = port.PublicPort
+ }
+ if port.PrivatePort > 0 && (lowestPrivate == 0 || port.PrivatePort < lowestPrivate) {
+ lowestPrivate = port.PrivatePort
+ }
+ }
+
+ switch {
+ case lowestPublished > 0:
+ return true, lowestPublished
+ case lowestPrivate > 0:
+ return true, lowestPrivate
+ default:
+ return false, 0
+ }
+}
+
+func compareContainerNamesForSortInternal(a, b containertypes.Summary) int {
+ nameA, nameB := "", ""
+ if len(a.Names) > 0 {
+ nameA = a.Names[0]
+ }
+ if len(b.Names) > 0 {
+ nameB = b.Names[0]
+ }
+ return strings.Compare(nameA, nameB)
+}
+
func (s *ContainerService) buildContainerFilterAccessors() []pagination.FilterAccessor[containertypes.Summary] {
return []pagination.FilterAccessor[containertypes.Summary]{
{
diff --git a/backend/internal/services/container_service_test.go b/backend/internal/services/container_service_test.go
index 2c4d2a7af..fcca58cc2 100644
--- a/backend/internal/services/container_service_test.go
+++ b/backend/internal/services/container_service_test.go
@@ -181,6 +181,27 @@ func TestStreamContainerLogs_TTYPythonLikeFollowDoesNotReturnEmptyLogs(t *testin
}, lines)
}
+func TestCompareContainerPortsForSortDesc_KeepsContainersWithoutPortsLast(t *testing.T) {
+ withPublished := containertypes.Summary{
+ ID: "published",
+ Names: []string{"/published"},
+ Ports: []containertypes.Port{{PublicPort: 8080, PrivatePort: 80, Type: "tcp"}},
+ }
+ withPrivateOnly := containertypes.Summary{
+ ID: "private",
+ Names: []string{"/private"},
+ Ports: []containertypes.Port{{PrivatePort: 3000, Type: "tcp"}},
+ }
+ withoutPorts := containertypes.Summary{
+ ID: "none",
+ Names: []string{"/none"},
+ }
+
+ require.Equal(t, -1, compareContainerPortsForSortDescInternal(withPublished, withPrivateOnly))
+ require.Equal(t, -1, compareContainerPortsForSortDescInternal(withPrivateOnly, withoutPorts))
+ require.Equal(t, 1, compareContainerPortsForSortDescInternal(withoutPorts, withPublished))
+}
+
func TestStreamMultiplexedLogs_ContextCancelDoesNotDeadlock(t *testing.T) {
var stream bytes.Buffer
writeDockerLogFrameInternal(t, &stream, 1, "line 1\n")
diff --git a/backend/internal/services/network_service.go b/backend/internal/services/network_service.go
index 885498c47..39e4d4066 100644
--- a/backend/internal/services/network_service.go
+++ b/backend/internal/services/network_service.go
@@ -3,6 +3,7 @@ package services
import (
"context"
"fmt"
+ "sort"
"strings"
"github.com/getarcaneapp/arcane/backend/internal/database"
@@ -14,6 +15,7 @@ import (
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
+ "golang.org/x/sync/errgroup"
)
type NetworkService struct {
@@ -45,6 +47,129 @@ func (s *NetworkService) GetNetworkByID(ctx context.Context, id string) (*networ
return &inspect, nil
}
+func (s *NetworkService) GetNetworkTopology(ctx context.Context) (*networktypes.Topology, error) {
+ dockerClient, err := s.dockerService.GetClient(ctx)
+ if err != nil {
+ return nil, fmt.Errorf("failed to connect to Docker: %w", err)
+ }
+
+ containerList, err := dockerClient.ContainerList(ctx, client.ContainerListOptions{All: true})
+ if err != nil {
+ return nil, fmt.Errorf("failed to list containers: %w", err)
+ }
+
+ containerInfoByID := buildTopologyContainerInfoInternal(containerList.Items)
+
+ networkList, err := libarcane.NetworkListWithCompatibility(ctx, dockerClient, client.NetworkListOptions{})
+ if err != nil {
+ return nil, fmt.Errorf("failed to list Docker networks: %w", err)
+ }
+
+ topology := &networktypes.Topology{
+ Nodes: make([]networktypes.TopologyNode, 0, len(networkList.Items)),
+ Edges: make([]networktypes.TopologyEdge, 0),
+ }
+ containerNodeIDs := make(map[string]struct{})
+ inspectedNetworks := make([]struct {
+ summary network.Summary
+ inspect network.Inspect
+ }, len(networkList.Items))
+
+ g, groupCtx := errgroup.WithContext(ctx)
+ g.SetLimit(8)
+
+ for i := range networkList.Items {
+ rawNetwork := networkList.Items[i]
+ g.Go(func() error {
+ inspected, err := libarcane.NetworkInspectWithCompatibility(groupCtx, dockerClient, rawNetwork.ID, client.NetworkInspectOptions{})
+ if err != nil {
+ return fmt.Errorf("failed to inspect network %s: %w", rawNetwork.Name, err)
+ }
+
+ inspectedNetworks[i] = struct {
+ summary network.Summary
+ inspect network.Inspect
+ }{
+ summary: rawNetwork,
+ inspect: inspected.Network,
+ }
+ return nil
+ })
+ }
+
+ if err := g.Wait(); err != nil {
+ return nil, err
+ }
+
+ for _, inspectedNetwork := range inspectedNetworks {
+ rawNetwork := inspectedNetwork.summary
+ topology.Nodes = append(topology.Nodes, networktypes.TopologyNode{
+ ID: rawNetwork.ID,
+ Name: rawNetwork.Name,
+ Type: networktypes.TopologyNodeTypeNetwork,
+ Metadata: networktypes.TopologyNodeMetadata{
+ Driver: rawNetwork.Driver,
+ Scope: rawNetwork.Scope,
+ IsDefault: dockerutil.IsDefaultNetwork(rawNetwork.Name),
+ },
+ })
+
+ for containerID, endpoint := range inspectedNetwork.inspect.Containers {
+ info, ok := containerInfoByID[containerID]
+ if !ok {
+ info = topologyContainerInfo{Name: endpoint.Name}
+ }
+ if info.Name == "" {
+ info.Name = endpoint.Name
+ }
+
+ if _, exists := containerNodeIDs[containerID]; !exists {
+ topology.Nodes = append(topology.Nodes, networktypes.TopologyNode{
+ ID: containerID,
+ Name: info.Name,
+ Type: networktypes.TopologyNodeTypeContainer,
+ Metadata: networktypes.TopologyNodeMetadata{
+ Status: info.State,
+ Image: info.Image,
+ },
+ })
+ containerNodeIDs[containerID] = struct{}{}
+ }
+
+ edge := networktypes.TopologyEdge{
+ ID: fmt.Sprintf("%s:%s", rawNetwork.ID, containerID),
+ Source: rawNetwork.ID,
+ Target: containerID,
+ }
+ if endpoint.IPv4Address.IsValid() {
+ edge.IPv4Address = endpoint.IPv4Address.String()
+ }
+ if endpoint.IPv6Address.IsValid() {
+ edge.IPv6Address = endpoint.IPv6Address.String()
+ }
+
+ topology.Edges = append(topology.Edges, edge)
+ }
+ }
+
+ sort.Slice(topology.Nodes, func(i, j int) bool {
+ left, right := topology.Nodes[i], topology.Nodes[j]
+ if left.Type != right.Type {
+ return left.Type < right.Type
+ }
+ return strings.ToLower(left.Name) < strings.ToLower(right.Name)
+ })
+ sort.Slice(topology.Edges, func(i, j int) bool {
+ left, right := topology.Edges[i], topology.Edges[j]
+ if left.Source != right.Source {
+ return left.Source < right.Source
+ }
+ return left.Target < right.Target
+ })
+
+ return topology, nil
+}
+
func (s *NetworkService) CreateNetwork(ctx context.Context, name string, options client.NetworkCreateOptions, user models.User) (*network.CreateResponse, error) {
dockerClient, err := s.dockerService.GetClient(ctx)
if err != nil {
@@ -182,6 +307,28 @@ func (s *NetworkService) buildNetworkUsageMaps(containers []container.Summary) (
return inUseByID, inUseByName
}
+type topologyContainerInfo struct {
+ Name string
+ Image string
+ State string
+}
+
+func buildTopologyContainerInfoInternal(containers []container.Summary) map[string]topologyContainerInfo {
+ infoByID := make(map[string]topologyContainerInfo, len(containers))
+ for _, rawContainer := range containers {
+ name := rawContainer.ID
+ if len(rawContainer.Names) > 0 {
+ name = strings.TrimPrefix(rawContainer.Names[0], "/")
+ }
+ infoByID[rawContainer.ID] = topologyContainerInfo{
+ Name: name,
+ Image: rawContainer.Image,
+ State: string(rawContainer.State),
+ }
+ }
+ return infoByID
+}
+
func (s *NetworkService) convertToNetworkSummaries(rawNets []network.Summary, inUseByID, inUseByName map[string]bool) []networktypes.Summary {
items := make([]networktypes.Summary, 0, len(rawNets))
for _, n := range rawNets {
diff --git a/backend/internal/services/port_service.go b/backend/internal/services/port_service.go
new file mode 100644
index 000000000..b7dcb0088
--- /dev/null
+++ b/backend/internal/services/port_service.go
@@ -0,0 +1,222 @@
+package services
+
+import (
+ "context"
+ "fmt"
+ "strconv"
+ "strings"
+
+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"
+ containertypes "github.com/getarcaneapp/arcane/types/container"
+ porttypes "github.com/getarcaneapp/arcane/types/port"
+ "github.com/moby/moby/client"
+)
+
+type PortService struct {
+ dockerService *DockerClientService
+}
+
+func NewPortService(dockerService *DockerClientService) *PortService {
+ return &PortService{dockerService: dockerService}
+}
+
+func (s *PortService) ListPortsPaginated(ctx context.Context, params pagination.QueryParams) ([]porttypes.PortMapping, pagination.Response, error) {
+ dockerClient, err := s.dockerService.GetClient(ctx)
+ if err != nil {
+ return nil, pagination.Response{}, fmt.Errorf("failed to connect to Docker: %w", err)
+ }
+
+ containerList, err := dockerClient.ContainerList(ctx, client.ContainerListOptions{All: true})
+ if err != nil {
+ return nil, pagination.Response{}, fmt.Errorf("failed to list containers: %w", err)
+ }
+
+ items := make([]porttypes.PortMapping, 0)
+ for _, rawContainer := range containerList.Items {
+ summary := containertypes.NewSummary(rawContainer)
+ containerName := primaryContainerNameInternal(summary.Names, summary.ID)
+ for _, port := range summary.Ports {
+ items = append(items, porttypes.PortMapping{
+ ID: buildPortMappingIDInternal(summary.ID, port),
+ ContainerID: summary.ID,
+ ContainerName: containerName,
+ HostIP: port.IP,
+ HostPort: port.PublicPort,
+ ContainerPort: port.PrivatePort,
+ Protocol: port.Type,
+ IsPublished: port.PublicPort > 0,
+ })
+ }
+ }
+
+ result := pagination.SearchOrderAndPaginate(items, params, s.buildPortPaginationConfig())
+ return result.Items, pagination.BuildResponseFromFilterResult(result, params), nil
+}
+
+func (s *PortService) buildPortPaginationConfig() pagination.Config[porttypes.PortMapping] {
+ return pagination.Config[porttypes.PortMapping]{
+ SearchAccessors: []pagination.SearchAccessor[porttypes.PortMapping]{
+ func(item porttypes.PortMapping) (string, error) { return item.ContainerName, nil },
+ func(item porttypes.PortMapping) (string, error) { return item.HostIP, nil },
+ func(item porttypes.PortMapping) (string, error) { return strconv.Itoa(item.HostPort), nil },
+ func(item porttypes.PortMapping) (string, error) { return strconv.Itoa(item.ContainerPort), nil },
+ func(item porttypes.PortMapping) (string, error) { return item.Protocol, nil },
+ },
+ SortBindings: s.buildPortSortBindings(),
+ }
+}
+
+func (s *PortService) buildPortSortBindings() []pagination.SortBinding[porttypes.PortMapping] {
+ return []pagination.SortBinding[porttypes.PortMapping]{
+ {
+ Key: "hostPort",
+ Fn: func(a, b porttypes.PortMapping) int {
+ return compareOptionalIntInternal(a.HostPort, b.HostPort, a.ContainerName, b.ContainerName)
+ },
+ DescFn: func(a, b porttypes.PortMapping) int {
+ return compareOptionalIntDescInternal(a.HostPort, b.HostPort, a.ContainerName, b.ContainerName)
+ },
+ },
+ {
+ Key: "containerPort",
+ Fn: func(a, b porttypes.PortMapping) int {
+ if a.ContainerPort != b.ContainerPort {
+ if a.ContainerPort < b.ContainerPort {
+ return -1
+ }
+ return 1
+ }
+ return strings.Compare(a.ContainerName, b.ContainerName)
+ },
+ },
+ {
+ Key: "protocol",
+ Fn: func(a, b porttypes.PortMapping) int {
+ if cmp := strings.Compare(a.Protocol, b.Protocol); cmp != 0 {
+ return cmp
+ }
+ return strings.Compare(a.ContainerName, b.ContainerName)
+ },
+ },
+ {
+ Key: "containerName",
+ Fn: func(a, b porttypes.PortMapping) int {
+ return strings.Compare(a.ContainerName, b.ContainerName)
+ },
+ },
+ {
+ Key: "hostIp",
+ Fn: func(a, b porttypes.PortMapping) int {
+ return compareOptionalStringInternal(a.HostIP, b.HostIP, a.ContainerName, b.ContainerName)
+ },
+ DescFn: func(a, b porttypes.PortMapping) int {
+ return compareOptionalStringDescInternal(a.HostIP, b.HostIP, a.ContainerName, b.ContainerName)
+ },
+ },
+ {
+ Key: "isPublished",
+ Fn: func(a, b porttypes.PortMapping) int {
+ if a.IsPublished != b.IsPublished {
+ if a.IsPublished {
+ return -1
+ }
+ return 1
+ }
+ return strings.Compare(a.ContainerName, b.ContainerName)
+ },
+ },
+ }
+}
+
+func primaryContainerNameInternal(names []string, id string) string {
+ if len(names) > 0 && names[0] != "" {
+ return strings.TrimPrefix(names[0], "/")
+ }
+ if len(id) >= 12 {
+ return id[:12]
+ }
+ return id
+}
+
+func buildPortMappingIDInternal(containerID string, port containertypes.Port) string {
+ return fmt.Sprintf("%s:%s:%d:%d:%s", containerID, port.IP, port.PublicPort, port.PrivatePort, port.Type)
+}
+
+func compareOptionalIntInternal(a, b int, fallbackA, fallbackB string) int {
+ switch {
+ case a == 0 && b == 0:
+ return strings.Compare(fallbackA, fallbackB)
+ case a == 0:
+ return 1
+ case b == 0:
+ return -1
+ case a < b:
+ return -1
+ case a > b:
+ return 1
+ default:
+ return strings.Compare(fallbackA, fallbackB)
+ }
+}
+
+func compareOptionalIntDescInternal(a, b int, fallbackA, fallbackB string) int {
+ switch {
+ case a == 0 && b == 0:
+ return strings.Compare(fallbackA, fallbackB)
+ case a == 0:
+ return 1
+ case b == 0:
+ return -1
+ case a > b:
+ return -1
+ case a < b:
+ return 1
+ default:
+ return strings.Compare(fallbackA, fallbackB)
+ }
+}
+
+func compareOptionalStringInternal(a, b, fallbackA, fallbackB string) int {
+ a = normalizeOptionalStringSortValueInternal(a)
+ b = normalizeOptionalStringSortValueInternal(b)
+
+ switch {
+ case a == "" && b == "":
+ return strings.Compare(fallbackA, fallbackB)
+ case a == "":
+ return 1
+ case b == "":
+ return -1
+ default:
+ if cmp := strings.Compare(a, b); cmp != 0 {
+ return cmp
+ }
+ return strings.Compare(fallbackA, fallbackB)
+ }
+}
+
+func compareOptionalStringDescInternal(a, b, fallbackA, fallbackB string) int {
+ a = normalizeOptionalStringSortValueInternal(a)
+ b = normalizeOptionalStringSortValueInternal(b)
+
+ switch {
+ case a == "" && b == "":
+ return strings.Compare(fallbackA, fallbackB)
+ case a == "":
+ return 1
+ case b == "":
+ return -1
+ default:
+ if cmp := strings.Compare(b, a); cmp != 0 {
+ return cmp
+ }
+ return strings.Compare(fallbackA, fallbackB)
+ }
+}
+
+func normalizeOptionalStringSortValueInternal(value string) string {
+ if strings.EqualFold(strings.TrimSpace(value), "invalid IP") {
+ return ""
+ }
+ return value
+}
diff --git a/backend/internal/services/port_service_test.go b/backend/internal/services/port_service_test.go
new file mode 100644
index 000000000..943fab11a
--- /dev/null
+++ b/backend/internal/services/port_service_test.go
@@ -0,0 +1,224 @@
+package services
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "net/netip"
+ "strings"
+ "testing"
+
+ "github.com/getarcaneapp/arcane/backend/pkg/pagination"
+ dockercontainer "github.com/moby/moby/api/types/container"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func newPortServiceTestDockerService(t *testing.T, containers []dockercontainer.Summary) *DockerClientService {
+ t.Helper()
+
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+
+ switch {
+ case strings.HasSuffix(r.URL.Path, "/containers/json"):
+ require.NoError(t, json.NewEncoder(w).Encode(containers))
+ default:
+ http.NotFound(w, r)
+ }
+ }))
+ t.Cleanup(server.Close)
+
+ return &DockerClientService{client: newTestDockerClient(t, server)}
+}
+
+func TestPortService_ListPortsPaginated_FlattensPublishedAndExposedPorts(t *testing.T) {
+ svc := NewPortService(newPortServiceTestDockerService(t, []dockercontainer.Summary{
+ {
+ ID: "container-published",
+ Names: []string{"/web"},
+ Ports: []dockercontainer.PortSummary{
+ {IP: netip.MustParseAddr("0.0.0.0"), PrivatePort: 80, PublicPort: 8080, Type: "tcp"},
+ {PrivatePort: 443, Type: "tcp"},
+ },
+ },
+ {
+ ID: "container-exposed",
+ Names: []string{"/api"},
+ Ports: []dockercontainer.PortSummary{
+ {PrivatePort: 9000, Type: "udp"},
+ },
+ },
+ }))
+
+ items, page, err := svc.ListPortsPaginated(context.Background(), pagination.QueryParams{
+ PaginationParams: pagination.PaginationParams{Limit: 20},
+ })
+ require.NoError(t, err)
+ require.Len(t, items, 3)
+
+ assert.Equal(t, int64(3), page.TotalItems)
+ assert.Equal(t, "web", items[0].ContainerName)
+ assert.Equal(t, "0.0.0.0", items[0].HostIP)
+ assert.Equal(t, 8080, items[0].HostPort)
+ assert.Equal(t, 80, items[0].ContainerPort)
+ assert.True(t, items[0].IsPublished)
+ assert.Equal(t, "container-published:0.0.0.0:8080:80:tcp", items[0].ID)
+
+ assert.Equal(t, "web", items[1].ContainerName)
+ assert.Equal(t, 0, items[1].HostPort)
+ assert.Equal(t, 443, items[1].ContainerPort)
+ assert.False(t, items[1].IsPublished)
+
+ assert.Equal(t, "api", items[2].ContainerName)
+ assert.Equal(t, 9000, items[2].ContainerPort)
+ assert.Equal(t, "udp", items[2].Protocol)
+ assert.False(t, items[2].IsPublished)
+}
+
+func TestPortService_ListPortsPaginated_SortsByHostPortWithUnpublishedLast(t *testing.T) {
+ svc := NewPortService(newPortServiceTestDockerService(t, []dockercontainer.Summary{
+ {
+ ID: "container-3000",
+ Names: []string{"/api"},
+ Ports: []dockercontainer.PortSummary{
+ {IP: netip.MustParseAddr("127.0.0.1"), PrivatePort: 3000, PublicPort: 3000, Type: "tcp"},
+ },
+ },
+ {
+ ID: "container-8080",
+ Names: []string{"/web"},
+ Ports: []dockercontainer.PortSummary{
+ {IP: netip.MustParseAddr("0.0.0.0"), PrivatePort: 80, PublicPort: 8080, Type: "tcp"},
+ },
+ },
+ {
+ ID: "container-unpublished",
+ Names: []string{"/worker"},
+ Ports: []dockercontainer.PortSummary{
+ {PrivatePort: 9000, Type: "tcp"},
+ },
+ },
+ }))
+
+ items, _, err := svc.ListPortsPaginated(context.Background(), pagination.QueryParams{
+ SortParams: pagination.SortParams{
+ Sort: "hostPort",
+ Order: pagination.SortAsc,
+ },
+ PaginationParams: pagination.PaginationParams{Limit: 20},
+ })
+ require.NoError(t, err)
+ require.Len(t, items, 3)
+
+ assert.Equal(t, []string{"api", "web", "worker"}, []string{
+ items[0].ContainerName,
+ items[1].ContainerName,
+ items[2].ContainerName,
+ })
+ assert.Equal(t, []int{3000, 8080, 0}, []int{
+ items[0].HostPort,
+ items[1].HostPort,
+ items[2].HostPort,
+ })
+}
+
+func TestPortService_ListPortsPaginated_SortsByHostPortDescWithUnpublishedLast(t *testing.T) {
+ svc := NewPortService(newPortServiceTestDockerService(t, []dockercontainer.Summary{
+ {
+ ID: "container-3000",
+ Names: []string{"/api"},
+ Ports: []dockercontainer.PortSummary{
+ {IP: netip.MustParseAddr("127.0.0.1"), PrivatePort: 3000, PublicPort: 3000, Type: "tcp"},
+ },
+ },
+ {
+ ID: "container-8080",
+ Names: []string{"/web"},
+ Ports: []dockercontainer.PortSummary{
+ {IP: netip.MustParseAddr("0.0.0.0"), PrivatePort: 80, PublicPort: 8080, Type: "tcp"},
+ },
+ },
+ {
+ ID: "container-unpublished",
+ Names: []string{"/worker"},
+ Ports: []dockercontainer.PortSummary{
+ {PrivatePort: 9000, Type: "tcp"},
+ },
+ },
+ }))
+
+ items, _, err := svc.ListPortsPaginated(context.Background(), pagination.QueryParams{
+ SortParams: pagination.SortParams{
+ Sort: "hostPort",
+ Order: pagination.SortDesc,
+ },
+ PaginationParams: pagination.PaginationParams{Limit: 20},
+ })
+ require.NoError(t, err)
+ require.Len(t, items, 3)
+
+ assert.Equal(t, []string{"web", "api", "worker"}, []string{
+ items[0].ContainerName,
+ items[1].ContainerName,
+ items[2].ContainerName,
+ })
+ assert.Equal(t, []int{8080, 3000, 0}, []int{
+ items[0].HostPort,
+ items[1].HostPort,
+ items[2].HostPort,
+ })
+}
+
+func TestPortService_ListPortsPaginated_SortsByHostIPDescWithUnpublishedLast(t *testing.T) {
+ svc := NewPortService(newPortServiceTestDockerService(t, []dockercontainer.Summary{
+ {
+ ID: "container-127",
+ Names: []string{"/api"},
+ Ports: []dockercontainer.PortSummary{
+ {IP: netip.MustParseAddr("127.0.0.1"), PrivatePort: 3000, PublicPort: 3000, Type: "tcp"},
+ },
+ },
+ {
+ ID: "container-000",
+ Names: []string{"/web"},
+ Ports: []dockercontainer.PortSummary{
+ {IP: netip.MustParseAddr("0.0.0.0"), PrivatePort: 80, PublicPort: 8080, Type: "tcp"},
+ },
+ },
+ {
+ ID: "container-unpublished",
+ Names: []string{"/worker"},
+ Ports: []dockercontainer.PortSummary{
+ {PrivatePort: 9000, Type: "tcp"},
+ },
+ },
+ }))
+
+ items, _, err := svc.ListPortsPaginated(context.Background(), pagination.QueryParams{
+ SortParams: pagination.SortParams{
+ Sort: "hostIp",
+ Order: pagination.SortDesc,
+ },
+ PaginationParams: pagination.PaginationParams{Limit: 20},
+ })
+ require.NoError(t, err)
+ require.Len(t, items, 3)
+
+ assert.Equal(t, []string{"api", "web", "worker"}, []string{
+ items[0].ContainerName,
+ items[1].ContainerName,
+ items[2].ContainerName,
+ })
+ assert.Equal(t, []string{"127.0.0.1", "0.0.0.0", ""}, []string{
+ items[0].HostIP,
+ items[1].HostIP,
+ normalizeOptionalStringSortValueInternal(items[2].HostIP),
+ })
+}
+
+func TestPrimaryContainerName_TrimsDockerPrefix(t *testing.T) {
+ assert.Equal(t, "web", primaryContainerNameInternal([]string{"/web"}, "container-id"))
+ assert.Equal(t, "abcdef123456", primaryContainerNameInternal(nil, "abcdef1234567890"))
+}
diff --git a/backend/pkg/pagination/sort.go b/backend/pkg/pagination/sort.go
index 2c3612224..e2a36a1f6 100644
--- a/backend/pkg/pagination/sort.go
+++ b/backend/pkg/pagination/sort.go
@@ -17,8 +17,9 @@ type SortParams struct {
type (
SortOption[T any] func(a, b T) int
SortBinding[T any] struct {
- Key string
- Fn SortOption[T]
+ Key string
+ Fn SortOption[T]
+ DescFn SortOption[T]
}
)
@@ -27,7 +28,11 @@ func sortFunction[T any](items []T, params SortParams, sorts []SortBinding[T]) [
if sort.Key == params.Sort {
fn := sort.Fn
if params.Order == SortDesc {
- fn = reverSortFn(fn)
+ if sort.DescFn != nil {
+ fn = sort.DescFn
+ } else {
+ fn = reverSortFn(fn)
+ }
}
slices.SortStableFunc(items, fn)
}
diff --git a/backend/pkg/pagination/sort_test.go b/backend/pkg/pagination/sort_test.go
new file mode 100644
index 000000000..a61fa641e
--- /dev/null
+++ b/backend/pkg/pagination/sort_test.go
@@ -0,0 +1,47 @@
+package pagination
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestSortFunctionUsesCustomDescendingComparatorWhenProvided(t *testing.T) {
+ items := []int{2, 1, 0}
+
+ sorted := sortFunction(items, SortParams{Sort: "ports", Order: SortDesc}, []SortBinding[int]{
+ {
+ Key: "ports",
+ Fn: func(a, b int) int {
+ switch {
+ case a < b:
+ return -1
+ case a > b:
+ return 1
+ default:
+ return 0
+ }
+ },
+ DescFn: func(a, b int) int {
+ aIsEmpty := a == 0
+ bIsEmpty := b == 0
+ switch {
+ case aIsEmpty && bIsEmpty:
+ return 0
+ case aIsEmpty:
+ return 1
+ case bIsEmpty:
+ return -1
+ case a > b:
+ return -1
+ case a < b:
+ return 1
+ default:
+ return 0
+ }
+ },
+ },
+ })
+
+ require.Equal(t, []int{2, 1, 0}, sorted)
+}
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 636f909c6..7d1dfd266 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -754,6 +754,13 @@
"_comment_networks": "=== NETWORKS ===",
"networks_title": "Networks",
"networks_subtitle": "Manage your Docker networks",
+ "networks_topology_title": "Network Topology",
+ "networks_topology_subtitle": "Visualize networks and the containers connected to them",
+ "networks_topology_button": "Topology",
+ "networks_topology_empty": "No network topology data is available for this environment.",
+ "networks_topology_hint": "Click a node to open its details.",
+ "networks_topology_legend_networks": "Networks",
+ "networks_topology_legend_containers": "Containers",
"networks_total": "Total Networks",
"networks_delete_selected_title": "Delete {count} network(s)",
"networks_delete_selected_message": "Are you sure you want to delete {count} selected network(s)? This action cannot be undone.",
@@ -2355,6 +2362,15 @@
"containers_ports_published_exposed": "{published} published, {exposed} exposed",
"containers_ports_published": "{published} published",
"containers_ports_exposed": "{exposed} exposed",
+ "ports_title": "Ports",
+ "ports_subtitle": "Inspect published and exposed container ports across the active environment",
+ "ports_host_port": "Host Port",
+ "ports_container_port": "Container Port",
+ "ports_container_name": "Container",
+ "ports_host_ip": "Host IP",
+ "ports_published_label": "Published",
+ "ports_exposed_label": "Exposed",
+ "ports_no_host_binding": "Not published",
"common_mount": "mount",
"common_mounts": "mounts",
"common_image_id": "Image ID",
diff --git a/frontend/package.json b/frontend/package.json
index bc5dbd4ac..784be72ee 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -34,6 +34,7 @@
"@uiw/codemirror-themes": "^4.25.8",
"@xterm/addon-fit": "^0.11.0",
"@xterm/xterm": "^6.0.0",
+ "@xyflow/svelte": "^1.5.2",
"ajv": "^8.18.0",
"ansi-to-html": "^0.7.2",
"axios": "^1.14.0",
diff --git a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
index 7441d9450..58a4290ce 100644
--- a/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
+++ b/frontend/src/lib/components/mobile-nav/mobile-nav-sheet.svelte
@@ -178,22 +178,63 @@
</h4>
<div class="space-y-2">
{#each navigationItems.resourceItems as item (item.url)}
- {@const IconComponent = item.icon}
- <a
- href={item.url}
- onclick={handleItemClick}
- class={cn(
- 'flex items-center gap-3 rounded-2xl px-4 py-3 text-sm font-medium transition-all duration-200 ease-out',
- 'focus-visible:ring-muted-foreground/50 hover:scale-[1.01] focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent',
- isActiveItem(item)
- ? 'bg-muted text-foreground hover:bg-muted/70 shadow-sm'
- : 'text-foreground hover:bg-muted/50'
- )}
- aria-current={isActiveItem(item) ? 'page' : undefined}
- >
- <IconComponent size={20} />
- <span>{item.title}</span>
- </a>
+ {#if item.items}
+ {@const IconComponent = item.icon}
+ <div class="space-y-2">
+ <a
+ href={item.url}
+ onclick={handleItemClick}
+ class={cn(
+ 'flex items-center gap-3 rounded-2xl px-4 py-3 text-sm font-medium transition-all duration-200 ease-out',
+ 'focus-visible:ring-muted-foreground/50 hover:scale-[1.01] focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent',
+ isActiveItem(item)
+ ? 'bg-muted text-foreground hover:bg-muted/70 shadow-sm'
+ : 'text-foreground hover:bg-muted/50'
+ )}
+ aria-current={isActiveItem(item) ? 'page' : undefined}
+ >
+ <IconComponent size={20} />
+ <span>{item.title}</span>
+ </a>
+ <div class="ml-6 space-y-1">
+ {#each item.items as subItem (subItem.url)}
+ {@const SubIconComponent = subItem.icon}
+ <a
+ href={subItem.url}
+ onclick={handleItemClick}
+ class={cn(
+ 'flex items-center gap-3 rounded-xl px-4 py-2 text-sm transition-all duration-200 ease-out',
+ 'focus-visible:ring-muted-foreground/50 hover:scale-[1.01] focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent',
+ isActiveItem(subItem)
+ ? 'bg-muted/70 text-foreground shadow-sm'
+ : 'text-muted-foreground hover:text-foreground hover:bg-muted/40'
+ )}
+ aria-current={isActiveItem(subItem) ? 'page' : undefined}
+ >
+ <SubIconComponent size={16} />
+ <span>{subItem.title}</span>
+ </a>
+ {/each}
+ </div>
+ </div>
+ {:else}
+ {@const IconComponent = item.icon}
+ <a
+ href={item.url}
+ onclick={handleItemClick}
+ class={cn(
+ 'flex items-center gap-3 rounded-2xl px-4 py-3 text-sm font-medium transition-all duration-200 ease-out',
+ 'focus-visible:ring-muted-foreground/50 hover:scale-[1.01] focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent',
+ isActiveItem(item)
+ ? 'bg-muted text-foreground hover:bg-muted/70 shadow-sm'
+ : 'text-foreground hover:bg-muted/50'
+ )}
+ aria-current={isActiveItem(item) ? 'page' : undefined}
+ >
+ <IconComponent size={20} />
+ <span>{item.title}</span>
+ </a>
+ {/if}
{/each}
</div>
</section>
diff --git a/frontend/src/lib/components/network-diagram/network-diagram.svelte b/frontend/src/lib/components/network-diagram/network-diagram.svelte
new file mode 100644
index 000000000..cc7be5a5d
--- /dev/null
+++ b/frontend/src/lib/components/network-diagram/network-diagram.svelte
@@ -0,0 +1,449 @@
+<script lang="ts">
+ import { browser } from '$app/environment';
+ import { goto } from '$app/navigation';
+ import StatusBadge from '$lib/components/badges/status-badge.svelte';
+ import { m } from '$lib/paraglide/messages';
+ import type { NetworkTopologyDto, TopologyEdgeDto, TopologyNodeDto } from '$lib/types/network.type';
+ import { cn } from '$lib/utils';
+ import { mode } from 'mode-watcher';
+ import { onMount } from 'svelte';
+ import { Background, BackgroundVariant, Controls, MiniMap, Position, SvelteFlow, type Edge, type Node } from '@xyflow/svelte';
+ import '@xyflow/svelte/dist/style.css';
+
+ let {
+ topology,
+ class: className = ''
+ }: {
+ topology: NetworkTopologyDto;
+ class?: string;
+ } = $props();
+
+ let isReady = $state(false);
+
+ onMount(() => {
+ isReady = true;
+ });
+
+ type DiagramNodeData = {
+ href: string;
+ kind: 'network' | 'container';
+ label: string;
+ };
+
+ type NodePalette = {
+ background: string;
+ surface: string;
+ border: string;
+ text: string;
+ };
+
+ const networkNodes = $derived(topology.nodes.filter((node) => node.type === 'network'));
+ const containerNodes = $derived(topology.nodes.filter((node) => node.type === 'container'));
+ const isDarkMode = $derived(mode.current === 'dark');
+
+ const canvasTheme = $derived(
+ isDarkMode
+ ? {
+ flowBackground: '#0b1220',
+ edgeLabel: '#cbd5e1',
+ edgeLabelBackground: 'rgba(15, 23, 42, 0.92)',
+ edgeStroke: 'rgba(148, 163, 184, 0.42)',
+ backgroundDots: 'rgba(148, 163, 184, 0.22)',
+ minimapBackground: 'rgba(15, 23, 42, 0.92)',
+ minimapMask: 'rgba(15, 23, 42, 0.45)',
+ minimapMaskStroke: 'rgba(148, 163, 184, 0.34)',
+ shellBackground:
+ 'radial-gradient(circle at top left, rgba(14, 165, 233, 0.14), transparent 28%), radial-gradient(circle at top right, rgba(124, 58, 237, 0.16), transparent 24%), linear-gradient(180deg, rgba(12, 18, 32, 0.96), rgba(8, 12, 24, 0.98))',
+ shellBorder: 'color-mix(in srgb, var(--border) 82%, transparent)',
+ shellShadow: '0 24px 72px rgba(2, 6, 23, 0.5)',
+ nodeShadow: '0 18px 52px rgba(2, 6, 23, 0.42)',
+ nodeHoverShadow: '0 28px 64px rgba(2, 6, 23, 0.54)',
+ nodeSelectedShadow: '0 0 0 3px rgba(56, 189, 248, 0.22)',
+ controlsBackground: 'rgba(15, 23, 42, 0.92)',
+ controlsForeground: 'rgb(226, 232, 240)',
+ controlsBorder: 'rgba(148, 163, 184, 0.18)',
+ controlsShadow: '0 14px 32px rgba(2, 6, 23, 0.36)',
+ minimapBorder: 'rgba(148, 163, 184, 0.18)',
+ minimapShadow: '0 14px 32px rgba(2, 6, 23, 0.36)'
+ }
+ : {
+ flowBackground: '#f8fafc',
+ edgeLabel: '#475569',
+ edgeLabelBackground: 'rgba(255, 255, 255, 0.96)',
+ edgeStroke: 'rgba(71, 85, 105, 0.55)',
+ backgroundDots: 'rgba(100, 116, 139, 0.18)',
+ minimapBackground: 'rgba(248, 250, 252, 0.95)',
+ minimapMask: 'rgba(15, 23, 42, 0.12)',
+ minimapMaskStroke: 'rgba(15, 23, 42, 0.28)',
+ shellBackground:
+ 'radial-gradient(circle at top left, rgba(125, 211, 252, 0.18), transparent 28%), radial-gradient(circle at top right, rgba(196, 181, 253, 0.2), transparent 24%), linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.98))',
+ shellBorder: 'color-mix(in srgb, var(--border) 72%, transparent)',
+ shellShadow: '0 20px 60px rgba(15, 23, 42, 0.08)',
+ nodeShadow: '0 16px 40px rgba(15, 23, 42, 0.08)',
+ nodeHoverShadow: '0 24px 56px rgba(15, 23, 42, 0.12)',
+ nodeSelectedShadow: '0 0 0 3px rgba(56, 189, 248, 0.2)',
+ controlsBackground: 'rgba(255, 255, 255, 0.96)',
+ controlsForeground: 'rgb(51, 65, 85)',
+ controlsBorder: 'rgba(148, 163, 184, 0.24)',
+ controlsShadow: '0 12px 28px rgba(15, 23, 42, 0.12)',
+ minimapBorder: 'rgba(148, 163, 184, 0.24)',
+ minimapShadow: '0 12px 28px rgba(15, 23, 42, 0.12)'
+ }
+ );
+
+ function networkPalette(driver?: string, darkMode = false): NodePalette {
+ if (darkMode) {
+ switch ((driver ?? '').toLowerCase()) {
+ case 'bridge':
+ return { background: '#083344', surface: '#0f172a', border: '#22d3ee', text: '#cffafe' };
+ case 'overlay':
+ return { background: '#3b0764', surface: '#111827', border: '#a855f7', text: '#f3e8ff' };
+ case 'ipvlan':
+ return { background: '#7c2d12', surface: '#111827', border: '#fb923c', text: '#ffedd5' };
+ case 'macvlan':
+ return { background: '#881337', surface: '#111827', border: '#f472b6', text: '#fce7f3' };
+ default:
+ return { background: '#1e293b', surface: '#0f172a', border: '#94a3b8', text: '#e2e8f0' };
+ }
+ }
+
+ switch ((driver ?? '').toLowerCase()) {
+ case 'bridge':
+ return { background: '#ecfeff', surface: '#ffffff', border: '#0891b2', text: '#155e75' };
+ case 'overlay':
+ return { background: '#f5f3ff', surface: '#ffffff', border: '#7c3aed', text: '#5b21b6' };
+ case 'ipvlan':
+ return { background: '#fff7ed', surface: '#ffffff', border: '#ea580c', text: '#9a3412' };
+ case 'macvlan':
+ return { background: '#fff1f2', surface: '#ffffff', border: '#e11d48', text: '#9f1239' };
+ default:
+ return { background: '#f8fafc', surface: '#ffffff', border: '#64748b', text: '#334155' };
+ }
+ }
+
+ function containerPalette(status?: string, darkMode = false): NodePalette {
+ if (darkMode) {
+ switch ((status ?? '').toLowerCase()) {
+ case 'running':
+ return { background: '#064e3b', surface: '#0f172a', border: '#34d399', text: '#d1fae5' };
+ case 'paused':
+ return { background: '#78350f', surface: '#111827', border: '#fbbf24', text: '#fef3c7' };
+ case 'exited':
+ case 'dead':
+ return { background: '#7f1d1d', surface: '#111827', border: '#f87171', text: '#fee2e2' };
+ default:
+ return { background: '#1e293b', surface: '#0f172a', border: '#94a3b8', text: '#e2e8f0' };
+ }
+ }
+
+ switch ((status ?? '').toLowerCase()) {
+ case 'running':
+ return { background: '#ecfdf5', surface: '#ffffff', border: '#10b981', text: '#065f46' };
+ case 'paused':
+ return { background: '#fffbeb', surface: '#ffffff', border: '#f59e0b', text: '#92400e' };
+ case 'exited':
+ case 'dead':
+ return { background: '#fef2f2', surface: '#ffffff', border: '#ef4444', text: '#991b1b' };
+ default:
+ return { background: '#f8fafc', surface: '#ffffff', border: '#64748b', text: '#334155' };
+ }
+ }
+
+ function nodeLabel(node: TopologyNodeDto): string {
+ if (node.type === 'network') {
+ const suffix = node.metadata.driver ? ` · ${node.metadata.driver}` : '';
+ return `${node.name}${suffix}`;
+ }
+
+ const status = node.metadata.status ? ` · ${node.metadata.status}` : '';
+ return `${node.name}${status}`;
+ }
+
+ function nodeTitle(node: TopologyNodeDto): string {
+ if (node.type === 'network') {
+ return [
+ node.name,
+ node.metadata.driver ? `Driver: ${node.metadata.driver}` : null,
+ node.metadata.scope ? `Scope: ${node.metadata.scope}` : null,
+ node.metadata.isDefault ? 'Default Docker network' : null
+ ]
+ .filter(Boolean)
+ .join('\n');
+ }
+
+ return [node.name, node.metadata.status ? `Status: ${node.metadata.status}` : null, node.metadata.image ?? null]
+ .filter(Boolean)
+ .join('\n');
+ }
+
+ function edgeLabel(edge: TopologyEdgeDto): string | undefined {
+ const labels = [edge.ipv4Address, edge.ipv6Address].filter(Boolean);
+ if (labels.length === 0) {
+ return undefined;
+ }
+ return labels.join(' | ');
+ }
+
+ function containerSourceMap(edges: TopologyEdgeDto[]): Map<string, string[]> {
+ const map = new Map<string, string[]>();
+ for (const edge of edges) {
+ const existing = map.get(edge.target) ?? [];
+ existing.push(edge.source);
+ map.set(edge.target, existing);
+ }
+ return map;
+ }
+
+ function buildContainerYPositions(
+ containers: TopologyNodeDto[],
+ edges: TopologyEdgeDto[],
+ networkY: Map<string, number>
+ ): Map<string, number> {
+ const positions = new Map<string, number>();
+ const sourcesByContainer = containerSourceMap(edges);
+ const staged = containers.map((node, index) => {
+ const sources = sourcesByContainer.get(node.id) ?? [];
+ const connectedY = sources.map((source) => networkY.get(source)).filter((value): value is number => value !== undefined);
+ const averageY =
+ connectedY.length > 0 ? connectedY.reduce((sum, value) => sum + value, 0) / connectedY.length : index * 180;
+
+ return {
+ node,
+ averageY
+ };
+ });
+
+ staged.sort((a, b) => a.averageY - b.averageY || a.node.name.localeCompare(b.node.name));
+
+ let lastY = -180;
+ for (const entry of staged) {
+ const nextY = Math.max(entry.averageY, lastY + 150);
+ positions.set(entry.node.id, nextY);
+ lastY = nextY;
+ }
+
+ return positions;
+ }
+
+ const diagramNodes = $derived.by<Node<DiagramNodeData>[]>(() => {
+ const networkY = new Map(networkNodes.map((node, index) => [node.id, index * 180]));
+ const containerY = buildContainerYPositions(containerNodes, topology.edges, networkY);
+
+ const graphNodes: Node<DiagramNodeData>[] = [];
+
+ for (const node of networkNodes) {
+ const palette = networkPalette(node.metadata.driver, isDarkMode);
+ graphNodes.push({
+ id: node.id,
+ position: { x: 40, y: networkY.get(node.id) ?? 0 },
+ sourcePosition: Position.Right,
+ targetPosition: Position.Left,
+ type: 'default',
+ class: 'arcane-topology-node arcane-topology-node-network',
+ style: [
+ 'width: 280px',
+ 'border-radius: 20px',
+ 'padding: 18px 20px',
+ `border: 1px solid ${palette.border}`,
+ `background: linear-gradient(135deg, ${palette.background}, ${palette.surface})`,
+ `color: ${palette.text}`,
+ `box-shadow: ${canvasTheme.nodeShadow}`,
+ 'font-size: 13px',
+ 'font-weight: 600'
+ ].join('; '),
+ data: {
+ href: `/networks/${node.id}`,
+ kind: 'network',
+ label: nodeLabel(node)
+ },
+ ariaLabel: nodeLabel(node),
+ domAttributes: {
+ title: nodeTitle(node)
+ }
+ });
+ }
+
+ for (const node of containerNodes) {
+ const palette = containerPalette(node.metadata.status, isDarkMode);
+ graphNodes.push({
+ id: node.id,
+ position: { x: 440, y: containerY.get(node.id) ?? 0 },
+ data: {
+ href: `/containers/${node.id}`,
+ kind: 'container',
+ label: nodeLabel(node)
+ },
+ sourcePosition: Position.Right,
+ targetPosition: Position.Left,
+ type: 'default',
+ class: 'arcane-topology-node arcane-topology-node-container',
+ style: [
+ 'width: 300px',
+ 'border-radius: 20px',
+ 'padding: 18px 20px',
+ `border: 1px solid ${palette.border}`,
+ `background: linear-gradient(135deg, ${palette.background}, ${palette.surface})`,
+ `color: ${palette.text}`,
+ `box-shadow: ${canvasTheme.nodeShadow}`,
+ 'font-size: 13px',
+ 'font-weight: 600'
+ ].join('; '),
+ ariaLabel: nodeLabel(node),
+ domAttributes: {
+ title: nodeTitle(node)
+ }
+ });
+ }
+
+ return graphNodes;
+ });
+
+ const diagramEdges = $derived.by<Edge[]>(() =>
+ topology.edges.map((edge) => ({
+ id: edge.id,
+ source: edge.source,
+ target: edge.target,
+ type: 'smoothstep',
+ label: edgeLabel(edge),
+ labelStyle: `fill: ${canvasTheme.edgeLabel}; font-size: 11px; font-weight: 600;`,
+ style: `stroke: ${canvasTheme.edgeStroke}; stroke-width: 1.5;`,
+ interactionWidth: 24,
+ selectable: false,
+ focusable: false
+ }))
+ );
+
+ function miniMapColor(node: Node): string {
+ const kind = (node.data as DiagramNodeData | undefined)?.kind;
+ if (kind === 'network') {
+ return '#7c3aed';
+ }
+ return '#10b981';
+ }
+
+ function handleNodeClick({ node }: { node: Node }) {
+ const href = (node.data as DiagramNodeData | undefined)?.href;
+ if (href) {
+ void goto(href);
+ }
+ }
+</script>
+
+<div class={cn('space-y-4', className)}>
+ <div class="flex flex-wrap items-center gap-2">
+ <StatusBadge text={m.networks_topology_legend_networks()} variant="violet" minWidth="none" />
+ <StatusBadge text={m.networks_topology_legend_containers()} variant="emerald" minWidth="none" />
+ <p class="text-muted-foreground text-sm">{m.networks_topology_hint()}</p>
+ </div>
+
+ {#if topology.nodes.length === 0}
+ <div class="bg-card border-border/70 rounded-3xl border px-6 py-16 text-center shadow-sm">
+ <p class="text-foreground text-base font-medium">{m.networks_topology_empty()}</p>
+ </div>
+ {:else if browser && isReady}
+ <div
+ class="network-diagram-shell overflow-hidden rounded-[28px] border"
+ style:--diagram-shell-background={canvasTheme.shellBackground}
+ style:--diagram-shell-border={canvasTheme.shellBorder}
+ style:--diagram-shell-shadow={canvasTheme.shellShadow}
+ style:--diagram-node-hover-shadow={canvasTheme.nodeHoverShadow}
+ style:--diagram-node-selected-shadow={canvasTheme.nodeSelectedShadow}
+ style:--diagram-controls-background={canvasTheme.controlsBackground}
+ style:--diagram-controls-foreground={canvasTheme.controlsForeground}
+ style:--diagram-controls-border={canvasTheme.controlsBorder}
+ style:--diagram-controls-shadow={canvasTheme.controlsShadow}
+ style:--diagram-flow-background={canvasTheme.flowBackground}
+ style:--diagram-edge-label-background={canvasTheme.edgeLabelBackground}
+ style:--diagram-minimap-border={canvasTheme.minimapBorder}
+ style:--diagram-minimap-shadow={canvasTheme.minimapShadow}
+ >
+ <SvelteFlow
+ nodes={diagramNodes}
+ edges={diagramEdges}
+ colorMode={isDarkMode ? 'dark' : 'light'}
+ fitView
+ minZoom={0.35}
+ maxZoom={1.75}
+ panOnScroll
+ panOnDrag
+ nodesDraggable={false}
+ nodesConnectable={false}
+ elementsSelectable
+ attributionPosition="bottom-left"
+ class="network-diagram-flow"
+ onnodeclick={handleNodeClick}
+ >
+ <Controls showLock={false} />
+ <MiniMap
+ bgColor={canvasTheme.minimapBackground}
+ maskColor={canvasTheme.minimapMask}
+ maskStrokeColor={canvasTheme.minimapMaskStroke}
+ nodeColor={miniMapColor}
+ nodeStrokeColor={miniMapColor}
+ />
+ <Background variant={BackgroundVariant.Dots} gap={18} size={1.2} bgColor={canvasTheme.backgroundDots} />
+ </SvelteFlow>
+ </div>
+ {/if}
+</div>
+
+<style>
+ .network-diagram-shell {
+ height: calc(100dvh - 12.5rem);
+ min-height: 36rem;
+ background: var(--diagram-shell-background);
+ border-color: var(--diagram-shell-border);
+ box-shadow: var(--diagram-shell-shadow);
+ }
+
+ :global(.network-diagram-flow .svelte-flow__renderer) {
+ background: transparent;
+ }
+
+ :global(.network-diagram-flow.svelte-flow) {
+ --xy-background-color: var(--diagram-flow-background);
+ --xy-edge-label-background-color: var(--diagram-edge-label-background);
+ background-color: var(--diagram-flow-background);
+ }
+
+ :global(.network-diagram-flow .svelte-flow__background) {
+ background-color: var(--diagram-flow-background) !important;
+ }
+
+ :global(.network-diagram-flow .svelte-flow__node.arcane-topology-node) {
+ cursor: pointer;
+ line-height: 1.45;
+ transition:
+ transform 180ms ease,
+ box-shadow 180ms ease,
+ border-color 180ms ease;
+ }
+
+ :global(.network-diagram-flow .svelte-flow__node.arcane-topology-node:hover) {
+ transform: translateY(-2px);
+ box-shadow: var(--diagram-node-hover-shadow);
+ }
+
+ :global(.network-diagram-flow .svelte-flow__node.arcane-topology-node.selected) {
+ box-shadow: var(--diagram-node-selected-shadow);
+ }
+
+ :global(.network-diagram-flow .svelte-flow__controls) {
+ border-radius: 18px;
+ overflow: hidden;
+ border: 1px solid var(--diagram-controls-border);
+ box-shadow: var(--diagram-controls-shadow);
+ }
+
+ :global(.network-diagram-flow .svelte-flow__controls-button) {
+ background: var(--diagram-controls-background);
+ color: var(--diagram-controls-foreground);
+ }
+
+ :global(.network-diagram-flow .svelte-flow__minimap) {
+ border-radius: 18px;
+ overflow: hidden;
+ border: 1px solid var(--diagram-minimap-border);
+ box-shadow: var(--diagram-minimap-shadow);
+ }
+</style>
diff --git a/frontend/src/lib/components/sidebar/sidebar-collapsible-item.svelte b/frontend/src/lib/components/sidebar/sidebar-collapsible-item.svelte
index c29caf0f3..d2cf1ea39 100644
--- a/frontend/src/lib/components/sidebar/sidebar-collapsible-item.svelte
+++ b/frontend/src/lib/components/sidebar/sidebar-collapsible-item.svelte
@@ -34,27 +34,27 @@
{/snippet}
<Collapsible.Root open={getIsOpen(item.title, item.isActive)} {onOpenChange} class="group/collapsible">
- {#snippet child({ props })}
- <Sidebar.MenuItem {...props}>
- <Collapsible.Trigger>
- {#snippet child()}
- {@const Icon = item.icon}
- <Sidebar.MenuButton tooltipContent={showTooltip ? tooltipContent : undefined} isActive={item.isActive}>
- {#snippet child({ props })}
- <a href={item.url} {...props}>
- {#if item.icon}
- <Icon />
- {/if}
- <span>{item.title}</span>
- <ArrowRightIcon class="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
- </a>
- {/snippet}
- </Sidebar.MenuButton>
- {/snippet}
- </Collapsible.Trigger>
- {#if content}
- {@render content()}
- {/if}
- </Sidebar.MenuItem>
- {/snippet}
+ <Sidebar.MenuItem class="flex-col">
+ {@const Icon = item.icon}
+ <Sidebar.MenuButton tooltipContent={showTooltip ? tooltipContent : undefined} isActive={item.isActive}>
+ {#snippet child({ props })}
+ <a href={item.url} {...props}>
+ {#if item.icon}
+ <Icon />
+ {/if}
+ <span>{item.title}</span>
+ </a>
+ {/snippet}
+ </Sidebar.MenuButton>
+ <Collapsible.Trigger>
+ {#snippet child({ props })}
+ <Sidebar.MenuAction {...props} aria-label="Toggle submenu" class="data-[state=open]:bg-sidebar-accent">
+ <ArrowRightIcon class="transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
+ </Sidebar.MenuAction>
+ {/snippet}
+ </Collapsible.Trigger>
+ {#if content}
+ {@render content()}
+ {/if}
+ </Sidebar.MenuItem>
</Collapsible.Root>
diff --git a/frontend/src/lib/config/navigation-config.ts b/frontend/src/lib/config/navigation-config.ts
index 6c8c96b38..5e1e73b1d 100644
--- a/frontend/src/lib/config/navigation-config.ts
+++ b/frontend/src/lib/config/navigation-config.ts
@@ -12,6 +12,7 @@ import {
ImagesIcon,
NetworksIcon,
VolumesIcon,
+ HashIcon,
DockIcon,
JobsIcon,
LayersIcon,
@@ -52,7 +53,16 @@ export const navigationItems: NavigationSections = {
resourceItems: [
{ title: m.containers_title(), url: '/containers', icon: ContainersIcon, shortcut: ['mod', '5'] },
{ title: m.images_title(), url: '/images', icon: ImagesIcon, shortcut: ['mod', '6'] },
- { title: m.networks_title(), url: '/networks', icon: NetworksIcon, shortcut: ['mod', '7'] },
+ {
+ title: m.networks_title(),
+ url: '/networks',
+ icon: NetworksIcon,
+ shortcut: ['mod', '7'],
+ items: [
+ { title: m.ports_title(), url: '/ports', icon: HashIcon },
+ { title: m.networks_topology_button(), url: '/networks/topology', icon: GitBranchIcon }
+ ]
+ },
{ title: m.volumes_title(), url: '/volumes', icon: VolumesIcon, shortcut: ['mod', '8'] }
],
deploymentItems: [{ title: m.builds(), url: '/images/builds', icon: HammerIcon, shortcut: ['mod', 'b'] }],
diff --git a/frontend/src/lib/query/query-keys.ts b/frontend/src/lib/query/query-keys.ts
index 7c4a96703..023bf8bb4 100644
--- a/frontend/src/lib/query/query-keys.ts
+++ b/frontend/src/lib/query/query-keys.ts
@@ -113,7 +113,13 @@ export const queryKeys = {
all: ['networks'] as const,
list: (environmentId: string, options: SearchPaginationSortRequest) =>
['networks', environmentId, stableSerialize(options)] as const,
- detail: (environmentId: string, networkId: string) => ['network', environmentId, networkId] as const
+ detail: (environmentId: string, networkId: string) => ['network', environmentId, networkId] as const,
+ topology: (environmentId: string) => ['networks', environmentId, 'topology'] as const
+ },
+ ports: {
+ all: ['ports'] as const,
+ list: (environmentId: string, options: SearchPaginationSortRequest) =>
+ ['ports', environmentId, stableSerialize(options)] as const
},
gitOpsSyncs: {
all: ['gitops-syncs'] as const,
diff --git a/frontend/src/lib/services/network-service.ts b/frontend/src/lib/services/network-service.ts
index cf91b6308..be827c9fd 100644
--- a/frontend/src/lib/services/network-service.ts
+++ b/frontend/src/lib/services/network-service.ts
@@ -5,7 +5,8 @@ import type {
NetworkUsageCounts,
NetworkCreateRequest,
NetworkCreateOptions,
- NetworkInspectDto
+ NetworkInspectDto,
+ NetworkTopologyDto
} from '$lib/types/network.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import { transformPaginationParams } from '$lib/utils/params.util';
@@ -51,6 +52,11 @@ export class NetworkService extends BaseAPIService {
return this.handleResponse(this.api.get(`/environments/${environmentId}/networks/${networkId}`, { params }));
}
+ async getNetworkTopology(environmentId?: string): Promise<NetworkTopologyDto> {
+ const envId = await this.resolveEnvironmentId(environmentId);
+ return this.handleResponse(this.api.get(`/environments/${envId}/networks/topology`));
+ }
+
async createNetwork(name: string, options: NetworkCreateOptions): Promise<any> {
const envId = await environmentStore.getCurrentEnvironmentId();
const request: NetworkCreateRequest = {
diff --git a/frontend/src/lib/services/port-service.ts b/frontend/src/lib/services/port-service.ts
new file mode 100644
index 000000000..0e57dc914
--- /dev/null
+++ b/frontend/src/lib/services/port-service.ts
@@ -0,0 +1,25 @@
+import BaseAPIService from './api-service';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
+import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
+import type { PortMappingDto } from '$lib/types/port.type';
+import { transformPaginationParams } from '$lib/utils/params.util';
+
+export type PortsPaginatedResponse = Paginated<PortMappingDto>;
+
+export class PortService extends BaseAPIService {
+ private async resolveEnvironmentId(environmentId?: string): Promise<string> {
+ return environmentId ?? (await environmentStore.getCurrentEnvironmentId());
+ }
+
+ async getPorts(options?: SearchPaginationSortRequest): Promise<PortsPaginatedResponse> {
+ const envId = await this.resolveEnvironmentId();
+ return this.getPortsForEnvironment(envId, options);
+ }
+
+ async getPortsForEnvironment(environmentId: string, options?: SearchPaginationSortRequest): Promise<PortsPaginatedResponse> {
+ const params = transformPaginationParams(options);
+ return this.handleResponse(this.api.get(`/environments/${environmentId}/ports`, { params }));
+ }
+}
+
+export const portService = new PortService();
diff --git a/frontend/src/lib/types/network.type.ts b/frontend/src/lib/types/network.type.ts
index fd2e33a27..469a2896b 100644
--- a/frontend/src/lib/types/network.type.ts
+++ b/frontend/src/lib/types/network.type.ts
@@ -113,3 +113,33 @@ export interface NetworkInspectDto {
peers?: PeerInfo[];
services?: Record<string, ServiceInfo>;
}
+
+export type TopologyNodeType = 'network' | 'container';
+
+export interface TopologyNodeMetadata {
+ driver?: string;
+ scope?: string;
+ status?: string;
+ image?: string;
+ isDefault?: boolean;
+}
+
+export interface TopologyNodeDto {
+ id: string;
+ name: string;
+ type: TopologyNodeType;
+ metadata: TopologyNodeMetadata;
+}
+
+export interface TopologyEdgeDto {
+ id: string;
+ source: string;
+ target: string;
+ ipv4Address?: string;
+ ipv6Address?: string;
+}
+
+export interface NetworkTopologyDto {
+ nodes: TopologyNodeDto[];
+ edges: TopologyEdgeDto[];
+}
diff --git a/frontend/src/lib/types/port.type.ts b/frontend/src/lib/types/port.type.ts
new file mode 100644
index 000000000..b4af1a04e
--- /dev/null
+++ b/frontend/src/lib/types/port.type.ts
@@ -0,0 +1,10 @@
+export interface PortMappingDto {
+ id: string;
+ containerId: string;
+ containerName: string;
+ hostIp?: string;
+ hostPort?: number;
+ containerPort: number;
+ protocol: string;
+ isPublished: boolean;
+}
diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelte
index be8ca50cb..0f15fd4aa 100644
--- a/frontend/src/routes/(app)/containers/container-table.svelte
+++ b/frontend/src/routes/(app)/containers/container-table.svelte
@@ -255,7 +255,7 @@
},
{ accessorKey: 'status', title: m.common_status() },
{ accessorKey: 'networkSettings', id: 'ipAddress', title: m.containers_ip_address(), sortable: false, cell: IPAddressCell },
- { accessorKey: 'ports', title: m.common_ports(), cell: PortsCell },
+ { accessorKey: 'ports', title: m.common_ports(), sortable: !groupByProject, cell: PortsCell },
{ accessorKey: 'created', title: m.common_created(), sortable: !groupByProject, cell: CreatedCell }
] satisfies ColumnSpec<ContainerSummaryDto>[]);
diff --git a/frontend/src/routes/(app)/networks/+page.svelte b/frontend/src/routes/(app)/networks/+page.svelte
index 6b492aaad..9df864405 100644
--- a/frontend/src/routes/(app)/networks/+page.svelte
+++ b/frontend/src/routes/(app)/networks/+page.svelte
@@ -1,5 +1,7 @@
<script lang="ts">
+ import { goto } from '$app/navigation';
import { NetworksIcon, ConnectionIcon } from '$lib/icons';
+ import { GitBranchIcon } from '$lib/icons';
import { toast } from 'svelte-sonner';
import type { NetworkCreateOptions, NetworkUsageCounts } from '$lib/types/network.type';
import CreateNetworkSheet from '$lib/components/sheets/create-network-sheet.svelte';
@@ -74,6 +76,13 @@
onclick: refresh,
loading: isRefreshing,
disabled: isRefreshing
+ },
+ {
+ id: 'topology',
+ action: 'inspect',
+ label: m.networks_topology_button(),
+ icon: GitBranchIcon,
+ onclick: () => void goto('/networks/topology')
}
]);
diff --git a/frontend/src/routes/(app)/networks/topology/+page.svelte b/frontend/src/routes/(app)/networks/topology/+page.svelte
new file mode 100644
index 000000000..e99844411
--- /dev/null
+++ b/frontend/src/routes/(app)/networks/topology/+page.svelte
@@ -0,0 +1,43 @@
+<script lang="ts">
+ import { createQuery } from '@tanstack/svelte-query';
+ import NetworkDiagram from '$lib/components/network-diagram/network-diagram.svelte';
+ import { queryKeys } from '$lib/query/query-keys';
+ import { ResourcePageLayout, type ActionButton } from '$lib/layouts/index.js';
+ import { m } from '$lib/paraglide/messages';
+ import { networkService } from '$lib/services/network-service';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
+
+ let { data } = $props();
+
+ const envId = $derived(environmentStore.selected?.id || '0');
+
+ const topologyQuery = createQuery(() => ({
+ queryKey: queryKeys.networks.topology(envId),
+ queryFn: () => networkService.getNetworkTopology(envId),
+ initialData: data.topology
+ }));
+ const topology = $derived(topologyQuery.data!);
+
+ async function refresh() {
+ await topologyQuery.refetch();
+ }
+
+ const isRefreshing = $derived(topologyQuery.isFetching && !topologyQuery.isPending);
+
+ const actionButtons: ActionButton[] = $derived([
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refresh,
+ loading: isRefreshing,
+ disabled: isRefreshing
+ }
+ ]);
+</script>
+
+<ResourcePageLayout title={m.networks_topology_title()} subtitle={m.networks_topology_subtitle()} {actionButtons}>
+ {#snippet mainContent()}
+ <NetworkDiagram {topology} />
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/(app)/networks/topology/+page.ts b/frontend/src/routes/(app)/networks/topology/+page.ts
new file mode 100644
index 000000000..6e9653562
--- /dev/null
+++ b/frontend/src/routes/(app)/networks/topology/+page.ts
@@ -0,0 +1,24 @@
+import { networkService } from '$lib/services/network-service';
+import { queryKeys } from '$lib/query/query-keys';
+import { throwPageLoadError } from '$lib/utils/page-load-error.util';
+import type { PageLoad } from './$types';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
+
+export const load: PageLoad = async ({ parent }) => {
+ const { queryClient } = await parent();
+ const envId = await environmentStore.getCurrentEnvironmentId();
+
+ let topology;
+ try {
+ topology = await queryClient.fetchQuery({
+ queryKey: queryKeys.networks.topology(envId),
+ queryFn: () => networkService.getNetworkTopology(envId)
+ });
+ } catch (err) {
+ throwPageLoadError(err, 'Failed to load network topology');
+ }
+
+ return {
+ topology
+ };
+};
diff --git a/frontend/src/routes/(app)/ports/+page.svelte b/frontend/src/routes/(app)/ports/+page.svelte
new file mode 100644
index 000000000..a50ad9e73
--- /dev/null
+++ b/frontend/src/routes/(app)/ports/+page.svelte
@@ -0,0 +1,55 @@
+<script lang="ts">
+ import { untrack } from 'svelte';
+ import { createQuery } from '@tanstack/svelte-query';
+ import { ResourcePageLayout, type ActionButton } from '$lib/layouts/index.js';
+ import { m } from '$lib/paraglide/messages';
+ import { portService } from '$lib/services/port-service';
+ import { environmentStore } from '$lib/stores/environment.store.svelte';
+ import { queryKeys } from '$lib/query/query-keys';
+ import PortTable from './port-table.svelte';
+
+ let { data } = $props();
+
+ let requestOptions = $state(untrack(() => data.portRequestOptions));
+ let selectedIds = $state<string[]>([]);
+
+ const envId = $derived(environmentStore.selected?.id || '0');
+
+ const portsQuery = createQuery(() => ({
+ queryKey: queryKeys.ports.list(envId, requestOptions),
+ queryFn: () => portService.getPortsForEnvironment(envId, requestOptions),
+ initialData: data.ports
+ }));
+ const ports = $derived(portsQuery.data!);
+
+ async function refresh() {
+ await portsQuery.refetch();
+ }
+
+ const isRefreshing = $derived(portsQuery.isFetching && !portsQuery.isPending);
+
+ const actionButtons: ActionButton[] = $derived([
+ {
+ id: 'refresh',
+ action: 'restart',
+ label: m.common_refresh(),
+ onclick: refresh,
+ loading: isRefreshing,
+ disabled: isRefreshing
+ }
+ ]);
+</script>
+
+<ResourcePageLayout title={m.ports_title()} subtitle={m.ports_subtitle()} {actionButtons}>
+ {#snippet mainContent()}
+ <PortTable
+ {ports}
+ bind:selectedIds
+ bind:requestOptions
+ onRefreshData={async (options) => {
+ requestOptions = options;
+ await portsQuery.refetch();
+ }}
+ />
+ {/snippet}
+</ResourcePageLayout>
diff --git a/frontend/src/routes/(app)/ports/+page.ts b/frontend/src/routes/(app)/ports/+page.ts
new file mode 100644
index 000000000..dcf725683
--- /dev/null
+++ b/frontend/src/routes/(app)/ports/+page.ts
@@ -0,0 +1,38 @@
+import { portService } from '$lib/services/port-service';
+import { queryKeys } from '$lib/query/query-keys';
+import type { SearchPaginationSortRequest } from '$lib/types/pagination.type';
+import { resolveInitialTableRequest } from '$lib/utils/table-persistence.util';
+import { throwPageLoadError } from '$lib/utils/page-load-error.util';
+import type { PageLoad } from './$types';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
+
+export const load: PageLoad = async ({ parent }) => {
+ const { queryClient } = await parent();
+ const envId = await environmentStore.getCurrentEnvironmentId();
+
+ const portRequestOptions = resolveInitialTableRequest('arcane-ports-table', {
+ pagination: {
+ page: 1,
+ limit: 20
+ },
+ sort: {
+ column: 'hostPort',
+ direction: 'asc'
+ }
+ } satisfies SearchPaginationSortRequest);
+
+ let ports;
+ try {
+ ports = await queryClient.fetchQuery({
+ queryKey: queryKeys.ports.list(envId, portRequestOptions),
+ queryFn: () => portService.getPortsForEnvironment(envId, portRequestOptions)
+ });
+ } catch (err) {
+ throwPageLoadError(err, 'Failed to load ports');
+ }
+
+ return {
+ ports,
+ portRequestOptions
+ };
+};
diff --git a/frontend/src/routes/(app)/ports/port-table.svelte b/frontend/src/routes/(app)/ports/port-table.svelte
new file mode 100644
index 000000000..89f79c918
--- /dev/null
+++ b/frontend/src/routes/(app)/ports/port-table.svelte
@@ -0,0 +1,179 @@
+<script lang="ts">
+ import { goto } from '$app/navigation';
+ import ArcaneTable from '$lib/components/arcane-table/arcane-table.svelte';
+ import StatusBadge from '$lib/components/badges/status-badge.svelte';
+ import { UniversalMobileCard } from '$lib/components/arcane-table';
+ import type { ColumnSpec, MobileFieldVisibility } from '$lib/components/arcane-table';
+ import { ContainersIcon, ConnectionIcon, GlobeIcon, HashIcon } from '$lib/icons';
+ import { m } from '$lib/paraglide/messages';
+ import { portService } from '$lib/services/port-service';
+ import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
+ import type { PortMappingDto } from '$lib/types/port.type';
+
+ let {
+ ports,
+ selectedIds = $bindable(),
+ requestOptions = $bindable(),
+ onRefreshData
+ }: {
+ ports: Paginated<PortMappingDto>;
+ selectedIds: string[];
+ requestOptions: SearchPaginationSortRequest;
+ onRefreshData?: (options: SearchPaginationSortRequest) => Promise<void>;
+ } = $props();
+
+ let mobileFieldVisibility = $state<Record<string, boolean>>({});
+
+ function formatHostPort(port: PortMappingDto): string {
+ return port.isPublished && port.hostPort ? String(port.hostPort) : m.ports_no_host_binding();
+ }
+
+ function formatHostIp(port: PortMappingDto): string {
+ if (!port.isPublished) {
+ return m.ports_no_host_binding();
+ }
+ return port.hostIp?.trim() || '0.0.0.0';
+ }
+
+ function mappingTitle(port: PortMappingDto): string {
+ if (port.isPublished && port.hostPort) {
+ return `${port.hostPort} -> ${port.containerPort}`;
+ }
+ return `${port.containerPort}/${port.protocol}`;
+ }
+
+ async function refreshPorts(options: SearchPaginationSortRequest = requestOptions): Promise<Paginated<PortMappingDto> | void> {
+ if (onRefreshData) {
+ await onRefreshData(options);
+ return;
+ }
+ return await portService.getPorts(options);
+ }
+
+ const columns = [
+ { accessorKey: 'hostPort', title: m.ports_host_port(), sortable: true, cell: HostPortCell },
+ { accessorKey: 'containerPort', title: m.ports_container_port(), sortable: true, cell: ContainerPortCell },
+ { accessorKey: 'protocol', title: m.common_type(), sortable: true, cell: ProtocolCell },
+ { accessorKey: 'containerName', title: m.ports_container_name(), sortable: true, cell: ContainerCell },
+ { accessorKey: 'hostIp', title: m.ports_host_ip(), sortable: true, cell: HostIpCell },
+ { accessorKey: 'isPublished', title: m.common_status(), sortable: true, cell: PublishedCell }
+ ] satisfies ColumnSpec<PortMappingDto>[];
+
+ const mobileFields = [
+ { id: 'hostPort', label: m.ports_host_port(), defaultVisible: true },
+ { id: 'containerPort', label: m.ports_container_port(), defaultVisible: true },
+ { id: 'protocol', label: m.common_type(), defaultVisible: true },
+ { id: 'containerName', label: m.ports_container_name(), defaultVisible: true },
+ { id: 'hostIp', label: m.ports_host_ip(), defaultVisible: true },
+ { id: 'isPublished', label: m.common_status(), defaultVisible: true }
+ ];
+</script>
+
+{#snippet HostPortCell({ item }: { item: PortMappingDto })}
+ <span class:text-muted-foreground={!item.isPublished} class="font-mono text-sm">
+ {formatHostPort(item)}
+ </span>
+{/snippet}
+
+{#snippet ContainerPortCell({ item }: { item: PortMappingDto })}
+ <span class="font-mono text-sm">{item.containerPort}</span>
+{/snippet}
+
+{#snippet ProtocolCell({ item }: { item: PortMappingDto })}
+ <StatusBadge text={item.protocol.toUpperCase()} variant="gray" minWidth="none" />
+{/snippet}
+
+{#snippet ContainerCell({ item }: { item: PortMappingDto })}
+ <a class="font-medium hover:underline" href="/containers/{item.containerId}">
+ {item.containerName}
+ </a>
+{/snippet}
+
+{#snippet HostIpCell({ item }: { item: PortMappingDto })}
+ <span class:text-muted-foreground={!item.isPublished} class="font-mono text-sm">
+ {formatHostIp(item)}
+ </span>
+{/snippet}
+
+{#snippet PublishedCell({ item }: { item: PortMappingDto })}
+ <StatusBadge
+ text={item.isPublished ? m.ports_published_label() : m.ports_exposed_label()}
+ variant={item.isPublished ? 'sky' : 'gray'}
+ minWidth="none"
+ />
+{/snippet}
+
+{#snippet PortMobileCardSnippet({
+ item,
+ mobileFieldVisibility
+}: {
+ item: PortMappingDto;
+ mobileFieldVisibility: MobileFieldVisibility;
+})}
+ <UniversalMobileCard
+ {item}
+ icon={(item: PortMappingDto) => ({
+ component: item.isPublished ? ConnectionIcon : HashIcon,
+ variant: item.isPublished ? 'blue' : 'gray'
+ })}
+ title={(item: PortMappingDto) => mappingTitle(item)}
+ subtitle={(item: PortMappingDto) => ((mobileFieldVisibility.containerName ?? true) ? item.containerName : null)}
+ badges={[
+ (item: PortMappingDto) =>
+ (mobileFieldVisibility.isPublished ?? true)
+ ? {
+ variant: item.isPublished ? 'sky' : 'gray',
+ text: item.isPublished ? m.ports_published_label() : m.ports_exposed_label()
+ }
+ : null
+ ]}
+ fields={[
+ {
+ label: m.ports_container_port(),
+ getValue: (item: PortMappingDto) => String(item.containerPort),
+ icon: HashIcon,
+ iconVariant: 'gray' as const,
+ show: mobileFieldVisibility.containerPort ?? true
+ },
+ {
+ label: m.common_type(),
+ getValue: (item: PortMappingDto) => item.protocol.toUpperCase(),
+ icon: ConnectionIcon,
+ iconVariant: 'gray' as const,
+ type: 'badge' as const,
+ badgeVariant: 'gray' as const,
+ show: mobileFieldVisibility.protocol ?? true
+ },
+ {
+ label: m.ports_host_ip(),
+ getValue: (item: PortMappingDto) => formatHostIp(item),
+ icon: GlobeIcon,
+ iconVariant: 'gray' as const,
+ show: mobileFieldVisibility.hostIp ?? true
+ },
+ {
+ label: m.ports_container_name(),
+ getValue: (item: PortMappingDto) => item.containerName,
+ icon: ContainersIcon,
+ iconVariant: 'gray' as const,
+ show: mobileFieldVisibility.containerName ?? true
+ }
+ ]}
+ onclick={() => void goto(`/containers/${item.containerId}`)}
+ />
+{/snippet}
+
+<ArcaneTable
+ persistKey="arcane-ports-table"
+ items={ports}
+ bind:requestOptions
+ bind:selectedIds
+ bind:mobileFieldVisibility
+ onRefresh={async (options) => {
+ requestOptions = options;
+ return (await refreshPorts(options)) ?? ports;
+ }}
+ {columns}
+ {mobileFields}
+ mobileCard={PortMobileCardSnippet}
+/>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e26c459c2..8c3d9812b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -119,6 +119,9 @@ importers:
'@xterm/xterm':
specifier: ^6.0.0
version: 6.0.0
+ '@xyflow/svelte':
+ specifier: ^1.5.2
+ version: 1.5.2([email protected])
ajv:
specifier: '>=8.18.0'
version: 8.18.0
@@ -2039,6 +2042,11 @@ packages:
cpu: [x64]
os: [win32]
+ '@svelte-put/[email protected]':
+ resolution: {integrity: sha512-wImNEIkbxAIWFqlfuhcbC+jRPDeRa/uJGIXHMEVVD+jqL9xCwWNnkGQJ6Qb2XVszuRLHlb8SGZDL3Io/h3vs8w==}
+ peerDependencies:
+ svelte: ^5.1.0
+
'@sveltejs/[email protected]':
resolution: {integrity: sha512-lVJX6qEgs/4DOcRTpo56tmKzVPtoWAaVbL4hfO7t7NVwl9AAXzQR6cihesW1BmNMPl+bK6dreu2sOKBP2Q9CIA==}
peerDependencies:
@@ -2211,6 +2219,24 @@ packages:
resolution: {integrity: sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==}
+
+ '@types/[email protected]':
+ resolution: {integrity: sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw==}
+
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
@@ -2368,6 +2394,14 @@ packages:
resolution: {integrity: sha512-TQwDdQGtwwDt+2cgKDLn0IRaSxYu1tSUjgKarSDkUM0ZNiSRXFpjxEsvc/Zgc5kq5omJ+V0a8/kIM2WD3sMOYg==}
+ '@xyflow/[email protected]':
+ resolution: {integrity: sha512-jPLc2cwRmrkXSv/jvsNDQqTGCsNyTWURKtBl28UCH3BdOAA3CIc0/oQ0EvIcjPdzr0NwvWMgq9TmLdjOIccCEQ==}
+ peerDependencies:
+ svelte: ^5.25.0
+
+ '@xyflow/[email protected]':
+ resolution: {integrity: sha512-hvwvnRS1B3REwVDlWexsq7YQaPZeG3/mKo1jv38UmnpWmxihp14bW6VtEOuHEwJX2FvzFw8k77LyKSk/wiZVNA==}
+
resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==}
engines: {node: '>= 0.6'}
@@ -2613,6 +2647,44 @@ packages:
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
+ resolution: {integrity: sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==}
+ engines: {node: '>=12'}
+
+ resolution: {integrity: sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==}
+ engines: {node: '>=12'}
+ peerDependencies:
+ d3-selection: 2 - 3
+
+ resolution: {integrity: sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==}
+ engines: {node: '>=12'}
+
resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==}
engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}
@@ -5517,6 +5589,10 @@ snapshots:
'@svelte-check-rs/[email protected]':
optional: true
+ dependencies:
+ svelte: 5.55.0
+
dependencies:
acorn: 8.16.0
@@ -5668,6 +5744,27 @@ snapshots:
dependencies:
'@types/node': 25.5.0
+ '@types/[email protected]': {}
+
+ '@types/[email protected]':
+ dependencies:
+ '@types/d3-selection': 3.0.11
+
+ '@types/[email protected]':
+ dependencies:
+ '@types/d3-color': 3.1.3
+
+ '@types/[email protected]': {}
+
+ '@types/[email protected]':
+ dependencies:
+ '@types/d3-selection': 3.0.11
+
+ '@types/[email protected]':
+ dependencies:
+ '@types/d3-interpolate': 3.0.4
+ '@types/d3-selection': 3.0.11
+
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -5830,6 +5927,24 @@ snapshots:
'@xterm/[email protected]': {}
+ dependencies:
+ '@svelte-put/shortcut': 4.1.0([email protected])
+ '@xyflow/system': 0.0.76
+ svelte: 5.55.0
+
+ '@xyflow/[email protected]':
+ dependencies:
+ '@types/d3-drag': 3.0.7
+ '@types/d3-interpolate': 3.0.4
+ '@types/d3-selection': 3.0.11
+ '@types/d3-transition': 3.0.9
+ '@types/d3-zoom': 3.0.8
+ d3-drag: 3.0.0
+ d3-interpolate: 3.0.1
+ d3-selection: 3.0.0
+ d3-zoom: 3.0.0
+
dependencies:
mime-types: 2.1.35
@@ -6073,6 +6188,42 @@ snapshots:
+
+
+ dependencies:
+ d3-dispatch: 3.0.1
+ d3-selection: 3.0.0
+
+
+ dependencies:
+ d3-color: 3.1.0
+
+
+
+ dependencies:
+ d3-color: 3.1.0
+ d3-dispatch: 3.0.1
+ d3-ease: 3.0.1
+ d3-interpolate: 3.0.1
+ d3-selection: 3.0.0
+ d3-timer: 3.0.1
+
+ dependencies:
+ d3-dispatch: 3.0.1
+ d3-drag: 3.0.0
+ d3-interpolate: 3.0.1
+ d3-selection: 3.0.0
+ d3-transition: 3.0.1([email protected])
+
dependencies:
whatwg-mimetype: 5.0.0
diff --git a/types/network/topology.go b/types/network/topology.go
new file mode 100644
index 000000000..07c4c9577
--- /dev/null
+++ b/types/network/topology.go
@@ -0,0 +1,77 @@
+package network
+
+type TopologyNodeType string
+
+const (
+ TopologyNodeTypeNetwork TopologyNodeType = "network"
+ TopologyNodeTypeContainer TopologyNodeType = "container"
+)
+
+type TopologyNodeMetadata struct {
+ Driver string `json:"driver,omitempty"`
+ Scope string `json:"scope,omitempty"`
+ Status string `json:"status,omitempty"`
+ Image string `json:"image,omitempty"`
+ IsDefault bool `json:"isDefault,omitempty"`
+}
+
+type TopologyNode struct {
+ // ID is the unique node identifier.
+ //
+ // Required: true
+ ID string `json:"id"`
+
+ // Name is the display label for the node.
+ //
+ // Required: true
+ Name string `json:"name"`
+
+ // Type distinguishes network and container nodes.
+ //
+ // Required: true
+ Type TopologyNodeType `json:"type"`
+
+ // Metadata carries additional node context used by the UI.
+ //
+ // Required: true
+ Metadata TopologyNodeMetadata `json:"metadata"`
+}
+
+type TopologyEdge struct {
+ // ID is the unique edge identifier.
+ //
+ // Required: true
+ ID string `json:"id"`
+
+ // Source is the network node ID.
+ //
+ // Required: true
+ Source string `json:"source"`
+
+ // Target is the container node ID.
+ //
+ // Required: true
+ Target string `json:"target"`
+
+ // IPv4Address is the assigned IPv4 address on the network.
+ //
+ // Required: false
+ IPv4Address string `json:"ipv4Address,omitempty"`
+
+ // IPv6Address is the assigned IPv6 address on the network.
+ //
+ // Required: false
+ IPv6Address string `json:"ipv6Address,omitempty"`
+}
+
+type Topology struct {
+ // Nodes contains all topology nodes.
+ //
+ // Required: true
+ Nodes []TopologyNode `json:"nodes"`
+
+ // Edges contains all topology edges.
+ //
+ // Required: true
+ Edges []TopologyEdge `json:"edges"`
+}
diff --git a/types/port/port.go b/types/port/port.go
new file mode 100644
index 000000000..7c401e716
--- /dev/null
+++ b/types/port/port.go
@@ -0,0 +1,43 @@
+package port
+
+type PortMapping struct {
+ // ID is the stable unique identifier for the mapping row.
+ //
+ // Required: true
+ ID string `json:"id"`
+
+ // ContainerID is the owning container ID.
+ //
+ // Required: true
+ ContainerID string `json:"containerId"`
+
+ // ContainerName is the primary container name.
+ //
+ // Required: true
+ ContainerName string `json:"containerName"`
+
+ // HostIP is the host interface IP when the port is published.
+ //
+ // Required: false
+ HostIP string `json:"hostIp,omitempty"`
+
+ // HostPort is the published port on the host.
+ //
+ // Required: false
+ HostPort int `json:"hostPort,omitempty"`
+
+ // ContainerPort is the exposed port inside the container.
+ //
+ // Required: true
+ ContainerPort int `json:"containerPort"`
+
+ // Protocol is the transport protocol.
+ //
+ // Required: true
+ Protocol string `json:"protocol"`
+
+ // IsPublished indicates whether the port is bound on the host.
+ //
+ // Required: true
+ IsPublished bool `json:"isPublished"`
+}