Flaxon Spring-Boot
Spring Boot-style patterns for Flaxon — Dependency Injection, AOP, REST Controllers, and more.
Table of Contents
What is this?
Flaxon Spring-Boot brings the battle-tested patterns of Spring Boot to Python. It provides:
- 🔄 Dependency Injection —
@Autowired,@Component,@Service,@Repository - 🎯 AOP (Aspect-Oriented) —
@Aspect,@Before,@After,@Around - 🚀 Auto-Configuration — Auto-detect and configure components
- 📝 Application Properties —
application.yml/application.propertiessupport - 🎭 Profiles —
@Profile("dev"),@Profile("prod")environment-specific beans - ⏰ Scheduled Tasks —
@Scheduled(cron="* * * * *") - 💾 Transactional —
@Transactionalfor database operations - 🌐 REST Controllers —
@RestController,@GetMapping,@PostMapping - 📊 Spring Data JPA-style — Repository interfaces with auto-CRUD
- 📈 Actuator — Health checks, metrics, info endpoints
- 📡 Event Listeners —
@EventListenerfor application events - ⚙️ Configuration Properties —
@ConfigurationPropertiesfor typed config
Why Spring Boot Patterns in Python?
| Problem | Solution |
|---|---|
| Manual dependency wiring | @Autowired auto-wiring |
| Boilerplate CRUD code | @Repository + auto-CRUD |
| Transaction boilerplate | @Transactional |
| Manual scheduling setup | @Scheduled cron/fixed-delay |
| Cross-cutting concerns scattered | @Aspect AOP |
| Hard-coded configuration | application.yml profiles |
| No built-in health checks | /actuator/health, /actuator/metrics |
Installation
pip install flaxon-spring-boot
With dev dependencies:
pip install flaxon-spring-boot[dev]
Quick Start
1. Load the Plugin
from flaxon import Flaxon
from flaxon_spring_boot import SpringBootPlugin
app = Flaxon("my-app")
# Load Spring Boot plugin
app.plugins.load_plugin(SpringBootPlugin(
profiles=["dev"],
autoconfigure=True,
actuator_enabled=True,
))
2. Create a Service
from flaxon_spring_boot import Service, Autowired, Repository
@Service
class UserService:
@Autowired
def __init__(self, repo: UserRepository):
self.repo = repo
async def get_user(self, id: int):
return await self.repo.find_by_id(id)
@Repository
class UserRepository:
_data = {}
async def find_by_id(self, id: int):
return self._data.get(id)
async def save(self, data: dict):
self._data[data["id"]] = data
return data
3. Create a REST Controller
from flaxon_spring_boot import RestController, GetMapping, PostMapping, RequestBody
@RestController("/api/users")
class UserController:
@Autowired
def __init__(self, service: UserService):
self.service = service
@GetMapping("/{id}")
async def get_user(self, id: int):
return await self.service.get_user(id)
@PostMapping
async def create_user(self, @RequestBody data: dict):
return await self.service.create_user(data)
4. Run the App
flaxon run app:app --reload
Features
Dependency Injection
from flaxon_spring_boot import Component, Autowired, Service
@Component
class DatabaseConfig:
def __init__(self):
self.url = "postgresql://localhost:5432/mydb"
@Service
class UserService:
@Autowired
def __init__(self, config: DatabaseConfig, repo: UserRepository):
self.config = config
self.repo = repo
AOP (Aspect-Oriented Programming)
from flaxon_spring_boot import Aspect, Before, After, Pointcut
@Aspect
class LoggingAspect:
@Pointcut("execution(* UserService.*(..))")
def service_methods(self):
pass
@Before("service_methods")
def log_before(self, join_point):
print(f"Calling: {join_point.method}")
@After("service_methods")
def log_after(self, join_point, result):
print(f"Returned: {result}")
Scheduled Tasks
from flaxon_spring_boot import Scheduled, Component
@Component
class ReportScheduler:
@Scheduled(cron="0 0 * * * *") # Every hour
async def generate_report(self):
await report_service.generate()
@Scheduled(fixed_delay=5000) # Every 5 seconds
async def ping_health(self):
print("Health check")
Transactional
from flaxon_spring_boot import Transactional, Service
@Service
class OrderService:
@Transactional
async def create_order(self, order_data):
# Auto-rollback on exception
order = await order_repo.save(order_data)
await inventory_repo.update(order.items)
return order
Application Properties
# application.yml
spring:
datasource:
url: postgresql://localhost:5432/mydb
username: admin
password: secret
app:
name: My Flaxon App
version: 1.0.0
logging:
level: DEBUG
from flaxon_spring_boot import ConfigurationProperties
@ConfigurationProperties("app")
class AppConfig:
name: str
version: str
Actuator Endpoints
| Endpoint | Purpose |
|---|---|
/actuator/health |
Application health status |
/actuator/info |
Application information |
/actuator/metrics |
Performance metrics |
/actuator/routes |
Registered routes |
/actuator/beans |
Managed beans |
Profiles
from flaxon_spring_boot import Profile, Component
@Component
@Profile("dev")
class DevDatabaseConfig:
url = "postgresql://localhost:5432/dev"
@Component
@Profile("prod")
class ProdDatabaseConfig:
url = "postgresql://production:5432/prod"
File Structure
Spring vs Flaxon Spring-Boot
| Spring (Java) | Flaxon Spring-Boot (Python) |
|---|---|
@Autowired |
@Autowired |
@Service |
@Service |
@Repository |
@Repository |
@RestController |
@RestController |
@GetMapping |
@GetMapping |
@Transactional |
@Transactional |
@Scheduled |
@Scheduled |
@Aspect |
@Aspect |
application.properties |
application.yml |
@Profile |
@Profile |
| Spring Boot Actuator | Flaxon Actuator |
@EventListener |
@EventListener |
@ConfigurationProperties |
@ConfigurationProperties |
Requirements
Python 3.11+
Flaxon 0.1.9+
License
MIT License - See LICENSE file for details.
Support
📚 Documentation
🐛 Issue Tracker
💬 Discussions
Metadata
Release files for flaxon-spring-boot 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flaxon_spring_boot-0.1.1.tar.gz | 33.6 kB | Without provenance | Details for flaxon_spring_boot-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flaxon_spring_boot-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for flaxon_spring_boot-0.1.1-py3-none-any.whl |
Total release size: 67.1 kB
Release files / flaxon_spring_boot-0.1.1.tar.gz
| Download URL | flaxon_spring_boot-0.1.1.tar.gz |
|---|---|
| Size | 33.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd58c6622cf93e1448a2cbdfd54d77b8880743daf6d807e7ffd0df98b05f9cdf
|
|
BLAKE2b-256 checksum How to use checksums |
df4bdff6c60be233efd30304fca05927a5da5fa9ba1fb45fdd25ef19a8cc2a65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / flaxon_spring_boot-0.1.1-py3-none-any.whl
| Download URL | flaxon_spring_boot-0.1.1-py3-none-any.whl |
|---|---|
| Size | 33.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a508abd9c49727db5e0bcdf2dd2b85d574a7a2bc39b703e9ab97f2d675fdaa39
|
|
BLAKE2b-256 checksum How to use checksums |
c8fce6762ac032f34a97e4fd22698174a1cc9a66de6d6164bc83313a79574b60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for flaxon-spring-boot 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.