A modular Flask framework for building scalable web applications
Project description
Bivouac Framework
A modular Flask framework for building scalable web applications with built-in authentication, permissions, and multi-tenant support.
Features
- Modular Architecture: Dynamic module loading and management
- Authentication System: Flask-User based authentication with session management
- Role-Based Access Control: Comprehensive permission system with caching
- Multi-Tenant Support: Organization-based data isolation
- CLI Tools: Command-line interface for application management
- Extensible: Easy to extend with custom modules and functionality
Quick Start
Installation
pip install bivouac-framework
Basic Usage
from bivouac_framework import create_app
from bivouac_framework.core.config import Config
# Create configuration
config = Config()
config.SECRET_KEY = 'your-secret-key'
config.SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db'
# Create application
app = create_app(config)
if __name__ == '__main__':
app.run(debug=True)
CLI Commands
# Create a new application
bivouac create-app myapp
# List available modules
bivouac list-modules
# Check version
bivouac --version
Core Components
Module System
The framework provides a dynamic module loading system:
from bivouac_framework.core.module_registry import ModuleRegistry
from bivouac_framework.core.module_base import ModuleBase
class MyModule(ModuleBase):
name = "My Module"
version = "1.0.0"
def initialize(self):
# Module initialization code
pass
def cleanup(self):
# Module cleanup code
pass
# Register module
ModuleRegistry.register_module(MyModule())
Authentication
Built-in authentication with Flask-User:
from bivouac_framework.auth.auth_service import AuthService
# Check if user is authenticated
if AuthService.is_authenticated():
user = AuthService.get_current_user()
print(f"Welcome, {user.username}!")
Permissions
Role-based access control system:
from bivouac_framework.permissions.permission_service import PermissionService
# Create permission
PermissionService.create_permission('user.edit', 'Edit users', 'user')
# Check permission
if PermissionService.has_permission('user.edit'):
# User can edit
pass
Organizations
Multi-tenant organization support:
from bivouac_framework.organizations.organization_service import OrganizationService
# Get user's organization
org = OrganizationService.get_user_organization(user_id)
# Create organization
new_org = OrganizationService.create_organization('My Company')
Module Development
Creating a Module
- Structure your module:
my_module/
├── __init__.py
├── routes.py
├── models.py
├── services/
├── templates/
└── static/
- Define your module class:
# my_module/__init__.py
from bivouac_framework.core.module_base import ModuleBase
from flask import Blueprint
class MyModule(ModuleBase):
name = "My Module"
version = "1.0.0"
def __init__(self):
self.blueprint = Blueprint('my_module', __name__)
self.register_routes()
def register_routes(self):
from . import routes
# Register routes here
- Register your module:
from bivouac_framework.core.module_registry import ModuleRegistry
from my_module import MyModule
ModuleRegistry.register_module(MyModule())
Module Lifecycle
Modules follow a specific lifecycle:
- Registration: Module is registered with the system
- Initialization:
initialize()method is called - Activation: Module becomes active and available
- Runtime: Module is used during application execution
- Cleanup:
cleanup()method is called on shutdown
Configuration
The framework uses a configuration system that supports multiple environments:
from bivouac_framework.core.config import Config
class DevelopmentConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///dev.db'
class ProductionConfig(Config):
DEBUG = False
SQLALCHEMY_DATABASE_URI = 'postgresql://user:pass@localhost/prod'
API Reference
Core Classes
ModuleRegistry: Manages module registration and lifecycleModuleBase: Base class for all modulesConfig: Configuration managementAuthService: Authentication and user managementPermissionService: Permission and role managementOrganizationService: Multi-tenant organization management
CLI Commands
bivouac create-app <name>: Create a new applicationbivouac list-modules: List available modulesbivouac --version: Show version information
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support and questions:
- Create an issue on GitHub
- Check the documentation
- Join our community discussions
Changelog
See CHANGELOG.md for a list of changes and version history.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bivouac_framework-0.1.0a0.tar.gz.
File metadata
- Download URL: bivouac_framework-0.1.0a0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16ca6f696de52738cb37317716a6b806b03145d5b816b20aa1659d48b31c8814
|
|
| MD5 |
1efe772d9e206a26730eba57bd62fe32
|
|
| BLAKE2b-256 |
5d0d3136de1874d80c53ce908093777c08b9cc47cd024b8e7466a8769a679f94
|
File details
Details for the file bivouac_framework-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: bivouac_framework-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
102a8f43eb8b6fdf6bd706da14f92d569d0280e321f7718072f379d99a1e0e09
|
|
| MD5 |
84cd9274d33bee852fc0af5412422c37
|
|
| BLAKE2b-256 |
47fd770ecb6c4109ee07598e773738897f9c5506583477154709b5ae6f681de5
|