···11-# Voidy Architecture Overview
22-The Voidy architecture is a complete re-imagination of my previous bot's command and event organization architecture.
33-44-Instead of relying on loose commands and events in respective top-level directories, the new approach groups all sorts of handlers into a single "module".
55-66-And to allow even better handling of data, modules are managed by an even higher entity, "registries".
77-88-Registries have a standalone database, used to store data of included modules.
99-1010-A more detailed explainer of each system can be found in the related markdown files.
-14
docs/architecture/module-level.md
···11-# Module level architectural overview
22-Modules are groups of commands, events and more.
33-They export those, and provide a combined title, description and the discord name of the user who created them, using the author field.
44-55-## Modules
66-Each module *can* contain a set of commands, events or subscribers.
77-88-Subsribers are similar to events, but are related to the internal Lifecycle management of the bot, not Discord.
99-1010-These are the properties a module is required to provide:
1111-- name (a small and concise name for the module, e.g. "statistics")
1212-- description (a small text, which describes the use-cases of the module)
1313-- author (discord username of the module's author)
1414-- exports (an array of ModuleExportItem's, each containing a `source` and uninstantiated `loader` property)
-24
docs/architecture/registry-level.md
···11-# Registry level architectural overview
22-The Registry level of our architecture mainly focuses on Registries, exported Module data structure, Lifecycle events, and first database interactions, to track Registry/Module states.
33-44-## Registries
55-All Registries will follow a common Registry structure.
66-77-The following properties are required:
88-- store (Where the raw structure of imported Modules is stored)
99-1010-The following methods are required:
1111-- collect (uses the ModuleLoader to collect the raw JSON output of all registry modules) [registry::preCollect, registry::postCollect]
1212-- prepare (uses various loaders to prepare Module contents, based on the Module's exports property, which exports an array of ModuleExportItem's.) [registry::prePrepare, registry::postPrepare]
1313-- activate (activates the registry and all contained features) [registry::preActivate, registry::postActivate]
1414-- unload (deactivates all modules stored in the registry and the registry itself) [registry::preUnload, registry::postUnload]
1515-1616-1717-### ModuleExportItem
1818-Each Module provides a public `exports` property, which is an array of ModuleExportItem's, each ModuleFetchItem provides a `source` and a `loader` property.
1919-2020-The `source` property is a simple path, pointing to a directory or file.
2121-The `loader` property takes an uninitialized loader class, which is then instantiated by the Registry, while loading the Module.
2222-2323-2424-@Todo: document registry error-notify feature, which uses a Module's author field, to notify the user of an error, directly within Discord.
-39
docs/architecture/top-level.md
···11-# Top level architectural overview
22-Anything happening before, or required by, our registries, is considered top-level architecture.
33-44-This includes utilities such as the command and event handlers, which are consumed by lower levels of the system.
55-66-We'll go through each of the top-level components below.
77-88-## Loaders
99-Loaders are static classes, which provide utility methods for recursive loading of data from a data source, usually a directory.
1010-1111-The constructor of a loader always takes one parameter, a string/path pointer to the desired data-source.
1212-1313-Each loader additionally implements an asynchronous `collect` method for initial data collection.
1414-1515-Additionally, each loader implements their own asynchronous `validate` method, which is invoked within `collect`, to validate the contents of a file, before adding it to the Loader store.
1616-1717-Finally, loaders provide various means of exporting data in supported formats, through methods like `getJSON`, `getCSV` and more...
1818-1919-### Event loader
2020-The event loader walks a directory and stores data from any file exporting an object that follows the Event type structure.
2121-2222-### Command loader
2323-The command loader walks a directory and stores data from any file exporting an object that follows the Command type structure.
2424-2525-## Handlers
2626-Handlers are static classes, which are invoked, usually on discord events or interactions.
2727-2828-Each handler has an `invoke` method, which is the one I mentioned calling above.
2929-3030-The handler then queries the core registry and all other registries afterward, to find a fitting execution target.
3131-3232-It's important to note that only repositories marked as active are taken into account.
3333-3434-@Todo: document Handler lifecycle events
3535-3636-## Lifecycle manager
3737-The Lifecycle manager is a simple event manager with a fancy name, it stores subscribers of events in a map, with the event name as the key.
3838-3939-Additionally, it implements two very simple methods, notify - which fires lifecycle events, and subscribe - which subscribes a callback function to an event.