How chiranjitk/staysuite_cmc works
StaySuite CMC is a multi-tenant console for managing StaySuite devices and gateways. Operators enroll and approve devices, monitor health and alerts, issue commands, deploy configuration or software, and manage licenses and remote support. The Go agent registers with the CMC, reports heartbeats, polls for commands, and can establish a reverse SSH tunnel. The tree and sampled routes support these capabilities, but most UI-to-route wiring and several feature implementations were not sampled; those links are shown only where the product structure or excerpts support them.
Main entry points: db.ts Application database · main.go Device agent · tenant-context.ts Tenant permissions · route.ts License management
Components 24
Management console
- CMC console
web/src/app - Versioned API
web/src/app/api/v1
Device lifecycle
- Bootstrap tokens
web/src/app/api/v1/bootstrap-tokens/route.ts - Agent registration
web/src/app/api/v1/agent/register/route.ts - Device approval
web/src/app/api/v1/devices/[id]/approve/route.ts - Device agent
agent/cmd/staysuite-cmc-agent/main.go - Agent identity
agent/internal/identity/identity.go - Agent configuration
agent/internal/config/config.go
Fleet operations
- Heartbeat intake
web/src/app/api/v1/agent/heartbeat/route.ts - Command dispatch
web/src/app/api/v1/agent/command/route.ts - Agent command execution
agent/internal/commands/commands.go - Alert management
web/src/app/api/v1/alerts/route.ts - Configuration deployment
web/src/app/api/v1/configuration/deploy/route.ts - Software deployment
web/src/app/api/v1/software/deploy/route.ts - License management
web/src/app/api/v1/licenses/route.ts - Reports and audit
web/src/app/api/v1/reports
Remote access
- Support sessions
web/src/app/api/v1/support-sessions/route.ts - Remote UI sessions
web/src/app/remote/[sessionId]/[[...path]]/route.ts - Tunnel peer provisioning
web/src/app/api/v1/admin/tunnel-peer/route.ts - Reverse SSH tunnel
agent/internal/tunnel/tunnel.go - SSH service
mini-services/ssh-server/index.ts
Shared services
- Tenant permissions
web/src/lib/tenant-context.ts - Application database
web/src/lib/db.ts
Other components
- Operator
Connections 38
- Operator → CMC console: uses
- CMC console → Versioned API: requests
- Versioned API → Tenant permissions: checks access
- Bootstrap tokens → Tenant permissions: checks access
- Bootstrap tokens → Application database: stores tokens
- Agent registration → Application database: validates token; records device
- Device agent → Agent configuration: loads settings
- Device agent → Agent identity: reads identity
- Device agent → Agent registration: registers
- Operator → Device approval: approves device
- Device approval → Application database: updates device
- Device agent → Heartbeat intake: reports health
- Heartbeat intake → Application database: updates device and metrics
- Device agent → Command dispatch: polls and reports results
- Command dispatch → Application database: reads and updates commands
- Device agent → Agent command execution: executes commands
- Agent command execution → Device agent: returns results
- Operator → Alert management: reviews alerts
- Alert management → Application database: reads alerts
- Operator → Configuration deployment: deploys configuration
- Configuration deployment → Application database: accesses deployment data
- Operator → Software deployment: deploys software
- Software deployment → Application database: accesses deployment data
- Operator → License management: manages licenses
- License management → Tenant permissions: checks access
- License management → Application database: reads and writes licenses
- Operator → Reports and audit: views reports
- Reports and audit → Application database: reads reporting data
- Operator → Support sessions: starts support
- Support sessions → Tenant permissions: checks access
- Support sessions → Application database: stores sessions
- Operator → Remote UI sessions: opens session
- Remote UI sessions → Application database: validates session
- Operator → Tunnel peer provisioning: provisions peer
- Tunnel peer provisioning → Tenant permissions: checks access
- Tunnel peer provisioning → Application database: stores peer
- Device agent → Reverse SSH tunnel: starts tunnel
- Reverse SSH tunnel → SSH service: connects