# azukaar/cosmos-server architecture

> Architecture diagram of the GitHub repository azukaar/cosmos-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azukaar/cosmos-server
- Repository: https://github.com/azukaar/cosmos-server

## Overview

Cosmos is a self-hosted server manager and secure gateway. A typical user enters the authenticated web UI, selects an operational area, and uses its API client to manage server services. The repository documents app-store installs, containers, routing and SmartShield protections, authentication, storage and remote storage, backups, monitoring, VPN, and scheduled jobs. The graph includes these major product areas, plus shared API handling and server startup. Some backend components are documented or listed in startup wiring but their internal calls were not sampled; those relationships are shown only where supported or marked unverified.

Main entry points: [`src/index.go`](https://github.com/azukaar/cosmos-server/blob/master/src/index.go) (Cosmos server), [`client/src/api/index.tsx`](https://github.com/azukaar/cosmos-server/blob/master/client/src/api/index.tsx) (API facade), [`client/src/routes/MainRoutes.jsx`](https://github.com/azukaar/cosmos-server/blob/master/client/src/routes/MainRoutes.jsx) (Protected routes), [`client/src/App.jsx`](https://github.com/azukaar/cosmos-server/blob/master/client/src/App.jsx) (Cosmos UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_webapp["Cosmos UI<br/>[App.jsx]"]
  node_routes["Protected routes<br/>[MainRoutes.jsx]"]
  node_home["Home and app store<br/>[index.jsx]"]
  node_containerui["Container manager<br/>[newServiceForm.jsx]"]
  node_configui["Route security UI<br/>[routeSecurity.jsx]"]
  node_dashboard["Monitoring UI<br/>[index.jsx]"]
end

subgraph group_api["API client"]
  node_apifacade["API facade<br/>[index.tsx]"]
  node_apiwrap["Response handling<br/>[wrap.ts]"]
  node_dockerapi["Docker API<br/>[docker.tsx]"]
  node_storageapi["Storage API<br/>[storage.tsx]"]
  node_backupapi["Backup API<br/>[backup.ts]"]
end

subgraph group_management["Server management"]
  node_server["Cosmos server<br/>[index.go]"]
  node_authentication["Authentication"]
  node_containers["Container operations"]
  node_appmarket["App store"]
  node_backup["Backups"]
  node_storage["Storage manager"]
  node_cron["Scheduled jobs"]
  node_metrics["Monitoring and alerts"]
  node_constellation["VPN and constellation"]
end

subgraph group_platform["Gateway and platform"]
  node_proxy["Reverse proxy"]
  node_configroutes["Route configuration<br/>[routes.go]"]
end

node_operator(("Server operator"))
node_restic["Restic"]

node_operator -->|"uses"| node_webapp
node_webapp -->|"loads routes"| node_routes
node_routes -->|"routes to"| node_home
node_routes -->|"routes to"| node_containerui
node_routes -->|"routes to"| node_configui
node_routes -->|"routes to"| node_dashboard
node_home -.->|"uses API"| node_apifacade
node_containerui -->|"uses API"| node_apifacade
node_configui -->|"uses API"| node_apifacade
node_apifacade -->|"wraps responses"| node_apiwrap
node_apifacade -->|"creates client"| node_dockerapi
node_apifacade -->|"creates client"| node_storageapi
node_apifacade -->|"creates client"| node_backupapi
node_apifacade -.->|"sends API requests"| node_server
node_server -->|"initializes"| node_containers
node_server -->|"initializes"| node_appmarket
node_server -->|"initializes"| node_backup
node_server -->|"initializes"| node_storage
node_server -->|"initializes"| node_cron
node_server -->|"initializes"| node_metrics
node_server -->|"initializes"| node_constellation
node_server -->|"initializes"| node_proxy
node_server -.->|"initializes"| node_authentication
node_server -.->|"serves routes"| node_configroutes
node_configroutes -.->|"configures routes"| node_proxy
node_backup -->|"uses"| node_restic

click node_webapp "https://github.com/azukaar/cosmos-server/blob/master/client/src/App.jsx"
click node_routes "https://github.com/azukaar/cosmos-server/blob/master/client/src/routes/MainRoutes.jsx"
click node_home "https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/home/index.jsx"
click node_containerui "https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/servapps/containers/newServiceForm.jsx"
click node_configui "https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/config/routes/routeSecurity.jsx"
click node_dashboard "https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/dashboard/index.jsx"
click node_apifacade "https://github.com/azukaar/cosmos-server/blob/master/client/src/api/index.tsx"
click node_apiwrap "https://github.com/azukaar/cosmos-server/blob/master/client/src/api/wrap.ts"
click node_dockerapi "https://github.com/azukaar/cosmos-server/blob/master/client/src/api/docker.tsx"
click node_storageapi "https://github.com/azukaar/cosmos-server/blob/master/client/src/api/storage.tsx"
click node_backupapi "https://github.com/azukaar/cosmos-server/blob/master/client/src/api/backup.ts"
click node_server "https://github.com/azukaar/cosmos-server/blob/master/src/index.go"
click node_authentication "https://github.com/azukaar/cosmos-server/tree/master/src/user"
click node_containers "https://github.com/azukaar/cosmos-server/tree/master/src/docker"
click node_appmarket "https://github.com/azukaar/cosmos-server/tree/master/src/market"
click node_backup "https://github.com/azukaar/cosmos-server/tree/master/src/backups"
click node_storage "https://github.com/azukaar/cosmos-server/tree/master/src/storage"
click node_cron "https://github.com/azukaar/cosmos-server/tree/master/src/cron"
click node_metrics "https://github.com/azukaar/cosmos-server/tree/master/src/metrics"
click node_constellation "https://github.com/azukaar/cosmos-server/tree/master/src/constellation"
click node_proxy "https://github.com/azukaar/cosmos-server/tree/master/src/proxy"
click node_configroutes "https://github.com/azukaar/cosmos-server/blob/master/src/configapi/routes.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_routes,node_home,node_containerui,node_configui,node_dashboard toneBlue
class node_apifacade,node_apiwrap,node_dockerapi,node_storageapi,node_backupapi toneAmber
class node_server,node_authentication,node_containers,node_appmarket,node_backup,node_storage,node_cron,node_metrics,node_constellation,node_operator toneMint
class node_proxy,node_configroutes toneRose
class node_restic toneIndigo
```

## Components

### Web interface

- [Cosmos UI](https://github.com/azukaar/cosmos-server/blob/master/client/src/App.jsx): `client/src/App.jsx`
- [Protected routes](https://github.com/azukaar/cosmos-server/blob/master/client/src/routes/MainRoutes.jsx): `client/src/routes/MainRoutes.jsx`
- [Home and app store](https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/home/index.jsx): `client/src/pages/home/index.jsx`
- [Container manager](https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/servapps/containers/newServiceForm.jsx): `client/src/pages/servapps/containers/newServiceForm.jsx`
- [Route security UI](https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/config/routes/routeSecurity.jsx): `client/src/pages/config/routes/routeSecurity.jsx`
- [Monitoring UI](https://github.com/azukaar/cosmos-server/blob/master/client/src/pages/dashboard/index.jsx): `client/src/pages/dashboard/index.jsx`

### API client

- [API facade](https://github.com/azukaar/cosmos-server/blob/master/client/src/api/index.tsx): `client/src/api/index.tsx`
- [Response handling](https://github.com/azukaar/cosmos-server/blob/master/client/src/api/wrap.ts): `client/src/api/wrap.ts`
- [Docker API](https://github.com/azukaar/cosmos-server/blob/master/client/src/api/docker.tsx): `client/src/api/docker.tsx`
- [Storage API](https://github.com/azukaar/cosmos-server/blob/master/client/src/api/storage.tsx): `client/src/api/storage.tsx`
- [Backup API](https://github.com/azukaar/cosmos-server/blob/master/client/src/api/backup.ts): `client/src/api/backup.ts`

### Server management

- [Cosmos server](https://github.com/azukaar/cosmos-server/blob/master/src/index.go): `src/index.go`
- [Authentication](https://github.com/azukaar/cosmos-server/tree/master/src/user): `src/user`
- [Container operations](https://github.com/azukaar/cosmos-server/tree/master/src/docker): `src/docker`
- [App store](https://github.com/azukaar/cosmos-server/tree/master/src/market): `src/market`
- [Backups](https://github.com/azukaar/cosmos-server/tree/master/src/backups): `src/backups`
- [Storage manager](https://github.com/azukaar/cosmos-server/tree/master/src/storage): `src/storage`
- [Scheduled jobs](https://github.com/azukaar/cosmos-server/tree/master/src/cron): `src/cron`
- [Monitoring and alerts](https://github.com/azukaar/cosmos-server/tree/master/src/metrics): `src/metrics`
- [VPN and constellation](https://github.com/azukaar/cosmos-server/tree/master/src/constellation): `src/constellation`

### Gateway and platform

- [Reverse proxy](https://github.com/azukaar/cosmos-server/tree/master/src/proxy): `src/proxy`
- [Route configuration](https://github.com/azukaar/cosmos-server/blob/master/src/configapi/routes.go): `src/configapi/routes.go`

### Other components

- **Server operator**
- **Restic**

## Connections

- Server operator → Cosmos UI: uses
- Cosmos UI → Protected routes: loads routes (evidence: `client/src/App.jsx`)
- Protected routes → Home and app store: routes to (evidence: `client/src/routes/MainRoutes.jsx`)
- Protected routes → Container manager: routes to (evidence: `client/src/routes/MainRoutes.jsx`)
- Protected routes → Route security UI: routes to (evidence: `client/src/routes/MainRoutes.jsx`)
- Protected routes → Monitoring UI: routes to (evidence: `client/src/routes/MainRoutes.jsx`)
- Home and app store → API facade: uses API
- Container manager → API facade: uses API (evidence: `client/src/pages/servapps/containers/newServiceForm.jsx`)
- Route security UI → API facade: uses API (evidence: `client/src/pages/config/routes/routeSecurity.jsx`)
- API facade → Response handling: wraps responses (evidence: `client/src/api/index.tsx`)
- API facade → Docker API: creates client (evidence: `client/src/api/index.tsx`)
- API facade → Storage API: creates client (evidence: `client/src/api/index.tsx`)
- API facade → Backup API: creates client (evidence: `client/src/api/index.tsx`)
- API facade → Cosmos server: sends API requests
- Cosmos server → Container operations: initializes (evidence: `src/index.go`)
- Cosmos server → App store: initializes (evidence: `src/index.go`)
- Cosmos server → Backups: initializes (evidence: `src/index.go`)
- Cosmos server → Storage manager: initializes (evidence: `src/index.go`)
- Cosmos server → Scheduled jobs: initializes (evidence: `src/index.go`)
- Cosmos server → Monitoring and alerts: initializes (evidence: `src/index.go`)
- Cosmos server → VPN and constellation: initializes (evidence: `src/index.go`)
- Cosmos server → Reverse proxy: initializes (evidence: `src/index.go`)
- Cosmos server → Authentication: initializes
- Cosmos server → Route configuration: serves routes
- Route configuration → Reverse proxy: configures routes
- Backups → Restic: uses
