How sapphirefountains/crm_enhancements works
1. Overall shape
- This is a Frappe/ERPNext app that adds CRM-specific enhancements on top of an existing ERPNext installation.
- It is not a standalone service; it plugs into the ERPNext runtime through Frappe’s app, hooks, DocTypes, and client script mechanisms.
2. Main boundary
- The repository splits cleanly into:
- Python backend code for server-side logic and integrations
- Browser-side JavaScript for CRM UI behavior
- Frappe metadata/configuration for registration, hooks, and custom DocTypes
3. Server-side application package
- The core Python app lives under crm_enhancements/crm_enhancements/.
- api.py is the likely entry point for whitelisted Frappe API methods exposed to the client side or other Frappe components.
- drive_utils.py isolates Google Drive-related logic, keeping external integration concerns separate from UI and DocType code.
4. Google Drive integration
- The app clearly includes an external-service boundary to Google Drive.
- That integration is probably used to create, locate, or manage project folders from CRM data.
- drive_utils.py is the central abstraction for Drive operations, while the settings DocType supplies the configurable credentials/paths/behavior.
5. Custom settings DocType
- doctype/project_folder_google_drive_settings/ contains a custom DocType named Project Folder Google Drive Settings.
- This is the app’s main persisted configuration surface for the Drive integration.
- The JSON file defines the DocType schema; the Python file likely contains validation or helper behavior.
6. CRM UI customization
- The public/js/opportunity.js and public/js/opportunity_list.js files are client-side extensions for the Opportunity form and list view.
- These scripts likely add buttons, actions, field behavior, or automation triggers tied to the app’s CRM workflow.
- This is the main front-end boundary: browser actions call back into Frappe/Python through the API layer.
7. Frappe hooks and app registration
- hooks.py is the wiring layer that connects the app to ERPNext/Frappe.
- This is where assets, doc events, overrides, or scheduled actions would be registered so the custom logic runs inside the ERPNext lifecycle.
- modules.txt and __init__.py files support Frappe’s module discovery.
8. Migration/versioning support
- patches.txt indicates the app has database or schema migrations that Frappe can apply during upgrades.
- This suggests the app evolves its DocTypes/configuration over time rather than being static.
9. Templates/pages
- The templates/pages/ structure exists, but there are no concrete page files shown.
- Architecturally, this is an extension point for server-rendered Frappe pages, though it does not appear to be the primary delivery mechanism here.
10. Tooling and delivery
- The repo is built for Frappe bench deployment and uses pre-commit with ruff, eslint, prettier, and pyupgrade.
- That implies a mixed Python/JavaScript codebase with code quality enforced across backend and frontend layers.
11. Likely data flow
- A user interacts with the Opportunity UI in ERPNext.
- Client-side scripts invoke server methods in api.py.
- Server logic consults the Google Drive settings DocType, then uses drive_utils.py to perform Drive operations.
- Results flow back to the UI, and any configuration/state is stored in Frappe’s database as DocType records.
12. Diagram takeaway
- The architecture is best drawn as an ERPNext/Frappe extension app with three key subsystems:
- CRM UI customizations for Opportunity
- Backend API and helper utilities
- Google Drive configuration/integration via a custom settings DocType
Main entry points: hooks.py hooks.py · api.py API · drive_utils.py Drive utils · project_folder_google_drive_settings.json Settings schema
Components 15
Backend
Server-side Frappe app code and integrations.
- API · Server endpoints exposed to client scripts and other Frappe components.
crm_enhancements/crm_enhancements/api.py - Drive utils · Encapsulates Google Drive operations and integration logic.
crm_enhancements/crm_enhancements/drive_utils.py
Frontend
Browser-side CRM behavior for Opportunity views.
- Opportunity UI · Client-side customization for the Opportunity form.
crm_enhancements/public/js/opportunity.js - Opportunity list · Client-side customization for the Opportunity list view.
crm_enhancements/public/js/opportunity_list.js
Frappe wiring
App registration, hooks, and module discovery.
- hooks.py · Registers the app with Frappe/ERPNext and wires assets or lifecycle events.
crm_enhancements/hooks.py - modules.txt · Frappe module discovery metadata.
crm_enhancements/modules.txt - patches.txt · Upgrade patches for schema or data changes.
crm_enhancements/patches.txt - Pages · Server-rendered page template extension point.
crm_enhancements/templates/pages - Package init · Top-level app package marker.
crm_enhancements/__init__.py - App init · Main app package marker for the Frappe app.
crm_enhancements/crm_enhancements/__init__.py - Config init · Configuration package marker.
crm_enhancements/config/__init__.py - Templates init · Templates package marker.
crm_enhancements/templates/__init__.py - Pages init · Pages package marker.
crm_enhancements/templates/pages/__init__.py
Config & metadata
Persisted DocType schema and migration support.
- Settings logic · Python behavior for the Project Folder Google Drive Settings DocType.
crm_enhancements/crm_enhancements/doctype/project_folder_google_drive_settings/project_folder_google_drive_settings.py - Settings schema · Frappe JSON metadata defining the custom settings DocType.
crm_enhancements/crm_enhancements/doctype/project_folder_google_drive_settings/project_folder_google_drive_settings.json
Connections 18
- hooks.py → API: exposes · Hooks register server-side methods or app behavior.
- hooks.py → Opportunity UI: loads · Hooks can include browser assets for the Opportunity form.
- hooks.py → Opportunity list: loads · Hooks can include browser assets for the Opportunity list view.
- hooks.py → Settings schema: registers · Hooks connect custom DocTypes to the Frappe app.
- API → Drive utils: uses · API methods delegate Google Drive operations to the integration layer.
- API → Settings logic: reads · API methods can consult settings behavior and validation.
- Drive utils → Settings schema: configured by · Drive operations depend on persisted settings stored in the DocType.
- Settings logic → Settings schema: implements · Python file provides logic for the settings DocType schema.
- Opportunity UI → API: calls · Form actions trigger server-side API methods.
- Opportunity list → API: calls · List actions trigger server-side API methods.
- Opportunity UI → Drive utils: initiates · User actions may start Drive-related workflows through the backend.
- Opportunity list → Drive utils: initiates · List view actions may start Drive-related workflows through the backend.
- patches.txt → Settings schema: evolves · Patches support changes to the custom settings DocType over time.
- modules.txt → App init: discovers · Module metadata helps Frappe locate the app package.
- Package init → App init: contains · Top-level package contains the main app package.
- Pages → Pages init: contains · Template directory contains page package markers.
- Templates init → Pages init: contains · Template package contains the pages subpackage.
- Config init → hooks.py: supports · Config package supports app wiring and runtime configuration.