# eitaar/mipc architecture

> Architecture diagram of the GitHub repository eitaar/mipc, 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/eitaar/mipc
- Repository: https://github.com/eitaar/mipc

## Overview

This is a Discord bot for browsing and maintaining item price listings. Users invoke slash commands; the interaction handler dispatches them to command modules, which query or mutate PostgreSQL data and return replies, often formatted as embeds. Administrators have commands for managing item tables and listings, while users can view prices, lists, help, and ping. Startup also registers and loads commands, and the bot exposes a small HTTP health response. Several command implementations were not excerpted, so their detailed database and reply flows are shown only where supported or marked unverified.

Main entry points: [`other/interaction_create_handler.js`](https://github.com/eitaar/mipc/blob/main/other/interaction_create_handler.js) (Interaction dispatch), [`db.js`](https://github.com/eitaar/mipc/blob/main/db.js) (Listing queries), [`index.js`](https://github.com/eitaar/mipc/blob/main/index.js) (Bot startup), [`commands/db/bp.js`](https://github.com/eitaar/mipc/blob/main/commands/db/bp.js) (Best price)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_bot_entry["Bot startup<br/>[index.js]"]
  node_health_response["Health response<br/>[index.js]"]
  node_interaction_dispatch["Interaction dispatch"]
  node_command_loading["Command loading<br/>[load_commands.js]"]
  node_command_registration["Command registration<br/>[deploy-commands.js]"]
  node_message_test["Test message<br/>[index.js]"]
end

subgraph group_commands["Discord commands"]
  node_bestprice_command["Best price<br/>[bp.js]"]
  node_adddata_command["Add listing<br/>[adddata.js]"]
  node_deldata_command["Delete listing<br/>[deldata.js]"]
  node_newitem_command["Create item<br/>[newitem.js]"]
  node_delitem_command["Drop item<br/>[delitem.js]"]
  node_itemlist_command["Item catalog<br/>[itemlist.js]"]
  node_list_command["Listing list<br/>[list.js]"]
  node_help_command["Help command<br/>[help.js]"]
  node_ping_command["Ping command<br/>[ping.js]"]
end

subgraph group_data["Listing data"]
  node_listing_store["Listing queries<br/>[db.js]"]
end

subgraph group_presentation["Reply formatting"]
  node_embed_builders["Embed builders<br/>[embeds.js]"]
end

node_discord_user(("Discord user"))
node_discord_api["Discord API"]
node_postgres[("PostgreSQL")]
node_http_client(("Health client"))

node_discord_user -->|"invokes commands"| node_discord_api
node_discord_api -->|"emits interactions"| node_interaction_dispatch
node_bot_entry -->|"registers handler"| node_interaction_dispatch
node_bot_entry -->|"starts registration"| node_command_registration
node_bot_entry -->|"loads on ready"| node_command_loading
node_interaction_dispatch -.->|"dispatches command"| node_bestprice_command
node_interaction_dispatch -.->|"dispatches command"| node_adddata_command
node_interaction_dispatch -.->|"dispatches command"| node_deldata_command
node_interaction_dispatch -.->|"dispatches command"| node_newitem_command
node_interaction_dispatch -.->|"dispatches command"| node_delitem_command
node_interaction_dispatch -.->|"dispatches command"| node_itemlist_command
node_interaction_dispatch -.->|"dispatches command"| node_list_command
node_interaction_dispatch -.->|"dispatches command"| node_help_command
node_interaction_dispatch -.->|"dispatches command"| node_ping_command
node_command_loading -->|"fills command map"| node_discord_api
node_command_registration -->|"registers commands"| node_discord_api
node_discord_user -->|"requests price"| node_bestprice_command
node_bestprice_command -->|"queries lowest price"| node_listing_store
node_adddata_command -.->|"adds listing"| node_listing_store
node_deldata_command -.->|"deletes listing"| node_listing_store
node_newitem_command -.->|"creates table"| node_listing_store
node_delitem_command -.->|"drops table"| node_listing_store
node_itemlist_command -.->|"reads item catalog"| node_listing_store
node_list_command -.->|"reads listings"| node_listing_store
node_listing_store -->|"queries and mutates"| node_postgres
node_listing_store -->|"formats results"| node_embed_builders
node_help_command -->|"builds help embed"| node_embed_builders
node_discord_user -->|"requests help"| node_help_command
node_bot_entry -->|"handles messages"| node_message_test
node_message_test -->|"queries best price"| node_listing_store
node_http_client -->|"requests status"| node_health_response

click node_bot_entry "https://github.com/eitaar/mipc/blob/main/index.js"
click node_health_response "https://github.com/eitaar/mipc/blob/main/index.js"
click node_interaction_dispatch "https://github.com/eitaar/mipc/blob/main/other/interaction_create_handler.js"
click node_command_loading "https://github.com/eitaar/mipc/blob/main/other/load_commands.js"
click node_command_registration "https://github.com/eitaar/mipc/blob/main/other/deploy-commands.js"
click node_message_test "https://github.com/eitaar/mipc/blob/main/index.js"
click node_bestprice_command "https://github.com/eitaar/mipc/blob/main/commands/db/bp.js"
click node_adddata_command "https://github.com/eitaar/mipc/blob/main/commands/db/adddata.js"
click node_deldata_command "https://github.com/eitaar/mipc/blob/main/commands/db/deldata.js"
click node_newitem_command "https://github.com/eitaar/mipc/blob/main/commands/db/newitem.js"
click node_delitem_command "https://github.com/eitaar/mipc/blob/main/commands/db/delitem.js"
click node_itemlist_command "https://github.com/eitaar/mipc/blob/main/commands/db/itemlist.js"
click node_list_command "https://github.com/eitaar/mipc/blob/main/commands/db/list.js"
click node_help_command "https://github.com/eitaar/mipc/blob/main/commands/general/help.js"
click node_ping_command "https://github.com/eitaar/mipc/blob/main/commands/general/ping.js"
click node_listing_store "https://github.com/eitaar/mipc/blob/main/db.js"
click node_embed_builders "https://github.com/eitaar/mipc/blob/main/embeds.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_bot_entry,node_health_response,node_interaction_dispatch,node_command_loading,node_command_registration,node_message_test,node_discord_user,node_http_client toneBlue
class node_bestprice_command,node_adddata_command,node_deldata_command,node_newitem_command,node_delitem_command,node_itemlist_command,node_list_command,node_help_command,node_ping_command,node_postgres toneAmber
class node_listing_store,node_discord_api toneMint
class node_embed_builders toneRose
```

## Components

### Bot runtime

- [Bot startup](https://github.com/eitaar/mipc/blob/main/index.js): `index.js`
- [Health response](https://github.com/eitaar/mipc/blob/main/index.js): `index.js`
- [Interaction dispatch](https://github.com/eitaar/mipc/blob/main/other/interaction_create_handler.js): `other/interaction_create_handler.js`
- [Command loading](https://github.com/eitaar/mipc/blob/main/other/load_commands.js): `other/load_commands.js`
- [Command registration](https://github.com/eitaar/mipc/blob/main/other/deploy-commands.js): `other/deploy-commands.js`
- [Test message](https://github.com/eitaar/mipc/blob/main/index.js): `index.js`

### Discord commands

- [Best price](https://github.com/eitaar/mipc/blob/main/commands/db/bp.js): `commands/db/bp.js`
- [Add listing](https://github.com/eitaar/mipc/blob/main/commands/db/adddata.js): `commands/db/adddata.js`
- [Delete listing](https://github.com/eitaar/mipc/blob/main/commands/db/deldata.js): `commands/db/deldata.js`
- [Create item](https://github.com/eitaar/mipc/blob/main/commands/db/newitem.js): `commands/db/newitem.js`
- [Drop item](https://github.com/eitaar/mipc/blob/main/commands/db/delitem.js): `commands/db/delitem.js`
- [Item catalog](https://github.com/eitaar/mipc/blob/main/commands/db/itemlist.js): `commands/db/itemlist.js`
- [Listing list](https://github.com/eitaar/mipc/blob/main/commands/db/list.js): `commands/db/list.js`
- [Help command](https://github.com/eitaar/mipc/blob/main/commands/general/help.js): `commands/general/help.js`
- [Ping command](https://github.com/eitaar/mipc/blob/main/commands/general/ping.js): `commands/general/ping.js`

### Listing data

- [Listing queries](https://github.com/eitaar/mipc/blob/main/db.js): `db.js`

### Reply formatting

- [Embed builders](https://github.com/eitaar/mipc/blob/main/embeds.js): `embeds.js`

### Other components

- **Discord user**
- **Discord API**
- **PostgreSQL**
- **Health client**

## Connections

- Discord user → Discord API: invokes commands
- Discord API → Interaction dispatch: emits interactions (evidence: `other/interaction_create_handler.js`)
- Bot startup → Interaction dispatch: registers handler (evidence: `index.js`)
- Bot startup → Command registration: starts registration (evidence: `index.js`)
- Bot startup → Command loading: loads on ready (evidence: `index.js`)
- Interaction dispatch → Best price: dispatches command
- Interaction dispatch → Add listing: dispatches command
- Interaction dispatch → Delete listing: dispatches command
- Interaction dispatch → Create item: dispatches command
- Interaction dispatch → Drop item: dispatches command
- Interaction dispatch → Item catalog: dispatches command
- Interaction dispatch → Listing list: dispatches command
- Interaction dispatch → Help command: dispatches command
- Interaction dispatch → Ping command: dispatches command
- Command loading → Discord API: fills command map (evidence: `other/load_commands.js`)
- Command registration → Discord API: registers commands (evidence: `other/deploy-commands.js`)
- Discord user → Best price: requests price (evidence: `commands/db/bp.js`)
- Best price → Listing queries: queries lowest price (evidence: `commands/db/bp.js`)
- Add listing → Listing queries: adds listing (evidence: `commands/db/adddata.js`)
- Delete listing → Listing queries: deletes listing (evidence: `commands/db/deldata.js`)
- Create item → Listing queries: creates table (evidence: `commands/db/newitem.js`)
- Drop item → Listing queries: drops table (evidence: `commands/db/delitem.js`)
- Item catalog → Listing queries: reads item catalog (evidence: `commands/db/itemlist.js`)
- Listing list → Listing queries: reads listings (evidence: `commands/db/list.js`)
- Listing queries → PostgreSQL: queries and mutates (evidence: `db.js`)
- Listing queries → Embed builders: formats results (evidence: `db.js`)
- Help command → Embed builders: builds help embed (evidence: `commands/general/help.js`)
- Discord user → Help command: requests help (evidence: `commands/general/help.js`)
- Bot startup → Test message: handles messages (evidence: `index.js`)
- Test message → Listing queries: queries best price (evidence: `index.js`)
- Health client → Health response: requests status (evidence: `index.js`)
