How aquitcd/live-noti-fire works
Project Type and Purpose
• This is a single-service backend application built on Deno.
• It serves as a bot that registers slash commands on Discord, links Twitch accounts to Discord servers, and sends notifications when a Twitch stream starts or ends.
• The purpose is clearly detailed in the README: to auto-register bot commands and to handle stream events through defined API endpoints.
Analyzing the File Structure
• Top-level files such as .env.example, deno.jsonc, and deno.lock indicate environment configuration and dependency management.
• The “src” directory contains further subdirectories – “controllers”, “repositories”, “services”, “types”, and “utils” – showcasing a layered architecture:
• Controllers: Handle HTTP endpoint requests (for Discord interactions, Twitch webhooks, and debug endpoints).
• Services: Encapsulate business logic specific to Discord functionalities (e.g., sending notifications) and Twitch operations (e.g., subscribing to webhook events).
• Repositories: Likely act as interfaces for data persistence (for storing registration or notification-related data, such as mapping users and stream statuses).
• Types and Utils: Provide type definitions and helper functions such as environment variable management.
• The “scripts” directory (with register-commands.ts) is used for manually registering Discord commands if needed.
Components and Their Interactions
a. External Systems:
• Discord API: Handles slash command registration, user interactions, and sending notifications.
• Twitch API: Provides streamer information and sends webhook events (stream online/offline).
b. Application Layers:
• HTTP Controllers:
• Discord Controller: Receives interactions like the /add-streamer and /notify-settings commands, as well as command registration requests.
• Twitch Controller: Handles incoming webhook events (stream start and end) from Twitch.
• Debug Controller: Offers endpoints for examining and managing the KV-store (debug endpoints).
• Service Layer:
• Discord Service: Encapsulates the logic for sending messages and reactions, as well as interfacing with Discord for validations.
• Twitch Service: Handles interactions with Twitch to fetch broadcaster IDs and subscribe to or validate webhook events.
• Repository Layer:
• Guild, User, and Notification Repositories: Manage persistence for storing registrations, messages, and settings tied to Discord guilds and users.
• Utility & Configuration Layers:
• Environment and Type utilities: Load and manage environment variables and ensure type safety.
c. Data Stores / KV Store:
• A KV-store used to persist certain state information (e.g., user registration information, message IDs for notifications).
Final Checklist
• Every component is clearly labeled and easily identifiable.