# crydensync/cryden architecture

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

- Interactive diagram: https://gitdiagram.com/crydensync/cryden
- Repository: https://github.com/crydensync/cryden

## Overview

CrydenSync is an embeddable Go authentication engine: a host application configures an Engine with stores and security dependencies, calls the framework-neutral public facade for identity operations, and receives tokens or operation results. The product spans account authentication, sessions and tokens, optional second factors and integrations, plus administration and safe AI-assisted querying. The README documents these capabilities and storage choices; sampled source confirms engine wiring, WebAuthn handling, and safe-query behavior. Some subsystem links therefore cite the README rather than unsampled implementation.

Main entry points: [`cryden.go`](https://github.com/crydensync/cryden/blob/main/cryden.go) (Public facade), [`engine.go`](https://github.com/crydensync/cryden/blob/main/engine.go) (Engine wiring), [`auth/login.go`](https://github.com/crydensync/cryden/blob/main/auth/login.go) (Account auth), [`auth/webauthn.go`](https://github.com/crydensync/cryden/blob/main/auth/webauthn.go) (MFA and passkeys)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Engine and identity"]
  node_facade["Public facade<br/>[cryden.go]"]
  node_engine["Engine wiring<br/>[engine.go]"]
  node_accounts["Account auth<br/>[login.go]"]
  node_oauth["OAuth identities<br/>[oauth.go]"]
  node_api_keys["API keys<br/>[apikeys.go]"]
end

subgraph group_security["Security and sessions"]
  node_tokens["Tokens and claims<br/>[jwt.go]"]
  node_sessions["Session lifecycle<br/>[session.go]"]
  node_mfa["MFA and passkeys<br/>[webauthn.go]"]
  node_security_controls["Security controls<br/>[anomaly.go]"]
end

subgraph group_storage["Persistence backends"]
  node_store_contracts["Store interfaces<br/>[interfaces.go]"]
  node_memory[("Memory stores<br/>[user_store.go]")]
  node_postgres[("Postgres stores<br/>[user_store.go]")]
  node_sqlite[("SQLite stores<br/>[user_store.go]")]
end

subgraph group_extensions["Product extensions"]
  node_email_notify["Email delivery hooks<br/>[email_sender.go]"]
  node_webhooks["Webhook events<br/>[webhooks.go]"]
  node_admin_digest["Audit digest<br/>[digest.go]"]
  node_admin_tuning["Config advisor<br/>[tuning.go]"]
  node_support["Support assistant<br/>[support.go]"]
  node_widget["AI query widget<br/>[ask.go]"]
  node_ai_query["Query validation<br/>[validate.go]"]
  node_safe_query["Safe query store"]
end

node_host(("Host application"))

node_host -->|"configures"| node_engine
node_host -->|"calls operations"| node_facade
node_facade -->|"uses"| node_engine
node_engine -.->|"wires dependencies"| node_accounts
node_facade -->|"dispatches auth"| node_accounts
node_facade -->|"dispatches OAuth"| node_oauth
node_facade -.->|"dispatches key auth"| node_api_keys
node_accounts -->|"issues tokens"| node_tokens
node_accounts -->|"creates sessions"| node_sessions
node_accounts -.->|"supports second factor"| node_mfa
node_engine -->|"constructs issuer"| node_tokens
node_engine -->|"wires controls"| node_security_controls
node_engine -->|"accepts stores"| node_store_contracts
node_mfa -->|"verifies pending token"| node_tokens
node_mfa -->|"stores credentials"| node_store_contracts
node_facade -->|"invokes sender"| node_email_notify
node_facade -->|"delivers events"| node_webhooks
node_facade -.->|"offers digest"| node_admin_digest
node_facade -.->|"offers tuning advice"| node_admin_tuning
node_facade -.->|"offers support tools"| node_support
node_host -.->|"uses widget"| node_widget
node_widget -->|"requests query"| node_ai_query
node_ai_query -.->|"validates then queries"| node_safe_query
node_safe_query -->|"reads safely"| node_sqlite
node_safe_query -.->|"alternate backend"| node_postgres
node_engine -->|"can use"| node_memory
node_engine -->|"can use"| node_postgres
node_engine -->|"can use"| node_sqlite

click node_facade "https://github.com/crydensync/cryden/blob/main/cryden.go"
click node_engine "https://github.com/crydensync/cryden/blob/main/engine.go"
click node_accounts "https://github.com/crydensync/cryden/blob/main/auth/login.go"
click node_oauth "https://github.com/crydensync/cryden/blob/main/auth/oauth.go"
click node_api_keys "https://github.com/crydensync/cryden/blob/main/auth/apikeys.go"
click node_tokens "https://github.com/crydensync/cryden/blob/main/token/jwt.go"
click node_sessions "https://github.com/crydensync/cryden/blob/main/session/session.go"
click node_mfa "https://github.com/crydensync/cryden/blob/main/auth/webauthn.go"
click node_security_controls "https://github.com/crydensync/cryden/blob/main/security/anomaly.go"
click node_email_notify "https://github.com/crydensync/cryden/blob/main/notify/email_sender.go"
click node_webhooks "https://github.com/crydensync/cryden/blob/main/webhooks.go"
click node_admin_digest "https://github.com/crydensync/cryden/blob/main/admin/digest.go"
click node_admin_tuning "https://github.com/crydensync/cryden/blob/main/admin/tuning.go"
click node_support "https://github.com/crydensync/cryden/blob/main/admin/support.go"
click node_widget "https://github.com/crydensync/cryden/blob/main/widget/ask.go"
click node_ai_query "https://github.com/crydensync/cryden/blob/main/ai/validate.go"
click node_safe_query "https://github.com/crydensync/cryden/blob/main/store/sqlite/safe_query_store.go"
click node_store_contracts "https://github.com/crydensync/cryden/blob/main/store/interfaces.go"
click node_memory "https://github.com/crydensync/cryden/blob/main/store/memory/user_store.go"
click node_postgres "https://github.com/crydensync/cryden/blob/main/store/postgres/user_store.go"
click node_sqlite "https://github.com/crydensync/cryden/blob/main/store/sqlite/user_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_facade,node_engine,node_accounts,node_oauth,node_api_keys toneBlue
class node_tokens,node_sessions,node_mfa,node_security_controls toneAmber
class node_store_contracts,node_memory,node_postgres,node_sqlite toneMint
class node_email_notify,node_webhooks,node_admin_digest,node_admin_tuning,node_support,node_widget,node_ai_query,node_safe_query toneRose
class node_host toneIndigo
```

## Components

### Engine and identity

- [Public facade](https://github.com/crydensync/cryden/blob/main/cryden.go): `cryden.go`
- [Engine wiring](https://github.com/crydensync/cryden/blob/main/engine.go): `engine.go`
- [Account auth](https://github.com/crydensync/cryden/blob/main/auth/login.go): `auth/login.go`
- [OAuth identities](https://github.com/crydensync/cryden/blob/main/auth/oauth.go): `auth/oauth.go`
- [API keys](https://github.com/crydensync/cryden/blob/main/auth/apikeys.go): `auth/apikeys.go`

### Security and sessions

- [Tokens and claims](https://github.com/crydensync/cryden/blob/main/token/jwt.go): `token/jwt.go`
- [Session lifecycle](https://github.com/crydensync/cryden/blob/main/session/session.go): `session/session.go`
- [MFA and passkeys](https://github.com/crydensync/cryden/blob/main/auth/webauthn.go): `auth/webauthn.go`
- [Security controls](https://github.com/crydensync/cryden/blob/main/security/anomaly.go): `security/anomaly.go`

### Persistence backends

- [Store interfaces](https://github.com/crydensync/cryden/blob/main/store/interfaces.go): `store/interfaces.go`
- [Memory stores](https://github.com/crydensync/cryden/blob/main/store/memory/user_store.go): `store/memory/user_store.go`
- [Postgres stores](https://github.com/crydensync/cryden/blob/main/store/postgres/user_store.go): `store/postgres/user_store.go`
- [SQLite stores](https://github.com/crydensync/cryden/blob/main/store/sqlite/user_store.go): `store/sqlite/user_store.go`

### Product extensions

- [Email delivery hooks](https://github.com/crydensync/cryden/blob/main/notify/email_sender.go): `notify/email_sender.go`
- [Webhook events](https://github.com/crydensync/cryden/blob/main/webhooks.go): `webhooks.go`
- [Audit digest](https://github.com/crydensync/cryden/blob/main/admin/digest.go): `admin/digest.go`
- [Config advisor](https://github.com/crydensync/cryden/blob/main/admin/tuning.go): `admin/tuning.go`
- [Support assistant](https://github.com/crydensync/cryden/blob/main/admin/support.go): `admin/support.go`
- [AI query widget](https://github.com/crydensync/cryden/blob/main/widget/ask.go): `widget/ask.go`
- [Query validation](https://github.com/crydensync/cryden/blob/main/ai/validate.go): `ai/validate.go`
- [Safe query store](https://github.com/crydensync/cryden/blob/main/store/sqlite/safe_query_store.go): `store/sqlite/safe_query_store.go`

### Other components

- **Host application**

## Connections

- Host application → Engine wiring: configures
- Host application → Public facade: calls operations
- Public facade → Engine wiring: uses (evidence: `engine.go`)
- Engine wiring → Account auth: wires dependencies
- Public facade → Account auth: dispatches auth
- Public facade → OAuth identities: dispatches OAuth
- Public facade → API keys: dispatches key auth
- Account auth → Tokens and claims: issues tokens
- Account auth → Session lifecycle: creates sessions
- Account auth → MFA and passkeys: supports second factor
- Engine wiring → Tokens and claims: constructs issuer (evidence: `engine.go`)
- Engine wiring → Security controls: wires controls (evidence: `engine.go`)
- Engine wiring → Store interfaces: accepts stores (evidence: `engine.go`)
- MFA and passkeys → Tokens and claims: verifies pending token (evidence: `auth/webauthn.go`)
- MFA and passkeys → Store interfaces: stores credentials (evidence: `auth/webauthn.go`)
- Public facade → Email delivery hooks: invokes sender
- Public facade → Webhook events: delivers events (evidence: `webhooks.go`)
- Public facade → Audit digest: offers digest
- Public facade → Config advisor: offers tuning advice
- Public facade → Support assistant: offers support tools
- Host application → AI query widget: uses widget
- AI query widget → Query validation: requests query (evidence: `widget/ask.go`)
- Query validation → Safe query store: validates then queries
- Safe query store → SQLite stores: reads safely (evidence: `store/sqlite/safe_query_store.go`)
- Safe query store → Postgres stores: alternate backend
- Engine wiring → Memory stores: can use
- Engine wiring → Postgres stores: can use
- Engine wiring → SQLite stores: can use
