How frappe/lending works
Project type and purpose
• This is an “app” (plugin) for the Frappe/ERPNext framework. It adds a Loan Management module (“lending”) on top of ERPNext, supplying Doctypes, dashboards, reports, patches and UI assets.
File structure
• Top-level files: configuration (pyproject.toml, setup.py), CI/CD and linting (GitHub workflows, .flake8, commitlint), license.
• “lending/”: the app’s source. Within it:
• config, hooks.py, install.py → Frappe hook definitions, app setup and configuration.
• loan_management/doctype → JSON, Python and JS definitions for each Doctype (model), server‐side business logic, client scripts and tests.
• loan_management/dashboard_chart and number_card → metadata for Kanban/KPI widgets.
• report → server and client code for custom reports.
• overrides/ and patches/ → extensions and migration scripts that manipulate ERPNext core behavior and schema.
• public/js, templates/pages → front-end assets (bundled JS, HTML templates).
• translations/ → CSV files for i18n.
README for additional insights
• Describes the app as “Open Source Lending software” to install into a Frappe Bench. No standalone web server or mobile component—this integrates into the ERPNext web UI.
Main components and their interactions
a. Client browser (UI layer)
• Fetches HTML, JS and CSS from Frappe’s HTTP server (bench → Nginx/Gunicorn).
• Executes JS hooks (defined in Doctype .js files) for client-side validation and UI interactions.
b. Frappe Application Server
• Core framework + ERPNext + Lending app.
• Uses hooks.py to register event handlers, overrides, scheduler tasks, API endpoints.
• Doctype definitions (.json) register models in MariaDB; Python controllers enforce business rules.
c. Database (MariaDB)
• Persists all Doctype records, system settings, patches.
d. Cache/Broker (Redis)
• Session management, Redis Queue for background jobs (e.g., interest accrual).
e. Bench process manager
• Supervises worker processes, scheduler, web server, background jobs.
f. External dependencies
• ERPNext core (other modules), Frappe Bench CLI, third-party services only if configured (e.g., email SMTP).
Architectural patterns and design principles
• MVC pattern via Frappe Doctypes (Model = .json schemas, View = Jinja templates + JS, Controller = Python).
• Plugin/Extension pattern: “lending” registers hooks and overrides rather than patching core code.
• Data migrations applied incrementally via “patches” folder.
• i18n support via CSV translations.
• Modular dashboards and reports allow drop-in integration.