# lyfe00011/levanter architecture

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

- Interactive diagram: https://gitdiagram.com/lyfe00011/levanter
- Repository: https://github.com/lyfe00011/levanter

## Overview

Levanter is a multi-session WhatsApp bot with a plugin-driven command surface and an optional authenticated HTTP/webhook API. Its principal workflow starts the configured instance, connects WhatsApp sessions, handles user commands through plugins, and returns replies or performs group/media actions. The README also documents API sends, session listing, media retrieval and incoming-message webhooks. Source excerpts establish startup and several plugin-to-library calls; most client, API and handler internals were not sampled, so their detailed dispatch and persistence links are intentionally limited.

Main entry points: [`lib/index.js`](https://github.com/lyfe00011/levanter/blob/master/lib/index.js) (Bot command runtime), [`lib/client.js`](https://github.com/lyfe00011/levanter/blob/master/lib/client.js) (WhatsApp client), [`index.js`](https://github.com/lyfe00011/levanter/blob/master/index.js) (Process startup), [`lib/api.js`](https://github.com/lyfe00011/levanter/blob/master/lib/api.js) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and sessions"]
  node_startup["Process startup<br/>[index.js]"]
  node_configuration["Configuration<br/>[config.js]"]
  node_client["WhatsApp client<br/>[client.js]"]
end

subgraph group_commands["Bot capabilities"]
  node_command_plugins["Command plugins"]
  node_group_admin["Group administration<br/>[group.js]"]
  node_moderation["Group moderation<br/>[antiLink.js]"]
  node_media_tools["Media tools<br/>[media.js]"]
  node_photo_editor["Photo editor<br/>[editor.js]"]
  node_task_tools["Google Tasks<br/>[task.js]"]
  node_command_runtime["Bot command runtime<br/>[index.js]"]
  node_message_handling["Message handling<br/>[handle.js]"]
end

subgraph group_state["State and localization"]
  node_session_state[("Session state<br/>[session.js]")]
  node_database[("Database access<br/>[index.js]")]
  node_language["Localized responses<br/>[lang.js]"]
end

subgraph group_gateway["HTTP API"]
  node_api["HTTP API<br/>[api.js]"]
  node_webhook["Incoming webhooks<br/>[api.js]"]
  node_media_cache[("Received media cache<br/>[api.js]")]
end

node_operator(("Operator"))
node_whatsapp(("WhatsApp users"))
node_external_app(("External app"))

node_operator -->|"starts"| node_startup
node_startup -->|"reads settings"| node_configuration
node_startup -->|"authenticates"| node_database
node_startup -->|"connects"| node_client
node_whatsapp -.->|"messages"| node_client
node_client -.->|"dispatches commands"| node_command_runtime
node_command_plugins -->|"registers commands"| node_command_runtime
node_command_runtime -.->|"handles messages"| node_message_handling
node_group_admin -->|"registers commands"| node_command_runtime
node_moderation -->|"registers commands"| node_command_runtime
node_media_tools -->|"registers commands"| node_command_runtime
node_photo_editor -->|"registers commands"| node_command_runtime
node_task_tools -->|"registers commands"| node_command_runtime
node_moderation -->|"reads and updates"| node_database
node_task_tools -.->|"uses Google Tasks"| node_external_app
node_operator -->|"sends requests"| node_api
node_api -->|"sends via sessions"| node_client
node_api -->|"serves cached media"| node_media_cache
node_client -->|"forwards messages"| node_webhook
node_webhook -->|"posts payloads"| node_external_app
node_external_app -->|"downloads media"| node_api

click node_startup "https://github.com/lyfe00011/levanter/blob/master/index.js"
click node_configuration "https://github.com/lyfe00011/levanter/blob/master/config.js"
click node_client "https://github.com/lyfe00011/levanter/blob/master/lib/client.js"
click node_session_state "https://github.com/lyfe00011/levanter/blob/master/lib/db/session.js"
click node_command_plugins "https://github.com/lyfe00011/levanter/tree/master/plugins"
click node_group_admin "https://github.com/lyfe00011/levanter/blob/master/plugins/group.js"
click node_moderation "https://github.com/lyfe00011/levanter/blob/master/plugins/antiLink.js"
click node_media_tools "https://github.com/lyfe00011/levanter/blob/master/plugins/media.js"
click node_photo_editor "https://github.com/lyfe00011/levanter/blob/master/plugins/editor.js"
click node_task_tools "https://github.com/lyfe00011/levanter/blob/master/plugins/task.js"
click node_command_runtime "https://github.com/lyfe00011/levanter/blob/master/lib/index.js"
click node_message_handling "https://github.com/lyfe00011/levanter/blob/master/lib/handle.js"
click node_database "https://github.com/lyfe00011/levanter/blob/master/lib/db/index.js"
click node_language "https://github.com/lyfe00011/levanter/blob/master/lib/lang.js"
click node_api "https://github.com/lyfe00011/levanter/blob/master/lib/api.js"
click node_webhook "https://github.com/lyfe00011/levanter/blob/master/lib/api.js"
click node_media_cache "https://github.com/lyfe00011/levanter/blob/master/lib/api.js"

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_startup,node_configuration,node_client,node_whatsapp toneBlue
class node_command_plugins,node_group_admin,node_moderation,node_media_tools,node_photo_editor,node_task_tools,node_command_runtime,node_message_handling toneAmber
class node_session_state,node_database,node_language toneMint
class node_api,node_webhook,node_media_cache toneRose
class node_operator,node_external_app toneIndigo
```

## Components

### Runtime and sessions

- [Process startup](https://github.com/lyfe00011/levanter/blob/master/index.js): `index.js`
- [Configuration](https://github.com/lyfe00011/levanter/blob/master/config.js): `config.js`
- [WhatsApp client](https://github.com/lyfe00011/levanter/blob/master/lib/client.js): `lib/client.js`

### Bot capabilities

- [Command plugins](https://github.com/lyfe00011/levanter/tree/master/plugins): `plugins`
- [Group administration](https://github.com/lyfe00011/levanter/blob/master/plugins/group.js): `plugins/group.js`
- [Group moderation](https://github.com/lyfe00011/levanter/blob/master/plugins/antiLink.js): `plugins/antiLink.js`
- [Media tools](https://github.com/lyfe00011/levanter/blob/master/plugins/media.js): `plugins/media.js`
- [Photo editor](https://github.com/lyfe00011/levanter/blob/master/plugins/editor.js): `plugins/editor.js`
- [Google Tasks](https://github.com/lyfe00011/levanter/blob/master/plugins/task.js): `plugins/task.js`
- [Bot command runtime](https://github.com/lyfe00011/levanter/blob/master/lib/index.js): `lib/index.js`
- [Message handling](https://github.com/lyfe00011/levanter/blob/master/lib/handle.js): `lib/handle.js`

### State and localization

- [Session state](https://github.com/lyfe00011/levanter/blob/master/lib/db/session.js): `lib/db/session.js`
- [Database access](https://github.com/lyfe00011/levanter/blob/master/lib/db/index.js): `lib/db/index.js`
- [Localized responses](https://github.com/lyfe00011/levanter/blob/master/lib/lang.js): `lib/lang.js`

### HTTP API

- [HTTP API](https://github.com/lyfe00011/levanter/blob/master/lib/api.js): `lib/api.js`
- [Incoming webhooks](https://github.com/lyfe00011/levanter/blob/master/lib/api.js): `lib/api.js`
- [Received media cache](https://github.com/lyfe00011/levanter/blob/master/lib/api.js): `lib/api.js`

### Other components

- **Operator**
- **WhatsApp users**
- **External app**

## Connections

- Operator → Process startup: starts (evidence: `index.js`)
- Process startup → Configuration: reads settings (evidence: `index.js`)
- Process startup → Database access: authenticates (evidence: `index.js`)
- Process startup → WhatsApp client: connects (evidence: `index.js`)
- WhatsApp users → WhatsApp client: messages
- WhatsApp client → Bot command runtime: dispatches commands
- Command plugins → Bot command runtime: registers commands (evidence: `plugins/openrouter.js`)
- Bot command runtime → Message handling: handles messages
- Group administration → Bot command runtime: registers commands (evidence: `plugins/group.js`)
- Group moderation → Bot command runtime: registers commands (evidence: `plugins/antiLink.js`)
- Media tools → Bot command runtime: registers commands (evidence: `plugins/media.js`)
- Photo editor → Bot command runtime: registers commands (evidence: `plugins/editor.js`)
- Google Tasks → Bot command runtime: registers commands (evidence: `plugins/task.js`)
- Group moderation → Database access: reads and updates (evidence: `plugins/antiLink.js`)
- Google Tasks → External app: uses Google Tasks
- Operator → HTTP API: sends requests (evidence: `README.md`)
- HTTP API → WhatsApp client: sends via sessions (evidence: `README.md`)
- HTTP API → Received media cache: serves cached media (evidence: `README.md`)
- WhatsApp client → Incoming webhooks: forwards messages (evidence: `README.md`)
- Incoming webhooks → External app: posts payloads (evidence: `README.md`)
- External app → HTTP API: downloads media (evidence: `README.md`)
