This repository has been archived on 2026-02-24 . You can view files and clone it. You cannot open issues or pull requests or push a commit.
6aa2919f3435c8fc6dbe02605b118e84a1e18204
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 37s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cart App
Shopping cart, checkout, and order management service for the Rose Ash cooperative.
Architecture
One of four Quart microservices sharing a single PostgreSQL database:
| App | Port | Domain |
|---|---|---|
| blog (coop) | 8000 | Auth, blog, admin, menus, snippets |
| market | 8001 | Product browsing, Suma scraping |
| cart | 8002 | Shopping cart, checkout, orders |
| events | 8003 | Calendars, bookings, tickets |
Structure
app.py # Application factory (create_base_app + blueprints)
path_setup.py # Adds project root + app dir to sys.path
config/app-config.yaml # App URLs, SumUp config
models/ # Cart-domain models
order.py # Order, OrderItem
page_config.py # PageConfig (per-page SumUp credentials)
bp/
cart/ # Cart blueprint
global_routes.py # Add to cart, checkout, webhooks, return page
page_routes.py # Page-scoped cart and checkout
overview_routes.py # Cart overview / summary page
api.py # Internal API (/internal/cart/summary)
services/ # Business logic
checkout.py # Order creation, SumUp integration
check_sumup_status.py # Payment status polling
calendar_cart.py # Calendar entry cart queries
page_cart.py # Page-scoped cart queries
get_cart.py # Cart item queries
identity.py # Cart identity (user_id / session_id)
total.py # Price calculations
clear_cart_for_order.py # Soft-delete cart after checkout
order/ # Single order detail view
orders/ # Order listing view
templates/ # Jinja2 templates
entrypoint.sh # Docker entrypoint
Dockerfile
shared/ # Submodule → git.rose-ash.com/coop/shared.git
glue/ # Submodule → git.rose-ash.com/coop/glue.git
Cross-App Integration
- Internal API:
GET /internal/cart/summaryreturns cart count + total for the current session/user. Called by blog and market context processors. - Calendar entries: Checkout marks CalendarEntries (events domain) as "ordered" via
glue/services/order_lifecycle.py— not by direct model write. - Payment confirmation: When SumUp payment confirms, entries are marked "provisional" via the same glue service.
- Domain events: Emits
order.createdandorder.paidevents for observability. - Login adoption: Anonymous cart/entries are adopted when
user.logged_inevent fires (handled byglue/handlers/login_handlers.py).
Checkout Flow
1. User clicks "Checkout"
2. create_order_from_cart() creates Order + OrderItems
3. glue: claim_entries_for_order() marks CalendarEntries as "ordered"
4. emit: order.created event
5. SumUp hosted checkout created, user redirected
6. SumUp webhook / return page triggers check_sumup_status()
7. If PAID: glue: confirm_entries_for_order(), emit: order.paid
Running
export DATABASE_URL_ASYNC=postgresql+asyncpg://user:pass@localhost/coop
export REDIS_URL=redis://localhost:6379/0
export SECRET_KEY=your-secret-key
hypercorn app:app --reload --bind 0.0.0.0:8002
Docker
docker build -t cart .
docker run -p 8002:8000 --env-file .env cart
Description
Languages
Python
60%
HTML
38.2%
Dockerfile
0.9%
Shell
0.9%