How zumitoteam/zumito-framework works
Main Components
• Framework Core: At the heart is the main entry point (ZumitoFramework.ts) that initializes the bot, sets up Discord.js integrations, and wires all the services.
• Definitions & Contracts: The “src/definitions” folder contains type definitions (commands, errors, events, settings, APIs, parameters, decorators) that form the system’s contract layer. This forms the backbone for enforcing structure in the framework.
• Services: In “src/services” you find the essential modules (e.g., CommandParser, EmojiFallback, InteractionIdGenerator) and service managers (CommandManager, EventManager, ModuleManager, StatusManager, TranslationManager). These services encapsulate domain-specific logic and operations.
• Core Modules: Under “src/modules” the “core” folder – especially “baseModule” – provides a template for building modular components of your bot. It handles Discord events (like InteractionCreate, MessageCreate) and related models (e.g., Guild).
• Discord Integration: The “src/discord” directory indicates dedicated code handling Discord-specific initializations and event listeners, ensuring the bot can interact properly with Discord’s ecosystem.
• Utilities: The “src/services/utilities” folder holds helper classes (like DatabaseConfigLoader, GuildDataGetter, InviteUrlGenerator, etc.) that provide ancillary functionality to support the main services and modules.
• External Dependencies: Notice the integration and reliance on libraries like Discord.js and Express, as noted in the README. These are crucial for communication with the Discord API and (potentially) for providing a web dashboard later on.
Relationships and Interactions
• The Framework Core (ZumitoFramework.ts) acts as the orchestrator. It initializes the services, registers modules, and starts both the Discord and HTTP (Express) integrations.
• The Services layer (managers and handlers) interacts with the Core to process incoming commands and events. Each manager (for commands, events, modules, etc.) handles a specific part of the bot’s logic and uses definitions as contracts.
• The Definitions layer informs every part of the system (services, modules, and decorators like Injectable) ensuring type safety and consistency.
• The Discord integration code communicates with Discord's API through Discord.js, feeding events into pre-defined handlers.
• Utility components supply the underlying support for tasks like generating invite URLs, merging configuration objects, or formatting texts.
Architectural Patterns and Design Principles
• Modular Architecture: The separation between “core modules”, “services”, and “definitions” encourages reusability and ease of integration.
• Dependency Injection: With decorators (such as in “src/definitions/decorators/Injectable.decorator.ts”), the design promotes loose coupling and testability.
• DRY Principle: The framework abstracts common bot functionalities (command and event handling, status management) to remove repetition across bots built on it.
• Layered Design: Having a distinct “definitions” layer separate from logic (services, modules) makes the framework more maintainable and scalable.