How 12ali26/nexusos works
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.go Domain services · App.vue Admin UI · main.go Daemon entry · v2.go API v2
Components 22
Go backend
System daemon, API surface, domain services, and models.
- Daemon entry · Bootstraps the CasaOS backend process.
main.go - API v1 · Legacy and broad backend HTTP endpoints.
route/v1.go - API v2 · Versioned backend endpoints and newer surface area.
route/v2.go - Jobs · Periodic and scheduled backend work.
route/periodical.go - Domain services · Core backend business logic across files, storage, system, health, sharing, peers, sockets, and notifications.
service/service.go - File & upload · File operations, transfers, and upload handling.
service/file.go - Storage · Storage layout, mounts, and disk-oriented coordination.
service/storage.go - System ops · System information, settings, and device management.
service/system.go - Health · Health, recovery, and live status logic.
service/health.go - Sharing · Shares, rely relationships, and peer coordination.
service/shares.go - API models · Request/response payloads and persistent domain objects.
model/common.go
Vue UI
Single-page admin client and its state/service layers.
- Admin UI · Separate Vue single-page client for administration and dashboard flows.
UI/src/App.vue - UI services · Frontend API clients mirroring backend domains.
UI/src/service/index.js - UI store · Shared application state and mutations.
UI/src/store/index.js - UI router · Client-side navigation and page transitions.
UI/src/router/index.js - Message bus · 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 · Pluggable remote storage adapters for major cloud providers.
drivers/all.go - Utils · Shared filesystem, network, versioning, HTTP, and OS helpers.
pkg/utils/path.go - Config & cache · Configuration, cache, sqlite, redis, and signing primitives.
pkg/config/config.go - Install scripts · OS installation, migration, and deployment scripts.
scripts/install-nexus.sh - Sysroot assets · Systemd units, setup files, and packaged filesystem layout.
build/sysroot/usr/lib/systemd/system/casaos.service - OpenAPI spec · Generated API contract for external consumers and tooling.
api/casaos/openapi.yaml
Connections 26
- 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.