Decouple all cross-app service calls to HTTP endpoints

Replace every direct cross-app services.* call with HTTP-based
communication: call_action() for writes, fetch_data() for reads.
Each app now registers only its own domain service.

Infrastructure:
- shared/infrastructure/actions.py — POST client for /internal/actions/
- shared/infrastructure/data_client.py — GET client for /internal/data/
- shared/contracts/dtos.py — dto_to_dict/dto_from_dict serialization

Action endpoints (writes):
- events: 8 handlers (ticket adjust, claim/confirm, toggle, adopt)
- market: 2 handlers (create/soft-delete marketplace)
- cart: 1 handler (adopt cart for user)

Data endpoints (reads):
- blog: 4 (post-by-slug/id, posts-by-ids, search-posts)
- events: 10 (pending entries/tickets, entries/tickets for page/order,
  entry-ids, associated-entries, calendars, visible-entries-for-period)
- market: 1 (marketplaces-for-container)
- cart: 1 (cart-summary)

Service registration cleanup:
- blog→blog+federation, events→calendar+federation,
  market→market+federation, cart→cart only,
  federation→federation only, account→nothing
- Stubs reduced to minimal StubFederationService

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-25 03:01:38 +00:00
parent 5dafbdbda9
commit 3b707ec8a0
55 changed files with 1210 additions and 581 deletions

View File

@@ -16,6 +16,8 @@ from bp import (
register_cart_global,
register_orders,
register_fragments,
register_actions,
register_data,
)
from bp.cart.services import (
get_cart,
@@ -135,6 +137,8 @@ def create_app() -> "Quart":
app.jinja_env.globals["cart_delete_url"] = lambda product_id: f"/delete/{product_id}/"
app.register_blueprint(register_fragments())
app.register_blueprint(register_actions())
app.register_blueprint(register_data())
# --- Page slug hydration (follows events/market app pattern) ---
@@ -152,10 +156,15 @@ def create_app() -> "Quart":
@app.before_request
async def hydrate_page():
from shared.infrastructure.data_client import fetch_data
from shared.contracts.dtos import PostDTO, dto_from_dict
slug = getattr(g, "page_slug", None)
if not slug:
return
post = await services.blog.get_post_by_slug(g.s, slug)
raw = await fetch_data("blog", "post-by-slug", params={"slug": slug})
if not raw:
abort(404)
post = dto_from_dict(PostDTO, raw)
if not post or not post.is_page:
abort(404)
g.page_post = post