# cellbis/mojo-hakkefuin architecture

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

- Interactive diagram: https://gitdiagram.com/cellbis/mojo-hakkefuin
- Repository: https://github.com/cellbis/mojo-hakkefuin

## Overview

Hakkefuin is a Mojolicious authentication plugin: an application registers it, requests use its helpers to sign in or validate sessions, and configured database backends persist authentication and lock state. The README also documents CSRF token handling, cookie/session expiry, token rotation, optional locking, and three database drivers. Relationships below are limited to those described in the README; source excerpts were not available, so internal call details are not inferred.

Main entry points: [`lib/Mojolicious/Plugin/Hakkefuin.pm`](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojolicious/Plugin/Hakkefuin.pm) (Plugin setup), [`lib/Mojo/Hakkefuin.pm`](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin.pm) (Auth helpers), [`lib/Mojo/Hakkefuin/Backend/sqlite.pm`](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/sqlite.pm) (SQLite backend), [`lib/Mojo/Hakkefuin/Backend/mariadb.pm`](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/mariadb.pm) (MariaDB backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Mojolicious integration"]
  node_plugin["Plugin setup<br/>[Hakkefuin.pm]"]
end

subgraph group_auth["Authentication and sessions"]
  node_auth_helpers["Auth helpers<br/>[Hakkefuin.pm]"]
  node_session_manager["Session manager<br/>[Sessions.pm]"]
  node_utilities["Utilities<br/>[Utils.pm]"]
end

subgraph group_storage["Database backends"]
  node_sqlite_backend["SQLite backend<br/>[sqlite.pm]"]
  node_mariadb_backend["MariaDB backend<br/>[mariadb.pm]"]
  node_pg_backend["PostgreSQL backend<br/>[pg.pm]"]
  node_backend_interface["Backend interface<br/>[Backend.pm]"]
end

node_application(("Mojolicious app"))
node_request(("HTTP request"))
node_database[("Database")]

node_application -->|"registers"| node_plugin
node_plugin -->|"registers helpers"| node_auth_helpers
node_plugin -->|"attaches shared"| node_session_manager
node_plugin -->|"selects by config"| node_sqlite_backend
node_plugin -->|"selects by config"| node_mariadb_backend
node_plugin -->|"selects by config"| node_pg_backend
node_request -->|"uses helpers"| node_auth_helpers
node_auth_helpers -->|"checks or updates"| node_sqlite_backend
node_auth_helpers -->|"checks or updates"| node_mariadb_backend
node_auth_helpers -->|"checks or updates"| node_pg_backend
node_sqlite_backend -->|"reads and writes"| node_database
node_mariadb_backend -->|"reads and writes"| node_database
node_pg_backend -->|"reads and writes"| node_database

click node_plugin "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojolicious/Plugin/Hakkefuin.pm"
click node_auth_helpers "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin.pm"
click node_session_manager "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Sessions.pm"
click node_utilities "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Utils.pm"
click node_sqlite_backend "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/sqlite.pm"
click node_mariadb_backend "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/mariadb.pm"
click node_pg_backend "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/pg.pm"
click node_backend_interface "https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend.pm"

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_plugin toneBlue
class node_auth_helpers,node_session_manager,node_utilities,node_database toneAmber
class node_sqlite_backend,node_mariadb_backend,node_pg_backend,node_backend_interface,node_request toneMint
class node_application toneIndigo
```

## Components

### Mojolicious integration

- [Plugin setup](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojolicious/Plugin/Hakkefuin.pm): `lib/Mojolicious/Plugin/Hakkefuin.pm`

### Authentication and sessions

- [Auth helpers](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin.pm): `lib/Mojo/Hakkefuin.pm`
- [Session manager](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Sessions.pm): `lib/Mojo/Hakkefuin/Sessions.pm`
- [Utilities](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Utils.pm): `lib/Mojo/Hakkefuin/Utils.pm`

### Database backends

- [SQLite backend](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/sqlite.pm): `lib/Mojo/Hakkefuin/Backend/sqlite.pm`
- [MariaDB backend](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/mariadb.pm): `lib/Mojo/Hakkefuin/Backend/mariadb.pm`
- [PostgreSQL backend](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend/pg.pm): `lib/Mojo/Hakkefuin/Backend/pg.pm`
- [Backend interface](https://github.com/cellbis/mojo-hakkefuin/blob/master/lib/Mojo/Hakkefuin/Backend.pm): `lib/Mojo/Hakkefuin/Backend.pm`

### Other components

- **Mojolicious app**
- **HTTP request**
- **Database**

## Connections

- Mojolicious app → Plugin setup: registers (evidence: `README.md`)
- Plugin setup → Auth helpers: registers helpers (evidence: `README.md`)
- Plugin setup → Session manager: attaches shared (evidence: `README.md`)
- Plugin setup → SQLite backend: selects by config (evidence: `README.md`)
- Plugin setup → MariaDB backend: selects by config (evidence: `README.md`)
- Plugin setup → PostgreSQL backend: selects by config (evidence: `README.md`)
- HTTP request → Auth helpers: uses helpers (evidence: `README.md`)
- Auth helpers → SQLite backend: checks or updates (evidence: `README.md`)
- Auth helpers → MariaDB backend: checks or updates (evidence: `README.md`)
- Auth helpers → PostgreSQL backend: checks or updates (evidence: `README.md`)
- SQLite backend → Database: reads and writes (evidence: `README.md`)
- MariaDB backend → Database: reads and writes (evidence: `README.md`)
- PostgreSQL backend → Database: reads and writes (evidence: `README.md`)
