Skip to content

🏗️ Kiến trúc Hệ thống

Tóm tắt

Ứng dụng tuân thủ cấu trúc 7-Layer Frappe — mỗi lớp có trách nhiệm riêng, không vi phạm ranh giới.

Sơ đồ 7 lớp

Chi tiết từng lớp

LớpThư mục / FileVai trò trong Frappe x Haravan
1. DocType Schemalogin_with_haravan/login_with_haravan/doctype/Định nghĩa DocType haravan_account, haravan_account_link
2. Controllerdoctype/*/haravan_account.pyXử lý lifecycle event của DocType (before_save, validate, v.v.)
3. Enginelogin_with_haravan/engines/Logic nghiệp vụ thuần túy — sync_helpdesk.py chứa upsert_hd_customer, create_contact, link_account
4. Whitelist APIlogin_with_haravan/oauth.pyEndpoint callback OAuth (login_via_haravan), API lấy org (get_user_haravan_orgs)
5. Hookslogin_with_haravan/hooks.pyĐăng ký web_include_js, after_migrate, doc_events
6. Frontendlogin_with_haravan/public/js/Script giao diện: Vietnamese UI override, custom buttons
7. Setup / Installlogin_with_haravan/setup/install.pyTạo Social Login Key, Custom Fields khi after_migrate

Nguyên tắc thiết kế

  1. Không sửa Frappe core hay Frappe Helpdesk core. Mọi tuỳ biến nằm trong custom app.
  2. Engine không import frappe trực tiếp — nhận dữ liệu đã chuẩn hóa từ API layer.
  3. Whitelist API là cửa ngõ duy nhất — Client/webhook gọi API, API gọi Engine.
  4. Hooks chỉ đăng ký, không chứa logic — Hook trỏ đến hàm trong Engine hoặc Setup.
  5. Setup idempotentafter_migrate có thể chạy lại nhiều lần mà không gây lỗi.

Xem thêm