# lawrencenjeri4-lgtm/kenya-ultra architecture

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

- Interactive diagram: https://gitdiagram.com/lawrencenjeri4-lgtm/kenya-ultra
- Repository: https://github.com/lawrencenjeri4-lgtm/kenya-ultra

## Overview

Kenya-Ultra is a Node.js WhatsApp automation client. Its main workflow restores a SESSION_ID-backed auth state, creates a WhatsApp socket, listens for messages and commands, and sends responses; it also delegates settings and command execution to Kenya-Ultra Core. The README additionally describes pair-code login, session recovery, and multi-platform deployment. The graph includes the documented login capability, but deployment is hosting rather than runtime behavior. Source excerpts show the key startup and media paths; unsampled command branches are represented at the index boundary without inferring their internal calls.

Main entry points: [`index.js`](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/index.js) (Command handling), [`sessionBootstrap.js`](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/sessionBootstrap.js) (Auth bootstrap), [`core.js`](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/core.js) (Core API client), [`baileys.js`](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/baileys.js) (Socket and media)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Session and connection"]
  node_auth["Auth bootstrap"]
  node_authfiles[("Local auth state")]
end

subgraph group_messaging["WhatsApp messaging"]
  node_socket["Socket and media<br/>[baileys.js]"]
  node_runtime["Bot runtime<br/>[index.js]"]
  node_governor["Outbound send governor<br/>[sendGovernor.js]"]
end

subgraph group_core["Kenya-Ultra Core"]
  node_coreapi["Core API client<br/>[core.js]"]
end

subgraph group_features["Bot features and operations"]
  node_commands["Command handling<br/>[index.js]"]
  node_actions["Client actions<br/>[clientActions.js]"]
  node_stickers["Sticker processing<br/>[stickerUtils.js]"]
  node_activitylog["Message and activity logs<br/>[consoleLog.js]"]
end

node_operator(("Bot operator"))
node_pairing["Pairing portal"]
node_wa["WhatsApp"]
node_core["Kenya-Ultra Core"]

node_operator -.->|"generates session"| node_pairing
node_operator -->|"configures session"| node_auth
node_pairing -.->|"provides SESSION_ID"| node_auth
node_auth -->|"loads and saves"| node_authfiles
node_auth -->|"validates session"| node_coreapi
node_coreapi -->|"calls validation"| node_core
node_auth -->|"returns auth state"| node_runtime
node_runtime -->|"creates connection"| node_socket
node_socket -->|"connects and downloads media"| node_wa
node_wa -.->|"delivers events"| node_runtime
node_runtime -->|"dispatches commands"| node_commands
node_commands -.->|"requests settings and execution"| node_coreapi
node_coreapi -->|"calls Core endpoints"| node_core
node_commands -->|"invokes actions"| node_actions
node_commands -->|"creates or retags"| node_stickers
node_commands -->|"downloads quoted media"| node_socket
node_commands -->|"sends responses through"| node_governor
node_runtime -->|"wraps socket sender"| node_governor
node_governor -->|"queues and sends messages"| node_wa
node_runtime -->|"logs incoming messages"| node_activitylog

click node_auth "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/sessionBootstrap.js"
click node_coreapi "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/core.js"
click node_socket "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/baileys.js"
click node_runtime "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/index.js"
click node_commands "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/index.js"
click node_actions "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/clientActions.js"
click node_stickers "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/stickerUtils.js"
click node_governor "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/sendGovernor.js"
click node_activitylog "https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/consoleLog.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_auth,node_authfiles toneBlue
class node_socket,node_runtime,node_governor toneAmber
class node_coreapi toneMint
class node_commands,node_actions,node_stickers,node_activitylog toneRose
class node_operator,node_pairing,node_wa,node_core toneIndigo
```

## Components

### Session and connection

- [Auth bootstrap](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/sessionBootstrap.js): `sessionBootstrap.js`
- **Local auth state**

### WhatsApp messaging

- [Socket and media](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/baileys.js): `baileys.js`
- [Bot runtime](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/index.js): `index.js`
- [Outbound send governor](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/sendGovernor.js): `sendGovernor.js`

### Kenya-Ultra Core

- [Core API client](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/core.js): `core.js`

### Bot features and operations

- [Command handling](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/index.js): `index.js`
- [Client actions](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/clientActions.js): `clientActions.js`
- [Sticker processing](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/stickerUtils.js): `stickerUtils.js`
- [Message and activity logs](https://github.com/lawrencenjeri4-lgtm/kenya-ultra/blob/main/consoleLog.js): `consoleLog.js`

### Other components

- **Bot operator**
- **Pairing portal**
- **WhatsApp**
- **Kenya-Ultra Core**

## Connections

- Bot operator → Pairing portal: generates session (evidence: `README.md`)
- Bot operator → Auth bootstrap: configures session (evidence: `README.md`)
- Pairing portal → Auth bootstrap: provides SESSION_ID (evidence: `README.md`)
- Auth bootstrap → Local auth state: loads and saves (evidence: `sessionBootstrap.js`)
- Auth bootstrap → Core API client: validates session (evidence: `sessionBootstrap.js`)
- Core API client → Kenya-Ultra Core: calls validation (evidence: `core.js`)
- Auth bootstrap → Bot runtime: returns auth state (evidence: `index.js`)
- Bot runtime → Socket and media: creates connection (evidence: `index.js`)
- Socket and media → WhatsApp: connects and downloads media (evidence: `baileys.js`)
- WhatsApp → Bot runtime: delivers events
- Bot runtime → Command handling: dispatches commands (evidence: `index.js`)
- Command handling → Core API client: requests settings and execution (evidence: `index.js`)
- Core API client → Kenya-Ultra Core: calls Core endpoints (evidence: `core.js`)
- Command handling → Client actions: invokes actions (evidence: `index.js`)
- Command handling → Sticker processing: creates or retags (evidence: `index.js`)
- Command handling → Socket and media: downloads quoted media (evidence: `index.js`)
- Command handling → Outbound send governor: sends responses through (evidence: `index.js`)
- Bot runtime → Outbound send governor: wraps socket sender (evidence: `index.js`)
- Outbound send governor → WhatsApp: queues and sends messages (evidence: `sendGovernor.js`)
- Bot runtime → Message and activity logs: logs incoming messages (evidence: `index.js`)
