How frappe/webshop works
Project Type and Purpose
• Type: Frappe Webshop is a full-stack, open-source eCommerce application built on the Frappe framework (Python back end + Jinja/JavaScript front end).
• Purpose: To enable small and medium businesses to spin up customizable online stores; integrates with ERPNext for inventory, billing, and order management.
File Structure
• Top-level:
– .github, CI/CD pipelines
– pyproject.toml, packaging and dependencies
– webshop/: main Python package
• webshop/hooks.py: Frappe hooks into events
• webshop/patches/: data-migration and patch scripts applied at install/upgrade
• webshop/setup/: installer entry point
• webshop/public/: static assets (JS, SCSS, images) served to clients
• webshop/templates/: Jinja templates for website pages, includes, and generators
• webshop/webshop/: core Python modules
– api.py: REST or RPC endpoints
– crud_events/: doctype event handlers (e.g., revalidate cart when price_list changes)
– doctype/: DocType definitions (schemas, JS clients, Python controllers, tests)
– product_data_engine/: search & filtering logic
– shopping_cart/, variant_selector/: business logic modules
– utils/, redisearch_utils.py: helpers and cache/search integrations
– web_template/: configurable website components (hero slider, product cards)
• webshop/www/: “website application” pages (each folder is a URL route).
README
• Confirms full-stack eCommerce app on Frappe
• Key technologies: Python, JavaScript, SCSS, Redis, MariaDB (via Frappe)
• Integrates with ERPNext and external payment gateways (Stripe, PayPal)
• Deployment via Bench (Docker or VMs), uses Redis for caching & job queuing.
Main Components & Their Interactions
a. Client Layer
– Web Browser / Mobile Browser
– Static Assets: HTML (from Jinja templates), JS modules (webshop/public/js/...), SCSS bundles
– Pages: webshop/www/<route>, dynamic JS behavior (cart, wishlist, search)
b. Application Layer (Frappe Server)
– HTTP Server (Nginx → Gunicorn / bench served)
– Frappe Framework
• Hooks & Patches: hooks.py and patches/ on install/upgrade
• DocTypes: data models and form controllers
• CRUD Event Handlers: business rules triggered on document changes
• API Endpoints (api.py) for AJAX/REST calls
• Product Engine & Cart Logic: search, filtering, cart operations
– Bench Workers & Scheduler (background jobs, patch runner)
c. Data Layer
– MariaDB (primary DocType storage)
– Redis (cache, full-text search via redisearch_utils, job queue)
d. External Integrations
– ERPNext (via Frappe’s internal RPC)
– Payment Gateways (Stripe, PayPal)
– Optional Email/SMS providers for order notifications
Architectural Patterns & Design Principles
• MVC-style:
– Model = DocTypes
– View = Jinja templates + website pages + front-end JS
– Controller = server-side Python in pages, api.py, and event handlers
• Modular & Pluggable: Patches, Hooks, and Web Templates allow customization without core changes
• Separation of Concerns:
– Static asset pipeline in public/
– Template generators in templates/generators/
– Pure business logic in webshop/webshop/…
Essential Elements
– Clear, self-explanatory labels on each component
– Annotations for critical customizations (Hooks, Patches)
– Versioning/deployment context (e.g., Bench → Docker containers)