# styliteag/ssm architecture

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

- Interactive diagram: https://gitdiagram.com/styliteag/ssm
- Repository: https://github.com/styliteag/ssm

## Overview

SSM is a Phoenix LiveView application and wire-compatible JSON API for managing users, SSH keys, host access authorizations, and remote authorized_keys files. Users enter through the authenticated web UI or API; the application manages those records and provides activity, host-diff, and synchronization capabilities. The sampled host, key, and authorization API controllers show calls into domain services; the README documents the wider SSH and diff capabilities, whose internal call paths were not sampled. The graph therefore keeps those links explicitly unverified rather than implying a detailed execution chain.

Main entry points: [`phoenix/lib/ssm_web/router.ex`](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/router.ex) (Phoenix router), [`phoenix/lib/ssm_web/live`](https://github.com/styliteag/ssm/tree/main/phoenix/lib/ssm_web/live) (LiveView screens), [`phoenix/lib/ssm_web/controllers/api/authorization_controller.ex`](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/api/authorization_controller.ex) (Authorization API), [`phoenix/lib/ssm/hosts.ex`](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/hosts.ex) (Host management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_router["Phoenix router<br/>[router.ex]"]
  node_live_ui["LiveView screens"]
  node_web_session["Web sessions"]
  node_web_auth["Web authentication<br/>[user_auth.ex]"]
  node_ui_components["UI components<br/>[core_components.ex]"]
  node_ui_layouts["UI layouts<br/>[layouts.ex]"]
end

subgraph group_api["JSON API"]
  node_api_auth["API authentication<br/>[auth_plug.ex]"]
  node_host_api["Host API<br/>[host_controller.ex]"]
  node_key_api["Key API<br/>[key_controller.ex]"]
  node_authorization_api["Authorization API"]
  node_other_api["Other API endpoints"]
end

subgraph group_domain["Access management"]
  node_hosts["Host management<br/>[hosts.ex]"]
  node_users_keys["Users and keys<br/>[bulk_ops.ex]"]
  node_authorizations["Access authorizations<br/>[authorizations.ex]"]
  node_activity["Activity history<br/>[activity.ex]"]
end

subgraph group_remote["Remote operations"]
  node_diffs["Host diffs<br/>[diffs.ex]"]
  node_ssh["SSH operations<br/>[erlang_client.ex]"]
end

subgraph group_runtime["Runtime and storage"]
  node_repo[("SQLite repository<br/>[repo.ex]")]
  node_application["OTP application<br/>[application.ex]"]
end

node_operator(("Operator"))
node_api_client(("API client"))

node_operator -->|"uses web"| node_router
node_api_client -->|"calls API"| node_router
node_router -->|"routes LiveView"| node_live_ui
node_router -->|"routes sessions"| node_web_session
node_router -->|"guards pages"| node_web_auth
node_router -->|"protects API"| node_api_auth
node_live_ui -.->|"uses components"| node_ui_components
node_live_ui -.->|"uses layouts"| node_ui_layouts
node_web_session -->|"logs in"| node_web_auth
node_api_auth -->|"checks bearer token"| node_api_client
node_host_api -->|"calls"| node_hosts
node_key_api -->|"calls"| node_users_keys
node_authorization_api -->|"calls"| node_authorizations
node_authorization_api -->|"checks host"| node_hosts
node_authorization_api -->|"checks user"| node_users_keys
node_router -->|"routes hosts"| node_host_api
node_router -->|"routes keys"| node_key_api
node_router -->|"routes grants"| node_authorization_api
node_router -->|"routes endpoints"| node_other_api
node_live_ui -.->|"manages hosts"| node_hosts
node_live_ui -.->|"manages users and keys"| node_users_keys
node_live_ui -.->|"manages grants"| node_authorizations
node_live_ui -.->|"shows diffs"| node_diffs
node_live_ui -.->|"shows activity"| node_activity
node_diffs -.->|"checks remote hosts"| node_ssh
node_ssh -.->|"targets managed hosts"| node_hosts
node_application -->|"starts"| node_repo
node_application -->|"starts client"| node_ssh
node_diffs -.->|"records operations"| node_activity

click node_router "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/router.ex"
click node_live_ui "https://github.com/styliteag/ssm/tree/main/phoenix/lib/ssm_web/live"
click node_web_session "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/session_controller.ex"
click node_web_auth "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/user_auth.ex"
click node_ui_components "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/components/core_components.ex"
click node_ui_layouts "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/components/layouts.ex"
click node_api_auth "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/api/auth_plug.ex"
click node_host_api "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/api/host_controller.ex"
click node_key_api "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/api/key_controller.ex"
click node_authorization_api "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/api/authorization_controller.ex"
click node_other_api "https://github.com/styliteag/ssm/tree/main/phoenix/lib/ssm_web/controllers/api"
click node_hosts "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/hosts.ex"
click node_users_keys "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/users/bulk_ops.ex"
click node_authorizations "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/authorizations.ex"
click node_activity "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/activity.ex"
click node_diffs "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/diffs.ex"
click node_ssh "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/ssh/erlang_client.ex"
click node_repo "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/repo.ex"
click node_application "https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/application.ex"

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_router,node_live_ui,node_web_session,node_web_auth,node_ui_components,node_ui_layouts,node_api_client toneBlue
class node_api_auth,node_host_api,node_key_api,node_authorization_api,node_other_api toneAmber
class node_hosts,node_users_keys,node_authorizations,node_activity toneMint
class node_diffs,node_ssh toneRose
class node_repo,node_application,node_operator toneIndigo
```

## Components

### Web application

- [Phoenix router](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/router.ex): `phoenix/lib/ssm_web/router.ex`
- [LiveView screens](https://github.com/styliteag/ssm/tree/main/phoenix/lib/ssm_web/live): `phoenix/lib/ssm_web/live`
- [Web sessions](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/session_controller.ex): `phoenix/lib/ssm_web/controllers/session_controller.ex`
- [Web authentication](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/user_auth.ex): `phoenix/lib/ssm_web/user_auth.ex`
- [UI components](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/components/core_components.ex): `phoenix/lib/ssm_web/components/core_components.ex`
- [UI layouts](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/components/layouts.ex): `phoenix/lib/ssm_web/components/layouts.ex`

### JSON API

- [API authentication](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/api/auth_plug.ex): `phoenix/lib/ssm_web/api/auth_plug.ex`
- [Host API](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/api/host_controller.ex): `phoenix/lib/ssm_web/controllers/api/host_controller.ex`
- [Key API](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/api/key_controller.ex): `phoenix/lib/ssm_web/controllers/api/key_controller.ex`
- [Authorization API](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm_web/controllers/api/authorization_controller.ex): `phoenix/lib/ssm_web/controllers/api/authorization_controller.ex`
- [Other API endpoints](https://github.com/styliteag/ssm/tree/main/phoenix/lib/ssm_web/controllers/api): `phoenix/lib/ssm_web/controllers/api`

### Access management

- [Host management](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/hosts.ex): `phoenix/lib/ssm/hosts.ex`
- [Users and keys](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/users/bulk_ops.ex): `phoenix/lib/ssm/users/bulk_ops.ex`
- [Access authorizations](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/authorizations.ex): `phoenix/lib/ssm/authorizations.ex`
- [Activity history](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/activity.ex): `phoenix/lib/ssm/activity.ex`

### Remote operations

- [Host diffs](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/diffs.ex): `phoenix/lib/ssm/diffs.ex`
- [SSH operations](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/ssh/erlang_client.ex): `phoenix/lib/ssm/ssh/erlang_client.ex`

### Runtime and storage

- [SQLite repository](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/repo.ex): `phoenix/lib/ssm/repo.ex`
- [OTP application](https://github.com/styliteag/ssm/blob/main/phoenix/lib/ssm/application.ex): `phoenix/lib/ssm/application.ex`

### Other components

- **Operator**
- **API client**

## Connections

- Operator → Phoenix router: uses web
- API client → Phoenix router: calls API
- Phoenix router → LiveView screens: routes LiveView (evidence: `phoenix/lib/ssm_web/router.ex`)
- Phoenix router → Web sessions: routes sessions (evidence: `phoenix/lib/ssm_web/router.ex`)
- Phoenix router → Web authentication: guards pages (evidence: `phoenix/lib/ssm_web/router.ex`)
- Phoenix router → API authentication: protects API (evidence: `phoenix/lib/ssm_web/router.ex`)
- LiveView screens → UI components: uses components
- LiveView screens → UI layouts: uses layouts
- Web sessions → Web authentication: logs in (evidence: `phoenix/lib/ssm_web/controllers/session_controller.ex`)
- API authentication → API client: checks bearer token
- Host API → Host management: calls (evidence: `phoenix/lib/ssm_web/controllers/api/host_controller.ex`)
- Key API → Users and keys: calls (evidence: `phoenix/lib/ssm_web/controllers/api/key_controller.ex`)
- Authorization API → Access authorizations: calls (evidence: `phoenix/lib/ssm_web/controllers/api/authorization_controller.ex`)
- Authorization API → Host management: checks host (evidence: `phoenix/lib/ssm_web/controllers/api/authorization_controller.ex`)
- Authorization API → Users and keys: checks user (evidence: `phoenix/lib/ssm_web/controllers/api/authorization_controller.ex`)
- Phoenix router → Host API: routes hosts (evidence: `phoenix/lib/ssm_web/router.ex`)
- Phoenix router → Key API: routes keys (evidence: `phoenix/lib/ssm_web/router.ex`)
- Phoenix router → Authorization API: routes grants (evidence: `phoenix/lib/ssm_web/router.ex`)
- Phoenix router → Other API endpoints: routes endpoints (evidence: `phoenix/lib/ssm_web/router.ex`)
- LiveView screens → Host management: manages hosts
- LiveView screens → Users and keys: manages users and keys
- LiveView screens → Access authorizations: manages grants
- LiveView screens → Host diffs: shows diffs
- LiveView screens → Activity history: shows activity
- Host diffs → SSH operations: checks remote hosts
- SSH operations → Host management: targets managed hosts
- OTP application → SQLite repository: starts (evidence: `phoenix/lib/ssm/application.ex`)
- OTP application → SSH operations: starts client (evidence: `phoenix/lib/ssm/application.ex`)
- Host diffs → Activity history: records operations
