How dalgot4d/frappe_tap works
Project Type and Purpose
• Tap Lms is a Frappe/ERPNext‐style Python app (plugin) that implements a Learning Management System.
• It defines a set of domain objects (Doctypes) – Course, Student, Teacher, Enrollment, Performance, etc. – with client scripts (JS), metadata (JSON), and server logic (Python).
• It plugs into the Frappe web framework, exposing UI pages, REST endpoints, database models, and report generators.
File Structure Analysis
• Top-Level: setup.py, requirements.txt, MANIFEST.in – a standard Python package.
• tap_lms/config & fixtures – module registration, initial data (client scripts).
• hooks.py – Frappe hook points (event handlers, scheduled jobs, asset inclusion).
• tap_lms/public – static assets (JS/CSS) served to the browser.
• tap_lms/tap_lms/doctype – each subfolder is a Doctype containing:
– .json (schema/metadata)
– .py (server-side business logic)
– .js (client-side form scripts)
– test_*.py (unit tests)
• tap_lms/tap_lms/report – custom report definitions (JSON) and tests.
• tap_lms/templates/pages – Jinja HTML pages for custom UI routes.
a. Main Components
– Browser Client: loads Frappe UI, executes client scripts, invokes REST/WS calls.
– Frappe Web Server: core framework handling routing, authentication, MVC orchestration.
– tap_lms App Module: a plugin on the Frappe server, containing Doctype definitions, hooks, fixtures, templates, and reports.
– Database: MariaDB/MySQL (or PostgreSQL) storing Doctype tables and system data.
– Optional Scheduler/Worker: background job runner for hooks or scheduled tasks.
– Test Runner: pytest/unittest environment exercising Python and Doctype tests.
b. Relationships and Data Flows
– Browser → HTTP/WS → Frappe Server → Python Controllers (tap_lms doctypes) → Database CRUD.
– Frappe Server → JS & CSS assets (from tap_lms/public).
– Scheduler → invokes hook methods (hooks.py) → Doctype logic → Database.
– Test Runner → imports Doctype modules → executes unit tests (test_*.py) in isolation.
c. Architectural Patterns and Principles
– Modular plugin architecture (tap_lms installs into Frappe via hooks).
– MVC pattern: JSON schema defines the model, Python controllers implement the business logic, JS client scripts handle the “view/controller” interactions.
– Convention-over-configuration: file-based Doctype discovery.
– Separation of concerns: client assets vs. server logic vs. database schema.
d. Key Technologies and Frameworks
– Python 3, Frappe Framework (web server, ORM, hooks).
– MariaDB/MySQL (primary datastore).
– JavaScript (client form scripting).
– Jinja2 templates for custom pages.
– pytest/unittest for tests.
Capturing Essential Architectural Elements
• Every Doctype group (Course, Student, etc.) is represented as part of the tap_lms module layer.
• Hooks.py as the integration point with Frappe’s event system.
• Client scripts served from tap_lms/public and the JSON metadata feeding the Frappe model generator.
• Templates/pages folder to indicate server-rendered custom UI routes.
• Don’t overlook the report definitions and test suites – they validate business logic and deliver reports.