# t4ke0/pwm architecture

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

- Interactive diagram: https://gitdiagram.com/t4ke0/pwm
- Repository: https://github.com/t4ke0/pwm

## Overview

Password Manager is a multi-service password vault: users register or log in, receive a token carrying their user-key information, and use the gateway to manage encrypted credentials or generate passwords. The manager validates tokens with the authenticator, encrypts and decrypts vault entries, and accesses PostgreSQL; the key manager generates user keys and protects them with the server key. The excerpts show the main service calls and storage operations, but not all wiring or database schema details, so unsupported connections are omitted.

Main entry points: [`pwm_authenticator/cmd/serve/main.go`](https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/cmd/serve/main.go) (Registration and login), [`pwm_manager/server/main.go`](https://github.com/t4ke0/pwm/blob/develop/pwm_manager/server/main.go) (Vault manager), [`keys_manager/server/server.go`](https://github.com/t4ke0/pwm/blob/develop/keys_manager/server/server.go) (Key manager), [`pwm_db_api/db.go`](https://github.com/t4ke0/pwm/blob/develop/pwm_db_api/db.go) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["HTTP access"]
  node_gateway["REST gateway<br/>[main.go]"]
  node_gateway_api["Gateway API models<br/>[api.go]"]
end

subgraph group_identity["Identity and keys"]
  node_authenticator["Registration and login<br/>[main.go]"]
  node_auth_api["Auth request models<br/>[request_api.go]"]
  node_jwt["JWT handling<br/>[jwt_token.go]"]
  node_auth_passwords["Password hashing"]
  node_key_service["Key manager<br/>[server.go]"]
  node_key_crypto["Key cryptography<br/>[encryption_keys.go]"]
  node_key_contract["Key RPC contract<br/>[keymanager.proto]"]
end

subgraph group_vault["Password vault"]
  node_manager["Vault manager<br/>[main.go]"]
  node_manager_contract["Vault RPC contract<br/>[pwm_manager.proto]"]
  node_vault_crypto["Credential encryption"]
  node_generator["Password generator<br/>[generator.go]"]
end

subgraph group_storage["Persistence"]
  node_db_api["Database access<br/>[db.go]"]
  node_postgres[("PostgreSQL<br/>[schema.sql]")]
end

node_user(("Vault user"))

node_user -->|"uses"| node_gateway
node_gateway -->|"maps requests"| node_gateway_api
node_gateway -->|"calls RPC"| node_manager
node_user -->|"registers or logs in"| node_authenticator
node_authenticator -->|"binds requests"| node_auth_api
node_authenticator -->|"hashes passwords"| node_auth_passwords
node_authenticator -->|"issues and parses"| node_jwt
node_authenticator -->|"requests keys"| node_key_service
node_key_service -->|"implements RPC"| node_key_contract
node_key_service -->|"generates and decrypts"| node_key_crypto
node_manager -->|"implements RPC"| node_manager_contract
node_manager -->|"fetches token claims"| node_authenticator
node_manager -->|"encrypts and decrypts"| node_vault_crypto
node_manager -->|"generates passwords"| node_generator
node_authenticator -->|"reads and writes users"| node_db_api
node_key_service -->|"loads and stores keys"| node_db_api
node_manager -->|"reads and writes credentials"| node_db_api
node_db_api -->|"queries"| node_postgres

click node_gateway "https://github.com/t4ke0/pwm/blob/develop/gateway/cmd/serve/main.go"
click node_gateway_api "https://github.com/t4ke0/pwm/blob/develop/gateway/pkg/http/api/api.go"
click node_authenticator "https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/cmd/serve/main.go"
click node_auth_api "https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/api/request_api.go"
click node_jwt "https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/cmd/serve/jwt_token.go"
click node_auth_passwords "https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/passwords/manage_passwords.go"
click node_key_service "https://github.com/t4ke0/pwm/blob/develop/keys_manager/server/server.go"
click node_key_crypto "https://github.com/t4ke0/pwm/blob/develop/keys_manager/common/encryption_keys.go"
click node_key_contract "https://github.com/t4ke0/pwm/blob/develop/keys_manager/proto/keymanager.proto"
click node_manager "https://github.com/t4ke0/pwm/blob/develop/pwm_manager/server/main.go"
click node_manager_contract "https://github.com/t4ke0/pwm/blob/develop/pwm_manager/proto/pwm_manager.proto"
click node_vault_crypto "https://github.com/t4ke0/pwm/blob/develop/pwm_manager/passwords/passwords_encryption.go"
click node_generator "https://github.com/t4ke0/pwm/blob/develop/pwm_manager/pw_generator/generator.go"
click node_db_api "https://github.com/t4ke0/pwm/blob/develop/pwm_db_api/db.go"
click node_postgres "https://github.com/t4ke0/pwm/blob/develop/pwm_db_api/schema.sql"

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_gateway,node_gateway_api,node_user toneBlue
class node_authenticator,node_auth_api,node_jwt,node_auth_passwords,node_key_service,node_key_crypto,node_key_contract toneAmber
class node_manager,node_manager_contract,node_vault_crypto,node_generator toneMint
class node_db_api,node_postgres toneRose
```

## Components

### HTTP access

- [REST gateway](https://github.com/t4ke0/pwm/blob/develop/gateway/cmd/serve/main.go): `gateway/cmd/serve/main.go`
- [Gateway API models](https://github.com/t4ke0/pwm/blob/develop/gateway/pkg/http/api/api.go): `gateway/pkg/http/api/api.go`

### Identity and keys

- [Registration and login](https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/cmd/serve/main.go): `pwm_authenticator/cmd/serve/main.go`
- [Auth request models](https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/api/request_api.go): `pwm_authenticator/api/request_api.go`
- [JWT handling](https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/cmd/serve/jwt_token.go): `pwm_authenticator/cmd/serve/jwt_token.go`
- [Password hashing](https://github.com/t4ke0/pwm/blob/develop/pwm_authenticator/passwords/manage_passwords.go): `pwm_authenticator/passwords/manage_passwords.go`
- [Key manager](https://github.com/t4ke0/pwm/blob/develop/keys_manager/server/server.go): `keys_manager/server/server.go`
- [Key cryptography](https://github.com/t4ke0/pwm/blob/develop/keys_manager/common/encryption_keys.go): `keys_manager/common/encryption_keys.go`
- [Key RPC contract](https://github.com/t4ke0/pwm/blob/develop/keys_manager/proto/keymanager.proto): `keys_manager/proto/keymanager.proto`

### Password vault

- [Vault manager](https://github.com/t4ke0/pwm/blob/develop/pwm_manager/server/main.go): `pwm_manager/server/main.go`
- [Vault RPC contract](https://github.com/t4ke0/pwm/blob/develop/pwm_manager/proto/pwm_manager.proto): `pwm_manager/proto/pwm_manager.proto`
- [Credential encryption](https://github.com/t4ke0/pwm/blob/develop/pwm_manager/passwords/passwords_encryption.go): `pwm_manager/passwords/passwords_encryption.go`
- [Password generator](https://github.com/t4ke0/pwm/blob/develop/pwm_manager/pw_generator/generator.go): `pwm_manager/pw_generator/generator.go`

### Persistence

- [Database access](https://github.com/t4ke0/pwm/blob/develop/pwm_db_api/db.go): `pwm_db_api/db.go`
- [PostgreSQL](https://github.com/t4ke0/pwm/blob/develop/pwm_db_api/schema.sql): `pwm_db_api/schema.sql`

### Other components

- **Vault user**

## Connections

- Vault user → REST gateway: uses (evidence: `gateway/cmd/serve/main.go`)
- REST gateway → Gateway API models: maps requests (evidence: `gateway/cmd/serve/main.go`)
- REST gateway → Vault manager: calls RPC (evidence: `gateway/cmd/serve/main.go`)
- Vault user → Registration and login: registers or logs in (evidence: `pwm_authenticator/cmd/serve/main.go`)
- Registration and login → Auth request models: binds requests (evidence: `pwm_authenticator/cmd/serve/main.go`)
- Registration and login → Password hashing: hashes passwords (evidence: `pwm_authenticator/cmd/serve/main.go`)
- Registration and login → JWT handling: issues and parses (evidence: `pwm_authenticator/cmd/serve/main.go`)
- Registration and login → Key manager: requests keys (evidence: `pwm_authenticator/cmd/serve/main.go`)
- Key manager → Key RPC contract: implements RPC (evidence: `keys_manager/server/server.go`)
- Key manager → Key cryptography: generates and decrypts (evidence: `keys_manager/server/server.go`)
- Vault manager → Vault RPC contract: implements RPC (evidence: `pwm_manager/server/main.go`)
- Vault manager → Registration and login: fetches token claims (evidence: `pwm_manager/server/main.go`)
- Vault manager → Credential encryption: encrypts and decrypts (evidence: `pwm_manager/server/main.go`)
- Vault manager → Password generator: generates passwords (evidence: `pwm_manager/server/main.go`)
- Registration and login → Database access: reads and writes users (evidence: `pwm_authenticator/cmd/serve/main.go`)
- Key manager → Database access: loads and stores keys (evidence: `keys_manager/server/server.go`)
- Vault manager → Database access: reads and writes credentials (evidence: `pwm_manager/server/main.go`)
- Database access → PostgreSQL: queries (evidence: `pwm_db_api/db.go`)
