# Cart App Shopping cart, checkout, and order management service for the Rose Ash cooperative marketplace. ## Overview This is the **cart** microservice, split from the Rose Ash monolith. It handles: - **Shopping cart** - Add/remove products, view cart, cart summary API - **Checkout** - SumUp payment integration with hosted checkout - **Orders** - Order listing, detail view, payment status tracking - **Calendar bookings** - Calendar entry cart items and checkout integration ## Architecture - **Framework:** Quart (async Flask) - **Database:** PostgreSQL 16 via SQLAlchemy 2.0 (async) - **Payments:** SumUp Hosted Checkout - **Frontend:** HTMX + Jinja2 templates + Tailwind CSS ## Directory Structure ``` app.py # Quart application factory bp/ cart/ # Cart blueprint (add, view, checkout, webhooks) routes.py api.py # Internal API (server-to-server, CSRF-exempt) login_helper.py # Cart merge on login services/ # Business logic layer order/ # Single order detail blueprint routes.py filters/qs.py # Query string helpers orders/ # Order listing blueprint routes.py filters/qs.py templates/ _types/cart/ # Cart templates _types/order/ # Single order templates _types/orders/ # Order listing templates entrypoint.sh # Docker entrypoint (migrations + server start) Dockerfile # Container build .gitea/workflows/ci.yml # CI/CD pipeline ``` ## Running ```bash # Set environment variables export APP_MODULE=app:app export DATABASE_URL_ASYNC=postgresql+asyncpg://user:pass@localhost/coop export REDIS_URL=redis://localhost:6379/0 export SECRET_KEY=your-secret-key # Run the server hypercorn app:app --reload --bind 0.0.0.0:8002 ``` ## Cross-App Communication The cart app exposes internal API endpoints at `/internal/cart/` for other services: - `GET /internal/cart/summary` - Cart count and total for the current session/user - `POST /internal/cart/adopt` - Adopt anonymous cart items after user login ## Docker ```bash docker build -t cart:latest . docker run -p 8002:8000 --env-file .env cart:latest ```