How fvckgrimm/discord-fansly-notify works
Main Components
• Bot Executable & Entry Point – Represented by the file in cmd/fansly-notify/main.go, this is where the application starts.
• API Layer – The “api” directory contains Go files (get_account_info.go, get_post_media.go, etc.) that interact with Fansly. This component holds responsibilities for contacting external Fansly services and retrieving the needed data.
• Business Logic/Discord Bot Module – The “internal/bot” directory (with bot.go, commands.go, and handlers.go) encapsulates the core functionality of the Discord bot. It manages events, commands, and processing of notifications.
• Configuration Module – Under “internal/config/config.go” the project handles configuration settings, including loading environment variables (from the .env file).
• Database Layer – Inside “internal/database/databse.go”, this component (even if basic) is responsible for persistence, such as storing subscription state or other runtime data.
• Embed Factory – The “internal/embed/embed.go” builds the rich embed messages dispatched to Discord.
• CI/CD and Deployment – The .github/workflows and related config files (like .goreleaser.yml) handle automated building and releasing of the bot. Though peripheral to runtime architecture, they are key aspects of the project’s overall lifecycle.
External Services and Data Sources
• Discord API – Where the bot connects to send messages (embed notifications) and potentially receive commands.
• Fansly API – External service from which the bot fetches live/update information about posts and streaming status.
• (Optional) Hosting Environment – If self-hosted, consider representing the deployment environment that runs the binary.
Relationships and Data Flow
• The entry point (fansly-notify executable) initializes the application by loading configuration (from internal/config) which uses the .env file.
• Once running, the bot (internal/bot) uses its command handlers to either poll or subscribe to changes. When an event occurs (a new Fansly post or live notification), the corresponding method in the API layer is called.
• Data retrieved by the API layer (from Fansly) is then processed; any associated media or details are formatted using the embed module.
• If needed, the processed data may be stored or referenced via the database layer.
• Finally, the processed notification is dispatched to Discord through the Discord API.
Architectural Patterns and Principles
• Separation of Concerns: Distinct layers for configuration, business logic (bot/handlers), API interactions, data persistence, and message formatting.
• Modularity: Components mostly reside in different directories (api, internal/bot, internal/config) to enforce a clean layered approach.
Detailed Elements
• .env file as the external configuration input feeding into the Configuration module.
• A separate note for automated workflows indicating that after code pushes, the CI/CD pipeline builds and releases the binary.
• If desired, represent the “migrate.py” script near the database layer as part of the migration/setup process.