You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Flask-based web application following the MVC (Model-View-Controller) structure, with the added feature of integrating a Discord bot. The structure is flexible, allowing you to expand it for more parallel tasks, or easily adjust it to run a single task as needed.
Welcome to theFlask MVC Structure with Discord Integration! This project is primarily aFlask-based web application following the MVC (Model-View-Controller) structure, with the added feature of integrating aDiscord bot usingDisnake. This setup allows you to build a web app while also having a Discord bot running in parallel, enabling additional functionality. The structure is flexible, allowing you to expand it for more parallel tasks, or easily adjust it to run a single task as needed.
Project Structure
.├── app│ ├── Actions# Utility functions (pagination, embeds, webhook handling, etc.)│ ├── Commands# Discord command handling│ │ ├── Context# Traditional Discord commands│ │ └── Slash# Slash commands for Discord│ ├── Controllers# Controller logic for Flask and Discord│ │ ├── Flask# Controllers specific to Flask web app│ │ └── Discord# Controllers for Discord bot│ ├── Models# Data models for the application│ └── Views# Dynamic Flask views/templates structures├── config│ └── boot.py# Main entry point to boot up the program (Flask + Discord)├── database│ └── db.py# Database interactions (abstraction layer)├── resources# Static and template files for Flask│ ├── css# CSS files│ ├── js# JavaScript files│ └── views# HTML templates├── routes│ ├── api.py# Routes for API endpoints│ └── web.py# Routes for web pages├── storage# User file storage (uploads, etc.)├── vendor# Placeholder for third-party integrations (collaborations welcome)├── requirements.txt# Python dependencies├── Dockerfile# Docker containerization file└── .env# Environment configuration variables
Features Implemented
Flask
MVC Structure: Organized codebase that follows the MVC pattern for better separation of concerns:
Models handle data.
Views are rendered by Flask, found inresources/views.
Controllers handle business logic for web and API routes.
Routing:
API routes are defined inroutes/api.py.
Web routes are inroutes/web.py.
Database Abstraction: Easy-to-extend database layer (database/db.py) for managing models.
Templates & Static Files: Resources such as HTML, CSS, and JavaScript are stored inresources/.
Discord Bot (Using Discord.py)
Commands:
Traditional text-based Discord commands inapp/Commands/Context.
Slash commands inapp/Commands/Slash.
Parallel Execution: The Discord bot runs alongside the Flask application for seamless interaction between web and Discord functionalities.
Utility Actions: Functions like pagination, embeds, and webhook handling inapp/Actions.
Docker
Containerization: ProvidedDockerfile allows you to run the entire application in a Docker container, simplifying the setup process.
What's Next?
To-Do
Vendor Integrations: Open for contributions to implement third-party integrations or plugins within thevendor/ directory.
Authentication: Integrate authentication (OAuth or token-based) for the web app and APIs.
File Management: Add advanced handling for user uploads within thestorage/ folder.
Error Handling & Logging: Enhance error handling across both Flask and Discord components, with proper logging.
Collaboration
Contributions are welcome! If you'd like to collaborate, feel free to fork this repository and submit a pull request. Potential areas of contribution include:
Set up Environment Variables:Create a.env file in the root directory with the required environment variables for Flask and Discord (check the.env-example file).
Run the Application:
python config/boot.py
Run in Docker:
docker build -t flask-discord-app.docker run -d -p 5000:5000 flask-discord-app
License
This project is licensed under the GNU General Public License v3.0.
About
Flask-based web application following the MVC (Model-View-Controller) structure, with the added feature of integrating a Discord bot. The structure is flexible, allowing you to expand it for more parallel tasks, or easily adjust it to run a single task as needed.