# dalgot4d/frappe_tap architecture

> Architecture diagram of the GitHub repository dalgot4d/frappe_tap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dalgot4d/frappe_tap
- Repository: https://github.com/dalgot4d/frappe_tap

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    Browser["Browser Client"]:::frontend

    %% Server
    subgraph "Frappe Server" 
        direction TB
        CoreEngine["Core Frappe Engine"]:::server
        AssetManager["Asset Manager\n(serve JS & CSS)"]:::server
        TAPLMSPlugin["tap_lms Plugin"]:::plugin
    end

    %% Plugin internals
    subgraph "tap_lms Plugin" 
        direction TB
        DoctypeLayer["Doctype Layer"]:::plugin
        HooksFixtures["Hooks & Fixtures"]:::plugin
        Registration["Module Reg. & Initial Data"]:::plugin
        StaticAssets["Client Scripts & Styles"]:::plugin
        TemplatesPages["Templates for UI Pages"]:::plugin
        Reports["Custom Reports"]:::plugin
    end

    %% Doctypes
    subgraph "Doctype Layer" 
        direction TB
        Course["Course"]:::plugin
        Student["Student"]:::plugin
        Teacher["Teacher"]:::plugin
        Enrollment["Enrollment"]:::plugin
        Performance["Performance"]:::plugin
        Activities["Activities"]:::plugin
        Batch["Batch"]:::plugin
        School["School"]:::plugin
        Unit["Unit"]:::plugin
    end

    %% Scheduler and Test Runner
    Scheduler["Scheduler / Worker"]:::server
    TestRunner["Test Runner"]:::test

    %% Database
    Database[(Database)]:::database

    %% Relationships
    Browser -->|HTTP/WS calls| CoreEngine
    Browser -->|loads assets| AssetManager
    CoreEngine --> TAPLMSPlugin
    AssetManager --> StaticAssets
    TAPLMSPlugin --> DoctypeLayer
    TAPLMSPlugin --> HooksFixtures
    TAPLMSPlugin --> Registration
    TAPLMSPlugin --> TemplatesPages
    TAPLMSPlugin --> Reports
    DoctypeLayer --> Database
    HooksFixtures --> Database
    CoreEngine --> Database
    Scheduler -->|invoke hooks| HooksFixtures
    TestRunner -->|imports modules| DoctypeLayer
    TestRunner -->|isolated DB| Database

    %% Click Events
    click Course "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/course/course.json"
    click Student "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/student/student.json"
    click Teacher "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/teacher/teacher.json"
    click Enrollment "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/enrollment/enrollment.json"
    click Performance "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/performance/performance.json"
    click Activities "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/activities/activities.json"
    click Batch "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/batch/batch.json"
    click School "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/school/school.json"
    click Unit "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/tap_lms/doctype/unit/unit.json"
    click HooksFixtures "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/hooks.py"
    click Registration "https://github.com/dalgot4d/frappe_tap/blob/master/tap_lms/config/__init__.py"
    click StaticAssets "https://github.com/dalgot4d/frappe_tap/tree/master/tap_lms/public/"
    click Reports "https://github.com/dalgot4d/frappe_tap/tree/master/tap_lms/tap_lms/report/"
    click TemplatesPages "https://github.com/dalgot4d/frappe_tap/tree/master/tap_lms/templates/pages/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef server fill:#90EE90,stroke:#000,stroke-width:1px
    classDef plugin fill:#FFA500,stroke:#000,stroke-width:1px
    classDef database fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef test stroke-dasharray: 5 5,fill:none,stroke:#000,stroke-width:1px
```
