Skip to content

A truly modular, fast, and friendly MVC framework for Python that supports multiple services running in parallel. The architecture is designed to be service-agnostic, allowing you to easily add, remove, or configure services without tight coupling.

License

Notifications You must be signed in to change notification settings

zaber-dev/Zeython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Zeython β€” Flask MVC Structure with Modular Service Architecture

License: GPL v3 Python

Welcome to Zeython, a truly modular, fast, and friendly MVC framework for Python that supports multiple services running in parallel. The architecture is designed to be service-agnostic, allowing you to easily add, remove, or configure services without tight coupling.

Zeython is created by Md Mahedi Zaman Zaber and is the improved and advanced version of the earlier project: https://github.com/zaber-dev/MVC-Python

Repository: https://github.com/zaber-dev/Zeython

Documentation

Key Features

πŸ—οΈ Truly Modular Architecture

  • Service-oriented design: Each service (web, Discord, etc.) is completely independent
  • Plugin system: Services can be enabled/disabled through configuration
  • No tight coupling: Core framework doesn't depend on specific services
  • Easy extensibility: Add new services without modifying core code

⚑ Fast and Efficient

  • Lazy loading: Services are only loaded when enabled
  • Threaded execution: Services run in parallel without blocking each other
  • Optimized startup: Only configured services are initialized
  • Resource management: Proper service lifecycle management

πŸ‘₯ Developer Friendly

  • Clean separation: MVC pattern with clear service boundaries
  • Configuration-driven: Enable/disable features through environment variables
  • Backward compatible: Existing Discord-specific code continues to work
  • Well documented: Clear interfaces and comprehensive examples

Project Structure

.
β”œβ”€β”€ app
β”‚   β”œβ”€β”€ Actions             # Utility functions (pagination, embeds, webhook handling, etc.)
β”‚   β”œβ”€β”€ Commands            # Discord command handling (optional service)
β”‚   β”‚   β”œβ”€β”€ Context         # Traditional Discord commands
β”‚   β”‚   └── Slash           # Slash commands for Discord
β”‚   β”œβ”€β”€ Controllers         # Controller logic for web and services
β”‚   β”‚   β”œβ”€β”€ Flask           # Controllers specific to Flask web app
β”‚   β”‚   └── Discord         # Controllers for Discord bot (optional)
β”‚   β”œβ”€β”€ Core                # Core framework components
β”‚   β”‚   β”œβ”€β”€ service.py      # Service interface and base classes
β”‚   β”‚   β”œβ”€β”€ service_manager.py  # Service lifecycle management
β”‚   β”‚   └── config.py       # Configuration management
β”‚   β”œβ”€β”€ Models              # Data models for the application
β”‚   β”œβ”€β”€ Services            # Service implementations
β”‚   β”‚   β”œβ”€β”€ web_service.py  # Flask web service
β”‚   β”‚   └── discord_service.py  # Discord bot service (optional)
β”‚   └── Views               # Dynamic Flask views/templates structures
β”œβ”€β”€ config
β”‚   β”œβ”€β”€ boot.py             # Legacy entry point (deprecated)
β”‚   └── application.py      # New modular application bootstrap
β”œβ”€β”€ 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
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ Dockerfile               # Docker containerization file
└── .env                     # Environment configuration variables

Features Implemented

🌐 Enhanced Web Service

  • MVC Structure: Clean separation of concerns with Models, Views, and Controllers
  • Flask Integration: Modern Flask web application with blueprint support
  • Enhanced Models: Validation, caching, audit trails, and soft deletes
  • Service Layer: Repository pattern and business logic separation
  • Database Abstraction: Flexible database layer with SQLAlchemy and advanced ORM features
  • Template System: Jinja2 templates with organized static files
  • API Support: RESTful APIs with comprehensive error handling

πŸ” Authentication & Security

  • User Management: Enhanced user model with password hashing and account security
  • Session Management: Comprehensive session tracking with device information
  • JWT Tokens: Access token creation, validation, and revocation
  • OAuth Integration: Framework for external OAuth providers (Google, GitHub, Discord)
  • Security Audit: Database-backed security event logging with risk assessment
  • Password Reset: Secure token-based password reset functionality

πŸ“ File Management System

  • File Upload: Advanced file handling with category-based organization
  • Storage Management: Secure file storage with metadata tracking
  • Permissions: Granular file access control with user and public permissions
  • File Versioning: Track file changes and maintain version history
  • Security: Extension validation, size limits, and virus scanning integration

πŸ”Œ Vendor Integration Framework

  • Plugin Architecture: Extensible framework for third-party service integrations
  • API Management: Rate limiting, request tracking, and error handling
  • Webhook Support: Comprehensive webhook handling with logging and retry logic
  • Vendor Models: Configuration and state management for external services

πŸ“Š Error Handling & Monitoring

  • Custom Exceptions: Specific exception classes with detailed context
  • Error Logging: Database-backed error tracking with occurrence counting
  • Activity Logging: Comprehensive user and system activity tracking
  • Performance Metrics: Response time tracking and resource usage monitoring
  • Context Managers: Automatic error handling and performance monitoring utilities

πŸ€– Optional Discord Integration

  • Plugin Architecture: Discord service loads only when configured
  • Command System: Support for both traditional and slash commands
  • Event Handling: Comprehensive Discord event management
  • Modular Cogs: Organized command structure
  • No Dependencies: Core system works without Discord libraries

πŸ—οΈ Service Architecture

  • Service Manager: Centralized service lifecycle management
  • Configuration System: Environment-based configuration with fallbacks
  • Thread Management: Safe parallel execution of services
  • Status Monitoring: Real-time service status and health checks
  • Hot Swappable: Add/remove services without system restart

πŸ”§ Developer Experience

  • Type Hints: Full type annotation support throughout the codebase
  • Comprehensive Testing: Unit tests for all enhanced features
  • Documentation: Well-documented APIs with usage examples
  • Validation Framework: Field-level validation with custom validators
  • Caching System: Model-level caching for improved performance
  • JSON Serialization: Full serialization/deserialization support

🐳 Docker Support

  • Containerization: Complete Docker setup for easy deployment
  • Multi-service: Single container can run multiple services
  • Environment Configuration: Easy configuration through environment variables

Getting Started

Quick Start

  1. Clone the Repository:

    git clone https://github.com/zaber-dev/Zeython.git
    cd Zeython
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Configure Services: Copy .env_example to .env and configure your services:

    cp .env_example .env

    For Web Service Only:

    FLASK_HOST=127.0.0.1
    FLASK_PORT=5000
    DATABASE_URL=sqlite:///database.db

    For Web + Discord Services:

    FLASK_HOST=127.0.0.1
    FLASK_PORT=5000
    DISCORD_TOKEN=your_discord_token_here
    DISCORD_PREFIX=!
    DATABASE_URL=sqlite:///database.db
  4. Run the Application:

    # New modular system (recommended)
    python config/application.py
    
    # Legacy system (deprecated)
    python config/boot.py

Service Configuration

Web Service

  • Enable: Set FLASK_HOST environment variable
  • Port: Set FLASK_PORT (default: 5000)
  • Debug: Set FLASK_DEBUG=true for development

Discord Service (Optional)

  • Enable: Set DISCORD_TOKEN environment variable
  • Prefix: Set DISCORD_PREFIX (default: !)
  • Commands: Add commands in app/Commands/ directories

Adding New Services

  1. Create Service Class:

    from app.Core.service import ThreadedService
    
    class MyService(ThreadedService):
        def is_enabled(self) -> bool:
            return self.config.get('enabled', False)
        
        def _run(self):
            # Your service logic here
            pass
  2. Register Service:

    from app.Core.service_manager import service_manager
    service_manager.register_service_class(MyService, "my_service")
  3. Configure Service:

    MY_SERVICE_ENABLED=true
    MY_SERVICE_OPTION=value

Docker Deployment

# Build the container
docker build -t zeython .

# Run with web service only
docker run -e FLASK_HOST=0.0.0.0 -e FLASK_PORT=5000 -p 5000:5000 zeython

# Run with multiple services
docker run -e FLASK_HOST=0.0.0.0 -e DISCORD_TOKEN=your_token -p 5000:5000 zeython

What's Next?

βœ… Completed Features

All major TODO items have been implemented! The framework now includes:

  • βœ… Vendor Integrations: Complete framework for third-party integrations with rate limiting, webhooks, and plugin architecture
  • βœ… Authentication: Comprehensive authentication system with JWT tokens, OAuth integration, and session management
  • βœ… File Management: Advanced file handling with categories, permissions, versioning, and storage management
  • βœ… Error Handling & Logging: Enhanced error tracking, activity logging, and performance monitoring

Enhanced MVC Architecture

The framework now provides enterprise-level features including:

  • Enhanced Base Model: Validation, caching, audit trails, soft deletes, and JSON serialization
  • Service Layer: Repository pattern and business logic separation with transaction management
  • Security Features: Password hashing, account locking, security audit logging, and risk assessment
  • Performance Monitoring: Response time tracking, slow endpoint detection, and resource usage metrics
  • Multi-Currency Support: Currency-specific balance management with transaction controls

πŸ“– See MVC_ENHANCEMENTS.md for comprehensive documentation and usage examples.

Future Enhancements

Potential areas for further development:

  • GraphQL API integration
  • Real-time notifications with WebSockets
  • Advanced search capabilities with Elasticsearch
  • Machine learning model integration
  • Microservices architecture support

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:

  • Implementing additional Flask features.
  • Expanding Discord bot functionalities (commands, event listeners, etc.).
  • Integrating new third-party APIs or services.
  • Improving the MVC structures

Check out the issues section for current needs, or suggest your own enhancements!

Getting Started

  1. Clone the Repository:

    git clone https://github.com/zaber-dev/Zeython.git
    cd Zeython
  2. Install Dependencies:

    pip install -r requirements.txt
  3. 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).

  4. Run the Application:

    python config/boot.py
  5. Run in Docker:

    docker build -t zeython .
    docker run -d -p 5000:5000 zeython

License

This project is licensed under the GNU General Public License v3.0.

About

A truly modular, fast, and friendly MVC framework for Python that supports multiple services running in parallel. The architecture is designed to be service-agnostic, allowing you to easily add, remove, or configure services without tight coupling.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages