# commonly-ts/trivious architecture

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

## Overview

Trivious is a Discord.js bot framework: a bot starts the TriviousClient, which discovers and registers its configured handlers, optionally deploys application commands, binds events and modules, and logs in. Registered slash, context-menu, and message commands are distinct runtime stages; components and encoded interaction IDs support interactive routing, while permissions provide access checks. The sampled client, command registry, event registry, and deployer establish the main orchestration links. Other feature paths are present in the tree and README, but their internal call wiring was not sampled.

Main entry points: [`src/features/client/trivious.client.ts`](https://github.com/commonly-ts/trivious/blob/main/src/features/client/trivious.client.ts) (TriviousClient), [`src/features/commands/registry.commands.ts`](https://github.com/commonly-ts/trivious/blob/main/src/features/commands/registry.commands.ts) (Command registry), [`src/features/events/registry.events.ts`](https://github.com/commonly-ts/trivious/blob/main/src/features/events/registry.events.ts) (Event registry), [`src/features/client/deploy.client.ts`](https://github.com/commonly-ts/trivious/blob/main/src/features/client/deploy.client.ts) (Command deployer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Client lifecycle"]
  node_client["TriviousClient<br/>[trivious.client.ts]"]
end

subgraph group_commands["Commands and deployment"]
  node_commandreg["Command registry"]
  node_commandhandlers["Command handlers"]
  node_commandbuilders["Command builders"]
  node_deploy["Command deployer<br/>[deploy.client.ts]"]
end

subgraph group_interactions["Interactive features"]
  node_components["Component registry"]
  node_componentbuilders["Component builders"]
  node_customid["Interaction IDs"]
  node_permissions["Permission checks"]
end

subgraph group_runtime["Events and modules"]
  node_events["Event registry<br/>[registry.events.ts]"]
  node_presets["Default events"]
  node_modules["Module registry"]
end

subgraph group_shared["Shared infrastructure"]
  node_structure["Path resolution<br/>[index.structure.ts]"]
  node_registries["Registry facade<br/>[registries.ts]"]
  node_types["Feature types<br/>[typings.ts]"]
  node_errors["Framework errors<br/>[errors.ts]"]
end

node_bot(("Bot application"))
node_discordapi["Discord API"]
node_discorduser(("Discord user"))

node_bot -->|"starts"| node_client
node_client -->|"resolves paths"| node_structure
node_client -->|"registers features"| node_registries
node_registries -->|"registers commands"| node_commandreg
node_client -->|"deploys commands"| node_deploy
node_deploy -->|"sends commands"| node_discordapi
node_commandreg -->|"uses message parser"| node_commandhandlers
node_commandreg -->|"stores commands"| node_client
node_client -->|"registers and binds"| node_events
node_events -->|"loads presets"| node_presets
node_events -->|"attaches listeners"| node_client
node_client -->|"registers and binds"| node_modules
node_discorduser -->|"interacts"| node_client
node_client -->|"logs in"| node_discordapi

click node_client "https://github.com/commonly-ts/trivious/blob/main/src/features/client/trivious.client.ts"
click node_structure "https://github.com/commonly-ts/trivious/blob/main/src/features/structure/index.structure.ts"
click node_registries "https://github.com/commonly-ts/trivious/blob/main/src/shared/registries.ts"
click node_commandreg "https://github.com/commonly-ts/trivious/blob/main/src/features/commands/registry.commands.ts"
click node_commandhandlers "https://github.com/commonly-ts/trivious/tree/main/src/features/commands/handlers"
click node_commandbuilders "https://github.com/commonly-ts/trivious/blob/main/src/features/commands/builders.commands.ts"
click node_deploy "https://github.com/commonly-ts/trivious/blob/main/src/features/client/deploy.client.ts"
click node_components "https://github.com/commonly-ts/trivious/blob/main/src/features/components/registry.components.ts"
click node_componentbuilders "https://github.com/commonly-ts/trivious/blob/main/src/features/components/builders.components.ts"
click node_customid "https://github.com/commonly-ts/trivious/blob/main/src/features/customId/methods.customid.ts"
click node_permissions "https://github.com/commonly-ts/trivious/blob/main/src/features/permissions/methods.permissions.ts"
click node_events "https://github.com/commonly-ts/trivious/blob/main/src/features/events/registry.events.ts"
click node_presets "https://github.com/commonly-ts/trivious/tree/main/src/features/events/presets"
click node_modules "https://github.com/commonly-ts/trivious/blob/main/src/features/modules/registry.modules.ts"
click node_types "https://github.com/commonly-ts/trivious/blob/main/src/shared/typings.ts"
click node_errors "https://github.com/commonly-ts/trivious/blob/main/src/utility/errors.ts"

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_client,node_discorduser toneBlue
class node_commandreg,node_commandhandlers,node_commandbuilders,node_deploy toneAmber
class node_components,node_componentbuilders,node_customid,node_permissions,node_discordapi toneMint
class node_events,node_presets,node_modules toneRose
class node_structure,node_registries,node_types,node_errors,node_bot toneIndigo
```

## Components

### Client lifecycle

- [TriviousClient](https://github.com/commonly-ts/trivious/blob/main/src/features/client/trivious.client.ts): `src/features/client/trivious.client.ts`

### Commands and deployment

- [Command registry](https://github.com/commonly-ts/trivious/blob/main/src/features/commands/registry.commands.ts): `src/features/commands/registry.commands.ts`
- [Command handlers](https://github.com/commonly-ts/trivious/tree/main/src/features/commands/handlers): `src/features/commands/handlers`
- [Command builders](https://github.com/commonly-ts/trivious/blob/main/src/features/commands/builders.commands.ts): `src/features/commands/builders.commands.ts`
- [Command deployer](https://github.com/commonly-ts/trivious/blob/main/src/features/client/deploy.client.ts): `src/features/client/deploy.client.ts`

### Interactive features

- [Component registry](https://github.com/commonly-ts/trivious/blob/main/src/features/components/registry.components.ts): `src/features/components/registry.components.ts`
- [Component builders](https://github.com/commonly-ts/trivious/blob/main/src/features/components/builders.components.ts): `src/features/components/builders.components.ts`
- [Interaction IDs](https://github.com/commonly-ts/trivious/blob/main/src/features/customId/methods.customid.ts): `src/features/customId/methods.customid.ts`
- [Permission checks](https://github.com/commonly-ts/trivious/blob/main/src/features/permissions/methods.permissions.ts): `src/features/permissions/methods.permissions.ts`

### Events and modules

- [Event registry](https://github.com/commonly-ts/trivious/blob/main/src/features/events/registry.events.ts): `src/features/events/registry.events.ts`
- [Default events](https://github.com/commonly-ts/trivious/tree/main/src/features/events/presets): `src/features/events/presets`
- [Module registry](https://github.com/commonly-ts/trivious/blob/main/src/features/modules/registry.modules.ts): `src/features/modules/registry.modules.ts`

### Shared infrastructure

- [Path resolution](https://github.com/commonly-ts/trivious/blob/main/src/features/structure/index.structure.ts): `src/features/structure/index.structure.ts`
- [Registry facade](https://github.com/commonly-ts/trivious/blob/main/src/shared/registries.ts): `src/shared/registries.ts`
- [Feature types](https://github.com/commonly-ts/trivious/blob/main/src/shared/typings.ts): `src/shared/typings.ts`
- [Framework errors](https://github.com/commonly-ts/trivious/blob/main/src/utility/errors.ts): `src/utility/errors.ts`

### Other components

- **Bot application**
- **Discord API**
- **Discord user**

## Connections

- Bot application → TriviousClient: starts
- TriviousClient → Path resolution: resolves paths
- TriviousClient → Registry facade: registers features
- Registry facade → Command registry: registers commands
- TriviousClient → Command deployer: deploys commands
- Command deployer → Discord API: sends commands
- Command registry → Command handlers: uses message parser
- Command registry → TriviousClient: stores commands
- TriviousClient → Event registry: registers and binds
- Event registry → Default events: loads presets
- Event registry → TriviousClient: attaches listeners
- TriviousClient → Module registry: registers and binds
- Discord user → TriviousClient: interacts
- TriviousClient → Discord API: logs in
