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.
giles 44f475857b
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 42s
Fix AttributeError on g.cart in product cart route
g.cart was never populated in the market app — the cart loader
before_request hook was only registered in the cart microservice.
Replace the dead filter-building code with an actual query that
loads cart items inline, scoped to the current user/session.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 10:11:49 +00:00

Market App

Product browsing and marketplace service for the Rose Ash cooperative. Displays products scraped from Suma Wholesale.

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, feature flags
models/                 # Market-domain models
  market.py             #   Product, Category, CartItem
  market_place.py       #   MarketPlace (page-scoped marketplace)
bp/                     # Blueprints
  market/               #   Market root, navigation, category listing
  browse/               #   Product browsing with filters and infinite scroll
  product/              #   Product detail pages
  cart/                 #   Page-scoped cart views
  api/                  #   Product sync API (used by scraper)
scrape/                 # Suma Wholesale scraper
  get_auth.py           #   Authentication
  listings.py           #   Product listing pages
  nav.py                #   Category navigation
  product/              #   Individual product scraping
  build_snapshot/       #   Build product snapshots
  persist_snapshot/     #   Save snapshots to DB
  persist_api/          #   Save via API
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

Dependencies

Cross-app model imports:

  • blog.models.ghost_content.Postapp.py hydrates page data for marketplace views

Glue services:

  • glue.services.navigation.get_navigation_tree — context processor builds site nav

Internal APIs:

  • Calls GET /internal/cart/summary — context processor for cart widget

Scraping

# Full scrape (Suma Wholesale catalogue)
bash scrape.sh

# Test scraping (limited)
bash scrape-test.sh

Running

export DATABASE_URL_ASYNC=postgresql+asyncpg://user:pass@localhost/coop
export REDIS_URL=redis://localhost:6379/0
export SECRET_KEY=your-secret-key
export SUMA_USER=your-suma-username
export SUMA_PASSWORD=your-suma-password

hypercorn app:app --reload --bind 0.0.0.0:8001

Docker

docker build -t market .
docker run -p 8001:8000 --env-file .env market
Description
No description provided
Readme 555 KiB
Languages
Python 73.2%
HTML 26%
Shell 0.5%
Dockerfile 0.3%