# azahrina/bot architecture

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

- Interactive diagram: https://gitdiagram.com/azahrina/bot
- Repository: https://github.com/azahrina/bot

## Overview

Ninja Bot Server Engine is a localhost backend for a browser-extension-driven Instagram automation workflow: the extension sends session or task requests to the server, which prepares an Instagram client and invokes automation actions; results and logs return through the server. The engine also supports feed posting, Stories and link stickers, account setup, direct messages, profile actions, and media/font management. README capabilities fill gaps in the sampled source; unsampled route wiring is represented only at the server boundary.

Main entry points: [`server.js`](https://github.com/azahrina/bot/blob/main/server.js) (HTTP Server), [`index.js`](https://github.com/azahrina/bot/blob/main/index.js) (Instagram Client), [`worker.js`](https://github.com/azahrina/bot/blob/main/worker.js) (Task Worker), [`fonts`](https://github.com/azahrina/bot/tree/main/fonts) (Custom Fonts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Extension API"]
  node_server["HTTP Server<br/>[server.js]"]
  node_session["Session Handling<br/>[server.js]"]
  node_taskcontrol["Task Control<br/>[server.js]"]
  node_logs["Log Streaming<br/>[server.js]"]
end

subgraph group_engine["Automation Engine"]
  node_instagram["Instagram Client<br/>[index.js]"]
  node_feed["Feed Publishing<br/>[index.js]"]
  node_stories["Stories and Links<br/>[index.js]"]
  node_accountsetup["Account Setup<br/>[index.js]"]
  node_direct["Direct Messages<br/>[index.js]"]
  node_accountactions["Account Actions<br/>[index.js]"]
end

subgraph group_content["Content and Media"]
  node_contentfiles["Media and Templates<br/>[server.js]"]
  node_fonts["Custom Fonts"]
  node_shortlinks["Shortlink Presets"]
  node_userdata[("User Data")]
end

subgraph group_runtime["Runtime State"]
  node_worker["Task Worker<br/>[worker.js]"]
  node_taskstate["Task State<br/>[server.js]"]
end

node_extension(("Browser Extension"))
node_instagramservice["Instagram Service"]
node_shortlinkservice["Shortlink Provider"]
node_emojiassets["Emoji CDN"]

node_extension -->|"sends requests"| node_server
node_server -->|"routes sessions"| node_session
node_server -->|"dispatches tasks"| node_taskcontrol
node_server -->|"serves logs"| node_logs
node_session -->|"creates client"| node_instagram
node_taskcontrol -->|"starts or stops"| node_worker
node_worker -->|"loads and invokes"| node_instagram
node_instagram -->|"calls API"| node_instagramservice
node_server -->|"lists and uploads"| node_contentfiles
node_contentfiles -->|"reads and writes"| node_userdata
node_server -->|"tracks tasks"| node_taskstate
node_taskcontrol -->|"updates state"| node_taskstate
node_server -->|"handles feed routes"| node_feed
node_server -->|"handles story routes"| node_stories
node_server -->|"handles DM routes"| node_direct
node_server -->|"handles action routes"| node_accountactions
node_server -->|"handles setup routes"| node_accountsetup
node_feed -->|"publishes media"| node_instagram
node_stories -->|"publishes stories"| node_instagram
node_direct -->|"sends messages"| node_instagram
node_accountactions -->|"performs actions"| node_instagram
node_accountsetup -->|"runs setup"| node_instagram
node_stories -->|"reads presets"| node_shortlinks
node_stories -.->|"requests shortening"| node_shortlinkservice
node_stories -.->|"downloads emoji"| node_emojiassets
node_feed -->|"reads media"| node_userdata
node_stories -->|"uses fonts"| node_fonts
node_logs -->|"streams logs"| node_extension

click node_server "https://github.com/azahrina/bot/blob/main/server.js"
click node_session "https://github.com/azahrina/bot/blob/main/server.js"
click node_taskcontrol "https://github.com/azahrina/bot/blob/main/server.js"
click node_logs "https://github.com/azahrina/bot/blob/main/server.js"
click node_worker "https://github.com/azahrina/bot/blob/main/worker.js"
click node_instagram "https://github.com/azahrina/bot/blob/main/index.js"
click node_feed "https://github.com/azahrina/bot/blob/main/index.js"
click node_stories "https://github.com/azahrina/bot/blob/main/index.js"
click node_accountsetup "https://github.com/azahrina/bot/blob/main/index.js"
click node_direct "https://github.com/azahrina/bot/blob/main/index.js"
click node_accountactions "https://github.com/azahrina/bot/blob/main/index.js"
click node_contentfiles "https://github.com/azahrina/bot/blob/main/server.js"
click node_fonts "https://github.com/azahrina/bot/tree/main/fonts"
click node_shortlinks "https://github.com/azahrina/bot/blob/main/shortlink_urls.json"
click node_taskstate "https://github.com/azahrina/bot/blob/main/server.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_server,node_session,node_taskcontrol,node_logs,node_extension toneBlue
class node_instagram,node_feed,node_stories,node_accountsetup,node_direct,node_accountactions toneAmber
class node_contentfiles,node_fonts,node_shortlinks,node_userdata toneMint
class node_worker,node_taskstate toneRose
class node_instagramservice,node_shortlinkservice,node_emojiassets toneIndigo
```

## Components

### Extension API

- [HTTP Server](https://github.com/azahrina/bot/blob/main/server.js): `server.js`
- [Session Handling](https://github.com/azahrina/bot/blob/main/server.js): `server.js`
- [Task Control](https://github.com/azahrina/bot/blob/main/server.js): `server.js`
- [Log Streaming](https://github.com/azahrina/bot/blob/main/server.js): `server.js`

### Automation Engine

- [Instagram Client](https://github.com/azahrina/bot/blob/main/index.js): `index.js`
- [Feed Publishing](https://github.com/azahrina/bot/blob/main/index.js): `index.js`
- [Stories and Links](https://github.com/azahrina/bot/blob/main/index.js): `index.js`
- [Account Setup](https://github.com/azahrina/bot/blob/main/index.js): `index.js`
- [Direct Messages](https://github.com/azahrina/bot/blob/main/index.js): `index.js`
- [Account Actions](https://github.com/azahrina/bot/blob/main/index.js): `index.js`

### Content and Media

- [Media and Templates](https://github.com/azahrina/bot/blob/main/server.js): `server.js`
- [Custom Fonts](https://github.com/azahrina/bot/tree/main/fonts): `fonts`
- [Shortlink Presets](https://github.com/azahrina/bot/blob/main/shortlink_urls.json): `shortlink_urls.json`
- **User Data**

### Runtime State

- [Task Worker](https://github.com/azahrina/bot/blob/main/worker.js): `worker.js`
- [Task State](https://github.com/azahrina/bot/blob/main/server.js): `server.js`

### Other components

- **Browser Extension**
- **Instagram Service**
- **Shortlink Provider**
- **Emoji CDN**

## Connections

- Browser Extension → HTTP Server: sends requests
- HTTP Server → Session Handling: routes sessions
- HTTP Server → Task Control: dispatches tasks
- HTTP Server → Log Streaming: serves logs
- Session Handling → Instagram Client: creates client
- Task Control → Task Worker: starts or stops
- Task Worker → Instagram Client: loads and invokes
- Instagram Client → Instagram Service: calls API
- HTTP Server → Media and Templates: lists and uploads
- Media and Templates → User Data: reads and writes
- HTTP Server → Task State: tracks tasks
- Task Control → Task State: updates state
- HTTP Server → Feed Publishing: handles feed routes
- HTTP Server → Stories and Links: handles story routes
- HTTP Server → Direct Messages: handles DM routes
- HTTP Server → Account Actions: handles action routes
- HTTP Server → Account Setup: handles setup routes
- Feed Publishing → Instagram Client: publishes media
- Stories and Links → Instagram Client: publishes stories
- Direct Messages → Instagram Client: sends messages
- Account Actions → Instagram Client: performs actions
- Account Setup → Instagram Client: runs setup
- Stories and Links → Shortlink Presets: reads presets
- Stories and Links → Shortlink Provider: requests shortening
- Stories and Links → Emoji CDN: downloads emoji
- Feed Publishing → User Data: reads media
- Stories and Links → Custom Fonts: uses fonts
- Log Streaming → Browser Extension: streams logs
