# 12ali26/nexusos architecture

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

- Interactive diagram: https://gitdiagram.com/12ali26/nexusos
- Repository: https://github.com/12ali26/nexusos

## Overview

1. **What this repo is**
   - CasaOS is a split backend + frontend system for a “personal cloud” appliance.
   - The Go backend is the system daemon and API server; the `UI/` directory is a separate Vue-based single-page admin interface.
   - The product spans storage/file management, app/service management, system settings, and integrations for home-server use cases.

2. **Top-level runtime boundary**
   - The Go service is the authoritative backend runtime. It exposes versioned APIs under `route/v1` and `route/v2`, plus periodic/background routes and health endpoints.
   - The UI talks to the backend through service wrappers in `UI/src/service/*`, with state coordination handled in `UI/src/store/*`.
   - This cleanly separates presentation, API transport, and server-side state.

3. **Backend application structure**
   - `main.go`, `route/*`, `service/*`, and `model/*` form the core application layer.
   - `route/` is the HTTP surface: request routing, versioning, and endpoint grouping.
   - `service/` contains domain orchestration for files, storage, shares, system info, health, notifications, peers, and sockets.
   - `model/` defines request/response payloads and persistent domain objects used across the API boundary.

4. **Domain-focused backend subsystems**
   - File and storage handling is a major subsystem: `service/file.go`, `service/storage.go`, `route/v1/file.go`, `route/v2/file.go`, and related models.
   - System operations live in `service/system.go`, `service/health.go`, `route/v2/health.go`, and `route/v1/system.go`.
   - Collaboration and sharing features are represented by `service/shares.go`, `service/rely.go`, `service/peer.go`, and the `types/` package.

5. **External integrations and drivers**
   - The repo includes pluggable cloud-storage drivers under `drivers/` for Dropbox, Google Drive, and OneDrive.
   - There are additional integration surfaces for Samba, DDNS, ZeroTier, SSH, and cloud/file operations through helpers in `pkg/utils/httper` and `pkg/ddns`.
   - This suggests the backend acts as an orchestrator over local disk, network services, and remote storage providers rather than a single-purpose app.

6. **State, persistence, and infrastructure helpers**
   - Persistent/configuration concerns are isolated in `pkg/config`, `internal/conf`, `pkg/sqlite`, and `pkg/cache`.
   - `pkg/gredis` and `pkg/singleflight` support shared infrastructure patterns, while `pkg/sign` and `internal/sign` handle request/auth signing.
   - Utility packages cover file IO, networking, path handling, versioning, IP detection, and OS-level helpers.

7. **Frontend architecture**
   - `UI/` is a large Vue application with a component-heavy structure for apps, file browser, storage, settings, widgets, and account views.
   - `UI/src/views` provides the page-level entry points, while `UI/src/components/*` contains most UI composition.
   - The frontend is organized around product areas: app store/app management, file browsing, storage management, logs/terminal, widgets, and settings.

8. **Frontend-to-backend data flow**
   - The UI’s `service/` layer mirrors backend domains: `apps.js`, `file.js`, `storage.js`, `container.js`, `users.js`, `samba.js`, `sys.js`, and others.
   - Components call these service wrappers, which centralize API access and keep view components mostly presentation-focused.
   - Global app state is shared through the Vue store, and route transitions are managed via `UI/src/router`.

9. **Eventing and cross-component coordination**
   - The UI includes an explicit message bus in `UI/src/events/message_bus.js`, with event definitions in `UI/src/events/events.js`.
   - This indicates some interactions are decoupled from direct parent-child component props, especially for shell-like areas such as file browsing, uploads, and app panels.
   - Backend-side `service/socket.go` and notification-related models suggest live updates or push-style communication for selected workflows.

10. **Installer, packaging, and system integration**
   - `scripts/`, `build/`, and `build/sysroot` show this is packaged for OS-level installation, not just shipped as an app binary.
   - There are systemd unit files, setup/migration scripts, and OS-specific installers for Debian and Ubuntu variants.
   - The repo also includes release tooling (`goreleaser`, GitHub Actions) and a generated OpenAPI contract under `api/casaos/openapi.yaml`.

11. **Operational workflows**
   - The backend has explicit health, notification, recovery, and periodic job routes, which implies ongoing device management rather than just request/response APIs.
   - The UI includes widgets for CPU, disks, network, and clock, reflecting the backend’s role as a system dashboard.
   - App lifecycle, file transfers, and storage management appear to be the primary operational flows exposed to the user.

12. **How to draw the architecture**
   - At the center place the Go daemon/API server, split into route → service → model/storage/driver layers.
   - On the side place the Vue UI as a separate client that consumes the API and subscribes to events/messages.
   - Attach external boundaries for local OS services, filesystem/storage, Samba/SSH, Docker/app runtime concerns, and remote cloud-storage providers.

Main entry points: [`service/service.go`](https://github.com/12ali26/nexusos/blob/main/service/service.go) (Domain services), [`UI/src/App.vue`](https://github.com/12ali26/nexusos/blob/main/UI/src/App.vue) (Admin UI), [`main.go`](https://github.com/12ali26/nexusos/blob/main/main.go) (Daemon entry), [`route/v2.go`](https://github.com/12ali26/nexusos/blob/main/route/v2.go) (API v2)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Go backend"]
  node_main(("Daemon entry<br/>go entrypoint<br/>[main.go]"))
  node_routev1["API v1<br/>http routes<br/>[v1.go]"]
  node_routev2["API v2<br/>http routes<br/>[v2.go]"]
  node_periodical["Jobs<br/>background routes<br/>[periodical.go]"]
  node_services["Domain services<br/>orchestration<br/>[service.go]"]
  node_filesvc["File & upload<br/>file service<br/>[file.go]"]
  node_storagesvc[("Storage<br/>[storage.go]")]
  node_systemsvc["System ops<br/>system service<br/>[system.go]"]
  node_healthsvc(("Health<br/>status service<br/>[health.go]"))
  node_sharesvc["Sharing<br/>[shares.go]"]
  node_models["API models<br/>contracts<br/>[common.go]"]
end

subgraph group_frontend["Vue UI"]
  node_ui(("Admin UI<br/>vue app<br/>[App.vue]"))
  node_uiservices["UI services<br/>api wrappers<br/>[index.js]"]
  node_uistore["UI store<br/>state<br/>[index.js]"]
  node_uirouter["UI router<br/>routing<br/>[index.js]"]
  node_uimsg["Message bus<br/>eventing<br/>[message_bus.js]"]
end

subgraph group_platform["Platform & integrations"]
  node_drivers["Cloud drivers<br/>provider adapters<br/>[all.go]"]
  node_pkgutils["Utils<br/>helpers<br/>[path.go]"]
  node_persistence[("Config & cache<br/>infra<br/>[config.go]")]
  node_setup["Install scripts<br/>packaging<br/>[install-nexus.sh]"]
  node_sysroot["Sysroot assets<br/>service packaging<br/>[casaos.service]"]
  node_openapi["OpenAPI spec<br/>contract<br/>[openapi.yaml]"]
end

node_main -->|"registers"| node_routev1
node_main -->|"registers"| node_routev2
node_main -->|"starts"| node_periodical
node_routev1 -->|"calls"| node_services
node_routev2 -->|"calls"| node_services
node_services -->|"uses"| node_filesvc
node_services -->|"uses"| node_storagesvc
node_services -->|"uses"| node_systemsvc
node_services -->|"uses"| node_healthsvc
node_services -->|"uses"| node_sharesvc
node_filesvc -->|"reads/writes"| node_models
node_storagesvc -->|"reads/writes"| node_models
node_systemsvc -->|"reads/writes"| node_models
node_sharesvc -->|"reads/writes"| node_models
node_sharesvc -->|"integrates"| node_drivers
node_services -->|"depends on"| node_pkgutils
node_services -->|"depends on"| node_persistence
node_ui -->|"uses"| node_uiservices
node_uiservices -->|"consumes"| node_routev1
node_uiservices -->|"consumes"| node_routev2
node_ui -->|"shares state"| node_uistore
node_ui -->|"navigates"| node_uirouter
node_ui -->|"publishes/subscribes"| node_uimsg
node_setup -->|"installs"| node_sysroot
node_sysroot -->|"runs"| node_main
node_routev2 -.->|"documents"| node_openapi

click node_main "https://github.com/12ali26/nexusos/blob/main/main.go"
click node_routev1 "https://github.com/12ali26/nexusos/blob/main/route/v1.go"
click node_routev2 "https://github.com/12ali26/nexusos/blob/main/route/v2.go"
click node_periodical "https://github.com/12ali26/nexusos/blob/main/route/periodical.go"
click node_services "https://github.com/12ali26/nexusos/blob/main/service/service.go"
click node_filesvc "https://github.com/12ali26/nexusos/blob/main/service/file.go"
click node_storagesvc "https://github.com/12ali26/nexusos/blob/main/service/storage.go"
click node_systemsvc "https://github.com/12ali26/nexusos/blob/main/service/system.go"
click node_healthsvc "https://github.com/12ali26/nexusos/blob/main/service/health.go"
click node_sharesvc "https://github.com/12ali26/nexusos/blob/main/service/shares.go"
click node_models "https://github.com/12ali26/nexusos/blob/main/model/common.go"
click node_drivers "https://github.com/12ali26/nexusos/blob/main/drivers/all.go"
click node_pkgutils "https://github.com/12ali26/nexusos/blob/main/pkg/utils/path.go"
click node_persistence "https://github.com/12ali26/nexusos/blob/main/pkg/config/config.go"
click node_ui "https://github.com/12ali26/nexusos/blob/main/UI/src/App.vue"
click node_uiservices "https://github.com/12ali26/nexusos/blob/main/UI/src/service/index.js"
click node_uistore "https://github.com/12ali26/nexusos/blob/main/UI/src/store/index.js"
click node_uirouter "https://github.com/12ali26/nexusos/blob/main/UI/src/router/index.js"
click node_uimsg "https://github.com/12ali26/nexusos/blob/main/UI/src/events/message_bus.js"
click node_setup "https://github.com/12ali26/nexusos/blob/main/scripts/install-nexus.sh"
click node_sysroot "https://github.com/12ali26/nexusos/blob/main/build/sysroot/usr/lib/systemd/system/casaos.service"
click node_openapi "https://github.com/12ali26/nexusos/blob/main/api/casaos/openapi.yaml"

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_main,node_routev1,node_routev2,node_periodical,node_services,node_filesvc,node_storagesvc,node_systemsvc,node_healthsvc,node_sharesvc,node_models toneBlue
class node_ui,node_uiservices,node_uistore,node_uirouter,node_uimsg toneAmber
class node_drivers,node_pkgutils,node_persistence,node_setup,node_sysroot,node_openapi toneMint
```

## Components

### Go backend

System daemon, API surface, domain services, and models.

- [Daemon entry](https://github.com/12ali26/nexusos/blob/main/main.go): go entrypoint · Bootstraps the CasaOS backend process. · `main.go`
- [API v1](https://github.com/12ali26/nexusos/blob/main/route/v1.go): http routes · Legacy and broad backend HTTP endpoints. · `route/v1.go`
- [API v2](https://github.com/12ali26/nexusos/blob/main/route/v2.go): http routes · Versioned backend endpoints and newer surface area. · `route/v2.go`
- [Jobs](https://github.com/12ali26/nexusos/blob/main/route/periodical.go): background routes · Periodic and scheduled backend work. · `route/periodical.go`
- [Domain services](https://github.com/12ali26/nexusos/blob/main/service/service.go): orchestration · Core backend business logic across files, storage, system, health, sharing, peers, sockets, and notifications. · `service/service.go`
- [File & upload](https://github.com/12ali26/nexusos/blob/main/service/file.go): file service · File operations, transfers, and upload handling. · `service/file.go`
- [Storage](https://github.com/12ali26/nexusos/blob/main/service/storage.go): storage service · Storage layout, mounts, and disk-oriented coordination. · `service/storage.go`
- [System ops](https://github.com/12ali26/nexusos/blob/main/service/system.go): system service · System information, settings, and device management. · `service/system.go`
- [Health](https://github.com/12ali26/nexusos/blob/main/service/health.go): status service · Health, recovery, and live status logic. · `service/health.go`
- [Sharing](https://github.com/12ali26/nexusos/blob/main/service/shares.go): sharing service · Shares, rely relationships, and peer coordination. · `service/shares.go`
- [API models](https://github.com/12ali26/nexusos/blob/main/model/common.go): contracts · Request/response payloads and persistent domain objects. · `model/common.go`

### Vue UI

Single-page admin client and its state/service layers.

- [Admin UI](https://github.com/12ali26/nexusos/blob/main/UI/src/App.vue): vue app · Separate Vue single-page client for administration and dashboard flows. · `UI/src/App.vue`
- [UI services](https://github.com/12ali26/nexusos/blob/main/UI/src/service/index.js): api wrappers · Frontend API clients mirroring backend domains. · `UI/src/service/index.js`
- [UI store](https://github.com/12ali26/nexusos/blob/main/UI/src/store/index.js): state · Shared application state and mutations. · `UI/src/store/index.js`
- [UI router](https://github.com/12ali26/nexusos/blob/main/UI/src/router/index.js): routing · Client-side navigation and page transitions. · `UI/src/router/index.js`
- [Message bus](https://github.com/12ali26/nexusos/blob/main/UI/src/events/message_bus.js): eventing · Decoupled UI events for cross-component coordination. · `UI/src/events/message_bus.js`

### Platform & integrations

Storage drivers, OS helpers, packaging, and external service boundaries.

- [Cloud drivers](https://github.com/12ali26/nexusos/blob/main/drivers/all.go): provider adapters · Pluggable remote storage adapters for major cloud providers. · `drivers/all.go`
- [Utils](https://github.com/12ali26/nexusos/blob/main/pkg/utils/path.go): helpers · Shared filesystem, network, versioning, HTTP, and OS helpers. · `pkg/utils/path.go`
- [Config & cache](https://github.com/12ali26/nexusos/blob/main/pkg/config/config.go): infra · Configuration, cache, sqlite, redis, and signing primitives. · `pkg/config/config.go`
- [Install scripts](https://github.com/12ali26/nexusos/blob/main/scripts/install-nexus.sh): packaging · OS installation, migration, and deployment scripts. · `scripts/install-nexus.sh`
- [Sysroot assets](https://github.com/12ali26/nexusos/blob/main/build/sysroot/usr/lib/systemd/system/casaos.service): service packaging · Systemd units, setup files, and packaged filesystem layout. · `build/sysroot/usr/lib/systemd/system/casaos.service`
- [OpenAPI spec](https://github.com/12ali26/nexusos/blob/main/api/casaos/openapi.yaml): contract · Generated API contract for external consumers and tooling. · `api/casaos/openapi.yaml`

## Connections

- Daemon entry → API v1: registers · Main process wires the primary HTTP surface.
- Daemon entry → API v2: registers · Main process wires the versioned API surface.
- Daemon entry → Jobs: starts · Main process enables background route jobs.
- API v1 → Domain services: calls · v1 endpoints delegate to domain services.
- API v2 → Domain services: calls · v2 endpoints delegate to domain services.
- Domain services → File & upload: uses · Central service layer routes file workflows.
- Domain services → Storage: uses · Central service layer routes storage workflows.
- Domain services → System ops: uses · Central service layer routes system workflows.
- Domain services → Health: uses · Central service layer routes health workflows.
- Domain services → Sharing: uses · Central service layer routes sharing workflows.
- File & upload → API models: reads/writes · File service exchanges API and domain objects.
- Storage → API models: reads/writes · Storage service exchanges API and domain objects.
- System ops → API models: reads/writes · System service exchanges API and domain objects.
- Sharing → API models: reads/writes · Sharing service exchanges API and domain objects.
- Sharing → Cloud drivers: integrates · Sharing and remote file flows rely on provider adapters.
- Domain services → Utils: depends on · Domain logic uses shared helpers and OS abstractions.
- Domain services → Config & cache: depends on · Domain logic persists settings and shared state.
- Admin UI → UI services: uses · Vue views call API wrapper modules.
- UI services → API v1: consumes · Frontend service wrappers target backend endpoints.
- UI services → API v2: consumes · Frontend service wrappers target backend endpoints.
- Admin UI → UI store: shares state · Components coordinate through centralized store state.
- Admin UI → UI router: navigates · Client-side page transitions are routed centrally.
- Admin UI → Message bus: publishes/subscribes · Decoupled interactions use the message bus.
- Install scripts → Sysroot assets: installs · Deployment scripts populate the packaged system layout.
- Sysroot assets → Daemon entry: runs · Systemd packaging launches the backend daemon.
- API v2 → OpenAPI spec: documents · The API surface is captured in the generated contract.
