Seven end-to-end, step-by-step walkthroughs — from registration to re-encrypting credentials on a password change — showing how the client, backend, and SSH servers interact in practice.
flowchart LR
U(("User"))
U --> UC1["Registration and VM creation"]
U --> UC2["Vault unlock and SSH statistics"]
U --> UC3["File upload over SFTP"]
U --> UC4["App installation"]
U --> UC5["Running scripts with parameters"]
U --> UC6["Sign-in via MAX Bot"]
U --> UC7["Account password change"] The main user scenarios
sequenceDiagram
participant C as Client
participant S as Backend
participant VB as VirtualBox
C->>S: POST /auth/register { username, password, email }
S-->>C: { accessToken, refreshToken }
Note over C: Tokens → SecureStore / AsyncStorage
C->>S: GET /profile
S-->>C: { user: { ..., credentialSalt } }
C->>S: WebSocket connection (JWT via Sec-WebSocket-Protocol)
Note over C: Setting the PIN → authKey = Argon2id(pin, credentialSalt)<br/>blob = AES-256-GCM(authKey, { sshUser, sshPassword })
C->>S: POST /vps { name, cpu, ram, osType, sshEncryptedCreds }
S->>S: INSERT VpsInstance { status: INSTALLING }
S->>VB: launch the VirtualBox installer
S-->>C: status "Installing..."
VB->>S: PATCH /vps/installed?vpsName=...&installed=true (headers x-vm-ts, x-vm-signature)
S->>S: verify HMAC → status = RUNNING
S-->>C: WS event — VM is running sequenceDiagram
participant C as Client
participant S as Backend
participant SSH as ssh.service
Note over C: App in the foreground, isUnlocked = false
alt biometrics available (hasSecureKey)
C->>C: biometrics → kdfKey from SecureStore
else PIN
C->>C: PIN → Argon2id(pin, credentialSalt) → kdfKey
C->>C: trial decryption of the first VM's credentials (auth tag check)
end
C->>S: POST /vps/ssh-session { authKeyB64: kdfKey }
S->>S: store authKey in Valkey (TTL 8h)
S-->>C: sessionId
C->>S: GET /vps/:id/stats { tokenId, tokenTs, tokenSig }
S->>S: consume the token → decrypted credentials
S->>SSH: collect statistics (CPU/RAM/disk/network)
SSH-->>S: metrics
S-->>C: statistics
C->>C: render charts sequenceDiagram
participant C as Client
participant WS as WebSocket Gateway
participant SFTP as sftp.service
Note over C: 500 MB file → 250 chunks of 2 MB
C->>C: sshToken.getToken(vpsId, "sftp") → tokenId, tokenTs, tokenSig
C->>WS: sftp-upload-start { sessionId, fileName, fileSize, totalChunks, tokenId, tokenTs, tokenSig }
WS->>WS: consumeToken (once) → decrypted credentials, create the upload session
WS-->>C: sftp-upload-chunk-received { chunkIndex: -1 }
loop chunk i = 0..249
C->>WS: sftp-upload-chunk { sessionId, chunkIndex:i, totalChunks, data }
WS->>WS: store the chunk in the session (Map)
WS-->>C: sftp-upload-chunk-received { chunkIndex:i }
end
Note over WS: chunks.size === totalChunks → auto-assemble the file
WS->>SFTP: put(Buffer.concat(chunks), remotePath)
SFTP-->>WS: success
WS-->>C: sftp-upload-complete { sessionId, success:true }
C->>C: refresh the directory listing sequenceDiagram
participant C as Client
participant S as Backend
participant SSH as ssh.service
C->>S: POST /vps/:id/apps/search { query: "nginx" } (headers x-ssh-token, x-ssh-token-ts, x-ssh-sig)
S->>S: consumeToken (action "app-search") → { user, password }
S->>SSH: apt-cache search / choco search
SSH-->>S: list of packages
S-->>C: search results
C->>C: tap "Install" (nginx)
C->>S: POST /vps/:id/apps/install { packageId: "nginx", sudoPassword } (headers x-ssh-token, x-ssh-token-ts, x-ssh-sig)
S->>S: consumeToken (action "app-install") → { user, password }
S->>SSH: sudo apt-get install -y nginx (timeout 300s)
SSH-->>S: stdout / stderr
S->>SSH: post-install: systemctl enable/start nginx
S-->>C: { success: true, output }
C->>C: "Installed" with a green checkmark sequenceDiagram
participant C as Client
participant S as Backend
participant SSH as ssh.service
C->>C: select the "Database backup" script + parameters --db, --compress
C->>S: POST /scripts/:id/run/:vpsId { parameterValues, workingDirectory } (headers x-ssh-token, x-ssh-token-ts, x-ssh-sig)
S->>S: consumeToken (action "script-run") → decrypted credentials
S->>S: fetch the CustomScript (file / scriptUrl, SSRF check)
S->>S: build the command (parameter whitelist + shellQuoteSh())
S-->>C: 202 Accepted { runId }
S->>SSH: bash backup.sh --db 'myapp' --compress 'true'
loop line-by-line output
SSH-->>S: stdout / stderr
S-->>C: WS script-output:chunk { runId, seq, data }
end
S-->>C: WS script-output:complete { runId, exitCode: 0 }
C->>C: "Completed successfully" sequenceDiagram
participant C as Client
participant S as Backend
participant R as Valkey
participant M as MAX Bot
C->>C: generate a 6-digit code (sessionId)
C->>M: deep link .../bot?start=sessionId
C->>C: show the code in an overlay (with a "copy" button)
Note over C,M: if the redirect to MAX didn't fire automatically
C->>M: sends the code manually in chat
M->>S: /start <sessionId>
S->>R: store tokens under sessionId (TTL 60s)
loop poll every 3s (up to 60s)
C->>S: GET /auth/max/poll/:sessionId
S->>R: check readiness
S-->>C: 202 (waiting)
end
S-->>C: 200 { accessToken, refreshToken }
C->>C: the user is authenticated sequenceDiagram
participant C as Client
participant S as Backend
C->>S: PATCH /profile/password { password }
S->>S: hash(password) (Argon2), save passwordHash
S-->>C: { user }
Note over S: credentialSalt does NOT change — there is no rotation on password change
Note over C: authKey = Argon2id(PIN, credentialSalt)<br/>depends on the vault PIN, not the account password
C->>C: vault stays unlocked with the same PIN, no credential re-encryption needed