How q10developer/sbcrm works
Purpose and Runtime
SB CRM is a small Frappe/ERPNext-style application installed into a Bench site with bench install-app sbcrm. Its implemented domain surface is an “SB Opportunity” DocType. Python runs server-side in the Frappe runtime; JavaScript runs in the Frappe Desk form client.
Key app registration files: sbcrm/hooks.py, sbcrm/modules.txt, sbcrm/__init__.py.
Application Registration and Lifecycle
Frappe discovers the app package and its module definitions through sbcrm/__init__.py and sbcrm/modules.txt. Framework lifecycle hooks, integration points, and app metadata would be declared in sbcrm/hooks.py; this is the primary boundary between the custom app and the host Frappe site.
sbcrm/patches.txt provides the framework-recognized migration/patch registration boundary for versioned database changes.
Opportunity Domain Model
The core business entity is the SB Opportunity DocType. Its schema, permissions, field definitions, and Desk metadata are defined in sbcrm/sb_crm/doctype/sb_opportunity/sb_opportunity.json.
Server-side document behavior belongs in sbcrm/sb_crm/doctype/sb_opportunity/sb_opportunity.py, under the Frappe document lifecycle. The enclosing domain module is sbcrm/sb_crm/doctype/__init__.py.
Desk Client Behavior
Opportunity form interactions and browser-side Desk customization are implemented in sbcrm/sb_crm/doctype/sb_opportunity/sb_opportunity.js. This code operates against Frappe’s client APIs and the DocType schema, rather than being an independent web frontend.
Primary flow: a Desk user opens or edits an SB Opportunity; Frappe loads the JSON DocType metadata and document data; the JS form script handles client interactions; save/submit actions invoke Frappe’s server-side document processing.
Persistence and Customization Delivery
Frappe persists DocType records and metadata in its site database; this repository supplies declarative changes rather than a standalone database layer. Exported customization fixtures are delivered via sbcrm/fixtures/custom_field.json and sbcrm/fixtures/property_setter.json, allowing installation or migration to apply field and property changes to the host site.
Web and Template Boundary
The app reserves Frappe public and page-template extension points in sbcrm/public/.gitkeep and sbcrm/templates/pages/__init__.py. No separate HTTP service, SPA, or external-service integration is represented in the repository tree; web delivery remains mediated by Frappe.
Infrastructure Dependencies
The material infrastructure dependency is a Frappe Bench deployment and its configured site/database. Installation is performed through Bench, while Frappe supplies routing, authentication, Desk UI, ORM/document persistence, migrations, and client/server RPC. No external APIs, queues, or cloud services are indicated.
Main entry points: sb_opportunity.json SB Opportunity schema · doctype/__init__.py DocType module · sb_opportunity.py Opportunity document logic · sbcrm/__init__.py App package
Components 15
SB CRM App
- App package
sbcrm/__init__.py - Module definitions
sbcrm/modules.txt - App hooks · Lifecycle and integration boundary with Frappe.
sbcrm/hooks.py - Patch registry · Registers versioned database changes.
sbcrm/patches.txt - DocType module
sbcrm/sb_crm/doctype/__init__.py - SB Opportunity schema · Defines fields, permissions, and Desk metadata.
sbcrm/sb_crm/doctype/sb_opportunity/sb_opportunity.json - Opportunity document logic · Server-side behavior under Frappe document processing.
sbcrm/sb_crm/doctype/sb_opportunity/sb_opportunity.py - Opportunity Desk script · Handles form interactions using Frappe client APIs.
sbcrm/sb_crm/doctype/sb_opportunity/sb_opportunity.js - Customization fixtures · Applies exported field and property changes during installation or migration.
sbcrm/fixtures/custom_field.json - Property fixtures
sbcrm/fixtures/property_setter.json - Web extension points · Reserved Frappe public and page-template extension points.
sbcrm/public/.gitkeep - Page template package
sbcrm/templates/pages/__init__.py
Frappe Host Site
- Bench deployment · Installs SB CRM into a configured Frappe site.
- Frappe site runtime · Provides Desk, RPC, document lifecycle, migrations, and ORM.
- Site database · Stores DocType metadata and SB Opportunity records.
Connections 18
- Bench deployment → Frappe site runtime: hosts
- Bench deployment → App package: installs
- App package → Module definitions: discovers
- Frappe site runtime → App hooks: loads
- Frappe site runtime → Patch registry: runs registered patches
- Module definitions → DocType module: exposes
- DocType module → SB Opportunity schema: contains
- DocType module → Opportunity document logic: contains
- Frappe site runtime → SB Opportunity schema: loads metadata
- SB Opportunity schema → Opportunity Desk script: drives form UI
- Opportunity Desk script → Frappe site runtime: saves via RPC
- Frappe site runtime → Opportunity document logic: invokes lifecycle
- Opportunity document logic → Site database: persists documents
- SB Opportunity schema → Site database: stored as metadata
- Frappe site runtime → Customization fixtures: applies on install or migration
- Frappe site runtime → Property fixtures: applies on install or migration
- Frappe site runtime → Web extension points: serves extension point
- Web extension points → Page template package: supports templates