# davidcanas/assistentecraftsapiens architecture

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

- Interactive diagram: https://gitdiagram.com/davidcanas/assistentecraftsapiens
- Repository: https://github.com/davidcanas/assistentecraftsapiens

## Overview

Assistente Craftsapiens is a Discord assistant for the Craftsapiens community. Its main workflow is Discord messages or interactions entering the bot’s event handlers, being processed through command/context abstractions, and producing replies or music actions. Separate capabilities include community and player information, moderation, utilities, voice-time rankings, and a web dashboard with punishment records and statistics. The excerpts show startup wiring, core abstractions, and some web and music behavior; links for unsampled command dispatch and web route internals are omitted or marked unverified.

Main entry points: [`src/structures/Client.ts`](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Client.ts) (Bot client), [`src/structures/Command.ts`](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Command.ts) (Command framework), [`src/main.ts`](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/main.ts) (Startup), [`src/events/interactionCreate.ts`](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/events/interactionCreate.ts) (Message events)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discord["Discord assistant"]
  node_main["Startup<br/>[main.ts]"]
  node_client["Bot client<br/>[Client.ts]"]
  node_events["Message events"]
  node_context["Command context<br/>[CommandContext.ts]"]
  node_commands["Command framework<br/>[Command.ts]"]
  node_info["Community info"]
  node_moderation["Moderation commands"]
  node_utilities["Utility commands"]
  node_owner["Owner controls"]
end

subgraph group_music["Music playback"]
  node_music_commands["Music commands"]
  node_music_engine["Music engine<br/>[Music.ts]"]
  node_voice_events["Voice events"]
  node_sub_bots["Study music bots<br/>[adaBot.ts]"]
  node_sub_client["Music bot client<br/>[subClient.ts]"]
end

subgraph group_web["Web portal"]
  node_web_app["Web application<br/>[app.ts]"]
  node_web_routes["Web routes<br/>[punicoes.ts]"]
  node_auth["Web authentication<br/>[Strategy.ts]"]
end

subgraph group_data["Data and services"]
  node_user_store[("User records<br/>[userDB.ts]")]
  node_global_store[("Global records<br/>[globalDB.ts]")]
  node_staff_store[("Staff records<br/>[staffDB.ts]")]
end

node_discord_users(("Discord users"))
node_towny_api{{"Towny API"}}
node_discord_service{{"Discord service"}}

node_discord_users -.->|"send interactions"| node_events
node_main -->|"creates and connects"| node_client
node_main -->|"loads"| node_web_app
node_main -->|"loads"| node_sub_bots
node_events -.->|"uses"| node_context
node_events -.->|"uses"| node_client
node_commands -.->|"uses"| node_context
node_info -.->|"uses framework"| node_commands
node_moderation -.->|"uses framework"| node_commands
node_utilities -.->|"uses framework"| node_commands
node_owner -.->|"uses framework"| node_commands
node_music_commands -.->|"uses framework"| node_commands
node_client -->|"creates and initializes"| node_music_engine
node_voice_events -.->|"uses"| node_client
node_sub_bots -->|"instantiates"| node_sub_client
node_sub_client -->|"creates music handler"| node_music_engine
node_web_app -->|"mounts routes"| node_web_routes
node_web_app -.->|"configures strategy"| node_auth
node_web_routes -->|"reads and writes"| node_user_store
node_main -->|"connects and queries"| node_user_store
node_client -.->|"references"| node_global_store
node_client -.->|"references"| node_staff_store
node_info -.->|"queries community data"| node_towny_api
node_client -.->|"connects bot"| node_discord_service

click node_main "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/main.ts"
click node_client "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Client.ts"
click node_events "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/events/interactionCreate.ts"
click node_context "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/CommandContext.ts"
click node_commands "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Command.ts"
click node_info "https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Info"
click node_moderation "https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Mod"
click node_utilities "https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Util"
click node_owner "https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Owner"
click node_music_commands "https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Music"
click node_music_engine "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Music.ts"
click node_voice_events "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/events/voiceChannelJoin.ts"
click node_sub_bots "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/submodules/ada/adaBot.ts"
click node_sub_client "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/sub/subClient.ts"
click node_web_app "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/web/app.ts"
click node_web_routes "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/web/routes/punicoes.ts"
click node_auth "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/web/lib/Strategy.ts"
click node_user_store "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/models/userDB.ts"
click node_global_store "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/models/globalDB.ts"
click node_staff_store "https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/models/staffDB.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_main,node_client,node_events,node_context,node_commands,node_info,node_moderation,node_utilities,node_owner,node_discord_users toneBlue
class node_music_commands,node_music_engine,node_voice_events,node_sub_bots,node_sub_client toneAmber
class node_web_app,node_web_routes,node_auth,node_towny_api toneMint
class node_user_store,node_global_store,node_staff_store toneRose
class node_discord_service toneIndigo
```

## Components

### Discord assistant

- [Startup](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/main.ts): `src/main.ts`
- [Bot client](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Client.ts): `src/structures/Client.ts`
- [Message events](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/events/interactionCreate.ts): `src/events/interactionCreate.ts`
- [Command context](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/CommandContext.ts): `src/structures/CommandContext.ts`
- [Command framework](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Command.ts): `src/structures/Command.ts`
- [Community info](https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Info): `src/commands/Info`
- [Moderation commands](https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Mod): `src/commands/Mod`
- [Utility commands](https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Util): `src/commands/Util`
- [Owner controls](https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Owner): `src/commands/Owner`

### Music playback

- [Music commands](https://github.com/davidcanas/assistentecraftsapiens/tree/master/src/commands/Music): `src/commands/Music`
- [Music engine](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/Music.ts): `src/structures/Music.ts`
- [Voice events](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/events/voiceChannelJoin.ts): `src/events/voiceChannelJoin.ts`
- [Study music bots](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/submodules/ada/adaBot.ts): `src/submodules/ada/adaBot.ts`
- [Music bot client](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/structures/sub/subClient.ts): `src/structures/sub/subClient.ts`

### Web portal

- [Web application](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/web/app.ts): `src/web/app.ts`
- [Web routes](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/web/routes/punicoes.ts): `src/web/routes/punicoes.ts`
- [Web authentication](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/web/lib/Strategy.ts): `src/web/lib/Strategy.ts`

### Data and services

- [User records](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/models/userDB.ts): `src/models/userDB.ts`
- [Global records](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/models/globalDB.ts): `src/models/globalDB.ts`
- [Staff records](https://github.com/davidcanas/assistentecraftsapiens/blob/master/src/models/staffDB.ts): `src/models/staffDB.ts`

### Other components

- **Discord users**
- **Towny API**
- **Discord service**

## Connections

- Discord users → Message events: send interactions
- Startup → Bot client: creates and connects (evidence: `src/main.ts`)
- Startup → Web application: loads (evidence: `src/main.ts`)
- Startup → Study music bots: loads (evidence: `src/main.ts`)
- Message events → Command context: uses (evidence: `src/events/interactionCreate.ts`)
- Message events → Bot client: uses (evidence: `src/events/interactionCreate.ts`)
- Command framework → Command context: uses
- Community info → Command framework: uses framework (evidence: `src/commands/Info/playerinfo.ts`)
- Moderation commands → Command framework: uses framework (evidence: `src/commands/Mod/mute.ts`)
- Utility commands → Command framework: uses framework (evidence: `src/commands/Util/asktowny.ts`)
- Owner controls → Command framework: uses framework (evidence: `src/commands/Owner/blacklistMusic.ts`)
- Music commands → Command framework: uses framework (evidence: `src/commands/Music/effect.ts`)
- Bot client → Music engine: creates and initializes (evidence: `src/structures/Client.ts`)
- Voice events → Bot client: uses (evidence: `src/events/voiceChannelJoin.ts`)
- Study music bots → Music bot client: instantiates (evidence: `src/submodules/ada/adaBot.ts`)
- Music bot client → Music engine: creates music handler (evidence: `src/structures/sub/subClient.ts`)
- Web application → Web routes: mounts routes (evidence: `src/web/app.ts`)
- Web application → Web authentication: configures strategy (evidence: `src/web/app.ts`)
- Web routes → User records: reads and writes (evidence: `src/web/routes/punicoes.ts`)
- Startup → User records: connects and queries (evidence: `src/main.ts`)
- Bot client → Global records: references (evidence: `src/structures/Client.ts`)
- Bot client → Staff records: references (evidence: `src/structures/Client.ts`)
- Community info → Towny API: queries community data
- Bot client → Discord service: connects bot
