PhilippTheServer

python

Python services, tooling and the packaging around them.

  1. Tracking Meals and Automating Shopping With an MCP Server

    An MCP server for meal tracking and grocery shopping automation: planned meals minus live stock, and why the v2 rebuild derives stock from an event journal.

  2. Automating Web Shop Order Processing Before the Catalogue

    Web shop order processing automated first: Stripe webhook payment confirmation, stock reservations, outbox-driven DHL labels, two manual steps.

  3. A Daily Digest of What Actually Got Merged, Built from MQTT and a Local LLM

    paho-mqtt subscriber to SQLite plus a local LLM: a daily digest that summarises merged pull requests per repository from diff stats, no cloud API.

  4. The NTP Clock Jump That Made the Scheduler Skip a Week of Measurements

    time.time() vs time.monotonic() in a Python scheduler: a backwards NTP step delayed runs by nine days. Monotonic durations and a jump-injecting test.

  5. One Local Endpoint for Every Agent Session

    OPENAI_BASE_URL=http://localhost:8080/v1 for every AI tool: one local FastAPI proxy that logs each request and refuses internal-only projects.

  6. Testing an Agent Harness Without Ever Calling the Model

    Unit testing a coding agent's tool-call permission layer with pytest and recorded fixtures: allow, deny or ask decisions with no model or API key.

  7. A Deterministic Daemon That Turns a Labelled Issue Into a Pull Request

    git apply --check before git commit: an issue-to-PR daemon where the model only returns a patch and plain Python commits, pushes and opens the PR.

  8. The Transactional Outbox: Never Losing a Job You Already Committed

    Transactional outbox in Postgres: commit-then-enqueue loses jobs on a crash. A SKIP LOCKED relay to Redis Streams and an idempotent consumer.

  9. Building the Dry-Run Path First, and Testing That It Sends Nothing

    if dry_run: return guards drift as side effects are added. Split the tool into a pure plan() and apply(), and test that dry run never calls the client.

  10. Idempotent Payment Webhooks with a Deduplication Table

    Payment webhook processed twice on retry: dedupe on the provider event ID with a primary key, committed in the same transaction as the side effect.

  11. Modelling an Order Lifecycle as an Explicit State Machine

    Python order status as a state machine: a transition table and one transition_to method that raises InvalidTransition on moves like shipping a cancelled order.

  12. Migrating Redis Consumers from Python to C++ on Constrained Hardware

    redis-plus-plus xreadgroup times out before its block timeout: set socket_timeout to 0. Replacing idle Python Redis stream consumers with C++.

  13. UUID Case Normalization as a Recurring Cross-Service Bug

    Uppercase vs lowercase UUID keys cause silent cache and database lookup misses between services. Normalise once at the boundary with str(uuid.UUID(value)).

  14. Chaining Single-Purpose Redis Consumers into a Processing Pipeline

    XREADGROUP, XACK and XAUTOCLAIM: splitting one Python consumer into single-purpose Redis Streams stages with at-least-once delivery and crash recovery.

  15. A Python CLI That Scaffolds a Project Structure You Actually Want

    Python scaffolding CLI with only argparse and string.Template: generates src layout, pyproject.toml, Dockerfile and .gitignore, tested with tomllib.

  16. Replacing pip, venv, flake8, black and isort with uv and Ruff

    uv sync --locked and ruff check replacing pip install -r requirements.txt, venv, flake8, black and isort: uv.lock plus one pyproject.toml config.

  17. Configuration Precedence: Docker Secrets, Kubernetes Secrets, Environment, .env, Default

    Docker secrets in /run/secrets, Kubernetes secret mounts, env vars and .env: a Python resolver with fixed precedence that reports which source won.

  18. An Exception Hierarchy and One Handler for FastAPI Error Responses

    FastAPI add_exception_handler on a base AppError instead of raising HTTPException in services: one status-code mapping and a consistent error body.

  19. Designing a Consistent FastAPI Response Envelope

    FastAPI response envelope with Pydantic Generic[T] and a custom APIRoute get_route_handler that wraps every response in success, data and error.

  20. A Feature-Module Layout for a FastAPI Application That Keeps Growing

    FastAPI APIRouter per feature directory with its own router.py, schemas.py and service.py, replacing a shared routers.py, schemas.py and crud.py.

All topics · All writing