Skip to main content

Opinionated framework for async web services

Project description

Pepelats

Small Opinionated framework for async web services in Python — compose on a fluent builder with DI, configuration, observability, and lifecycle built in.

Python Version Status License


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:

  1. appsettings.toml or appsettings.json (required)
  2. appsettings.{Environment}.* when present
  3. .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 (LoggingConfiglogging, MessageBusConfigmessage_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:

Optional:

  • FastAPI — API layer (pepelats[fastapi])

License

Apache-2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pepelats-0.1.0a3.tar.gz (504.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pepelats-0.1.0a3-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

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

Hashes for pepelats-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 93eac1803ee915e2339b9ffddf8d86816407d988467ad42776b2b92a8076e655
MD5 1ceb1cf11abb16b9e45a438db1adeb21
BLAKE2b-256 9d61ac84662fa35f8550c0f68926062a49688dcfb34fc91396c109cb44b1f7b9

See more details on using hashes here.

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

Hashes for pepelats-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 140284b885c5efcfaa2932953883b024d72f9bb9d549b2a06ede3a0e19630262
MD5 9b35fcfe9d62ded96c664fbdb3cc9bea
BLAKE2b-256 91e079492eff8ad3b319c6e6aac19c8a4b994e39fcf9cfe8ce2ffb4fb02badea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page