# vouv/srun architecture

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

- Interactive diagram: https://gitdiagram.com/vouv/srun
- Repository: https://github.com/vouv/srun

## Overview

Srun is a command-line client for BIT campus-network access. Users configure credentials, then log in or out, or query account and usage information. The login domain flow discovers the network access ID, obtains a challenge, builds the authenticated portal request, and saves updated session state; logout clears that state. The map separates CLI orchestration, portal logic, protocol/data models, and local account storage. Some request helpers and command implementations were not sampled, so uncertain internal wiring is omitted.

Main entry points: [`cmd/srun/cli.go`](https://github.com/vouv/srun/blob/master/cmd/srun/cli.go) (Command Handlers), [`core/core.go`](https://github.com/vouv/srun/blob/master/core/core.go) (Portal Operations), [`utils/request.go`](https://github.com/vouv/srun/blob/master/utils/request.go) (JSONP HTTP), [`store/store.go`](https://github.com/vouv/srun/blob/master/store/store.go) (Account Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_commands["Command Dispatch<br/>[main.go]"]
  node_handlers["Command Handlers<br/>[cli.go]"]
end

subgraph group_portal["Portal Access"]
  node_core["Portal Operations<br/>[core.go]"]
  node_transport["JSONP HTTP<br/>[request.go]"]
end

subgraph group_protocol["Protocol Data"]
  node_hash["Portal Hashing<br/>[hash.go]"]
  node_requestmodel["Request Builders<br/>[request.go]"]
  node_responsemodel["Response Models<br/>[response.go]"]
  node_format["Usage Formatting<br/>[format.go]"]
end

subgraph group_local["Local State"]
  node_account["Account Model<br/>[account.go]"]
  node_store[("Account Store<br/>[store.go]")]
end

node_user(("User"))
node_campus{{"Campus Portal"}}
node_terminal(("Terminal"))

node_user -->|"runs command"| node_commands
node_commands -->|"dispatches"| node_handlers
node_handlers -->|"reads input"| node_terminal
node_handlers -->|"reads credentials"| node_store
node_handlers -->|"writes credentials"| node_store
node_handlers -->|"invokes operations"| node_core
node_core -->|"requests portal"| node_campus
node_core -->|"fetches JSONP"| node_transport
node_transport -->|"sends HTTP"| node_campus
node_core -->|"builds requests"| node_requestmodel
node_core -->|"computes auth fields"| node_hash
node_transport -->|"decodes responses"| node_responsemodel
node_handlers -->|"formats usage"| node_format
node_responsemodel -->|"formats values"| node_format
node_store -->|"reads and writes"| node_account

click node_commands "https://github.com/vouv/srun/blob/master/cmd/srun/main.go"
click node_handlers "https://github.com/vouv/srun/blob/master/cmd/srun/cli.go"
click node_core "https://github.com/vouv/srun/blob/master/core/core.go"
click node_hash "https://github.com/vouv/srun/blob/master/hash/hash.go"
click node_requestmodel "https://github.com/vouv/srun/blob/master/model/request.go"
click node_responsemodel "https://github.com/vouv/srun/blob/master/model/response.go"
click node_transport "https://github.com/vouv/srun/blob/master/utils/request.go"
click node_format "https://github.com/vouv/srun/blob/master/utils/format.go"
click node_account "https://github.com/vouv/srun/blob/master/model/account.go"
click node_store "https://github.com/vouv/srun/blob/master/store/store.go"

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_commands,node_handlers,node_user toneBlue
class node_core,node_transport toneAmber
class node_hash,node_requestmodel,node_responsemodel,node_format toneMint
class node_account,node_store toneRose
class node_campus,node_terminal toneIndigo
```

## Components

### CLI

- [Command Dispatch](https://github.com/vouv/srun/blob/master/cmd/srun/main.go): `cmd/srun/main.go`
- [Command Handlers](https://github.com/vouv/srun/blob/master/cmd/srun/cli.go): `cmd/srun/cli.go`

### Portal Access

- [Portal Operations](https://github.com/vouv/srun/blob/master/core/core.go): `core/core.go`
- [JSONP HTTP](https://github.com/vouv/srun/blob/master/utils/request.go): `utils/request.go`

### Protocol Data

- [Portal Hashing](https://github.com/vouv/srun/blob/master/hash/hash.go): `hash/hash.go`
- [Request Builders](https://github.com/vouv/srun/blob/master/model/request.go): `model/request.go`
- [Response Models](https://github.com/vouv/srun/blob/master/model/response.go): `model/response.go`
- [Usage Formatting](https://github.com/vouv/srun/blob/master/utils/format.go): `utils/format.go`

### Local State

- [Account Model](https://github.com/vouv/srun/blob/master/model/account.go): `model/account.go`
- [Account Store](https://github.com/vouv/srun/blob/master/store/store.go): `store/store.go`

### Other components

- **User**
- **Campus Portal**
- **Terminal**

## Connections

- User → Command Dispatch: runs command
- Command Dispatch → Command Handlers: dispatches
- Command Handlers → Terminal: reads input
- Command Handlers → Account Store: reads credentials
- Command Handlers → Account Store: writes credentials
- Command Handlers → Portal Operations: invokes operations
- Portal Operations → Campus Portal: requests portal
- Portal Operations → JSONP HTTP: fetches JSONP
- JSONP HTTP → Campus Portal: sends HTTP
- Portal Operations → Request Builders: builds requests
- Portal Operations → Portal Hashing: computes auth fields
- JSONP HTTP → Response Models: decodes responses
- Command Handlers → Usage Formatting: formats usage
- Response Models → Usage Formatting: formats values
- Account Store → Account Model: reads and writes
