Lifecycle-first backend framework for Flask and gevent.
Project description
SPECTER
Service Primitives for Event Control, Teardown, and Execution Runtime
A lifecycle-first backend framework for Python applications built on Flask and gevent. SPECTER is designed around three ideas: explicit ownership of background work, deterministic teardown, and clear service boundaries.
Requirements
- Python 3.9+
- Flask
- gevent
- Flask-SocketIO
Install
Install from a checkout:
pip install .
For active development:
pip install -e .
Once published to PyPI:
pip install specter-runtime
The package installs its runtime dependencies automatically. Then import from it:
from specter import Service, Controller, Schema, Field, boot, registry, bus
Publish
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*
Primitives
| Channel | Role |
|---|---|
Service |
Lifecycle owner for background work (timers, greenlets, bus subscriptions) |
QueueService |
Queue-backed worker pool with managed startup/shutdown |
Controller |
Feature composition root — binds routes, socket events, and state under one lifecycle |
Handler |
Class-based Socket.IO event lifecycle |
SocketIngress |
Shared socket fanout dispatcher (multiple listeners per event with priority) |
Watcher |
Polling or stream-following observation loop with retry/backoff |
Schema / Field |
Declarative payload validation and coercion |
create_store |
Shared mutable flat state (gevent-safe) |
create_model |
Nested runtime state graph with path selectors |
create_cache |
Shared state with TTL expiry and bus-driven invalidation cascades |
Outcome |
Structured success/failure result |
Operation |
Reusable validate + perform action |
ManagedProcess |
Subprocess lifecycle with owned stream readers |
Router + route |
Class-based Flask Blueprint composition |
registry |
Composition-root service locator with late binding |
bus |
Internal synchronous pub/sub |
json_endpoint |
Flask route decorator for consistent JSON error envelopes |
Quick Examples
Service
from specter import Service
class PollingService(Service):
def __init__(self):
super().__init__('polling', {'tick_count': 0})
def on_start(self):
self.interval(self._tick, 10.0)
def _tick(self):
self.set_state({'tick_count': self.state.get('tick_count', 0) + 1})
service = PollingService().start()
# later
service.stop()
Controller
from flask import request
from specter import Controller, Field, Schema
class ItemController(Controller):
name = 'items'
schemas = {
'create': Schema('create', {
'name': Field(str, required=True),
'active': Field(bool, default=True),
})
}
def on_start(self):
self.state = self.create_model('items.state', {'items': []})
def build_routes(self, router):
@router.route('/api/items', methods=['POST'])
def create():
clean = self.schema('create').require(request.get_json(silent=True) or {})
return {'ok': True, 'name': clean['name']}
def build_events(self, handler):
handler.on('item_created', self._on_item_created)
def _on_item_created(self, data=None):
return {'ok': True}
Boot
from specter import boot
manager = boot(
app,
socketio,
services=[ThumbnailService(), IndexService()],
controllers=[ItemController()],
)
Documentation
See specter.md for the full guide and API reference.
License
Apache 2.0 — Copyright 2026 BleedingXiko
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 specter_runtime-0.1.1.tar.gz.
File metadata
- Download URL: specter_runtime-0.1.1.tar.gz
- Upload date:
- Size: 43.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deaf3ec89b63619654c28485845407c402771a16fca82d7d29cb4a708c0b2bfd
|
|
| MD5 |
5bb9a1cc2da9fc10b7d55b699944581a
|
|
| BLAKE2b-256 |
9743f3577536b509b65b2dd79cc4d6ac9ccbeb8513f9164dba734c5e188da1c5
|
File details
Details for the file specter_runtime-0.1.1-py3-none-any.whl.
File metadata
- Download URL: specter_runtime-0.1.1-py3-none-any.whl
- Upload date:
- Size: 59.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17255d4a13a32b5da3560401ed80928b6f3dd669fb090a51a32497ff4e552b6a
|
|
| MD5 |
efb8f0cc75c4da2e598e611f99c1e652
|
|
| BLAKE2b-256 |
1c9c1d8f5821a4b9c2821b46d1bc4d113a9d61f50611e4b00be0bfa00712573b
|