Opinionated framework for async web services
Project description
Small Opinionated framework for async web services in Python — compose on a fluent builder with DI, configuration, observability, and lifecycle built in.
Apps compose on WebHostBuilder or FastAPIHostBuilder: register services, mount routes or APIs, run background workers. Starlette is the HTTP layer; FastAPI is optional.
Features
- Compose and run an async web service from a single builder
- Inject services and configuration into handlers and constructors
- Load typed settings from TOML or JSON with environment overlays
- Structured logging, tracing, and metrics
- Run background work alongside the HTTP server
- Optional FastAPI for REST APIs and OpenAPI (
pepelats[fastapi])
Installation
uv add pepelats
uv add "pepelats[fastapi]"
Configuration
Pass a config_dir to the builder. Pepelats loads, in order:
appsettings.tomlorappsettings.json(required)appsettings.{Environment}.*when present.env, then process environment variables (highest priority)
The environment name comes from ENVIRONMENT, the environment key in the base file, or defaults to Local. That name selects the overlay file (e.g. appsettings.Staging.toml).
config/appsettings.toml:
environment = "Local"
[service]
service_name = "my-service"
service_version = "1.0.0"
[logging]
log_level = "INFO"
sinks = ["console"]
[logging.console]
json_logs = false
[host]
bind = "127.0.0.1"
port = 8000
[observability]
enabled = false
otlp_endpoint = ""
[greeting]
punctuation = "!"
shout = false
Overlay example (config/appsettings.Staging.toml):
[host]
port = 8080
Environment variables override file values. Nested keys use __:
ENVIRONMENT=Production
HOST__PORT=9001
LOGGING__LOG_LEVEL=DEBUG
Host bootstrap requires [service], [logging], [host], and [observability]. Set observability.enabled = true only with a non-empty otlp_endpoint.
App settings use Pydantic models registered with add_configuration. By default, {Name}Config maps to a [name] section in snake_case (LoggingConfig → logging, MessageBusConfig → message_bus). This works when each word is PascalCase with a single leading capital. Otherwise, pass section= to set the section name yourself.
from pydantic import BaseModel
from pepelats.configuration import Configuration
from pepelats.dependency_injection import ServiceCollection
class GreetingConfig(BaseModel):
punctuation: str
shout: bool
class HealthService:
def __init__(self, config: GreetingConfig) -> None:
self._config = config
def status(self) -> str:
message = "ok"
if self._config.shout:
message = message.upper()
return message + self._config.punctuation
def register(services: ServiceCollection, configuration: Configuration) -> None:
services.add_configuration(GreetingConfig)
services.add_singleton(HealthService)
Examples
Runnable apps live under examples/. Each folder has a short README and a main.py you can run from the repo root:
uv run python examples/starlette-basic/main.py
uv run python examples/fastapi-basic/main.py
uv run python examples/background-worker/main.py
uv run python examples/observability/main.py
| Example | What it shows |
|---|---|
starlette-basic/ |
Generic host, manual DI with request_services |
fastapi-basic/ |
FastAPI host, Inject[T] on routes |
background-worker/ |
BackgroundService with a status route |
observability/ |
Structured logging and spans on a request |
Shared wiring for the greeting examples is in examples/shared/. Smoke tests: tests/example_smoke/.
See examples/README.md for per-example notes.
Dependencies
Pepelats uses:
- Starlette and Uvicorn — ASGI application and server
- Dishka — dependency injection
- Dynaconf and Pydantic — configuration
- structlog — structured logging
- OpenTelemetry — tracing and metrics
Optional:
- FastAPI — API layer (
pepelats[fastapi])
License
Apache-2.0 — see LICENSE.
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 pepelats-0.1.0a3.tar.gz.
File metadata
- Download URL: pepelats-0.1.0a3.tar.gz
- Upload date:
- Size: 504.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93eac1803ee915e2339b9ffddf8d86816407d988467ad42776b2b92a8076e655
|
|
| MD5 |
1ceb1cf11abb16b9e45a438db1adeb21
|
|
| BLAKE2b-256 |
9d61ac84662fa35f8550c0f68926062a49688dcfb34fc91396c109cb44b1f7b9
|
File details
Details for the file pepelats-0.1.0a3-py3-none-any.whl.
File metadata
- Download URL: pepelats-0.1.0a3-py3-none-any.whl
- Upload date:
- Size: 47.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
140284b885c5efcfaa2932953883b024d72f9bb9d549b2a06ede3a0e19630262
|
|
| MD5 |
9b35fcfe9d62ded96c664fbdb3cc9bea
|
|
| BLAKE2b-256 |
91e079492eff8ad3b319c6e6aac19c8a4b994e39fcf9cfe8ce2ffb4fb02badea
|