What is Frappe web framework and the reasons to choose over Django

What is Frappe framework?

[official docs] Frappe is a full-stack, batteries-included, web framework written in Python and Javascript. It is the framework that powers ERPNext. It is pretty generic and can be used to build database-driven apps.

Frappe framework is more like no/less code, configuration oriented framework. It is a Meta-data driven web framework written in Python and Javascript with MariaDB as its database.

Key features of Frappe are:

  • MVC framework based on Werkzeug
  • ORM support
  • Auto generated UI based on Meta-data
  • Provides users, user roles and permissions
  • Comes with the scheduler (python RQ) for background jobs
  • Real-time notifications and web sockets
  • Templating based on Jinja
  • Multi-language support comes out of the box.
  • Re-usable apps
  • Rest API
  • Batteries included (email, OAUTH support, reports, payment gateway, chat)

When to use Frappe?

  • To build ERP systems since they do not recommend not to use outside the ERP.
  • Building the administration and business applications for small/medium-sized products.
  • Internal tools and portals used for reports

When to choose Frappe over Django?

  • To solve the business applications meant a set of features which come by default with Frappe.
  • A lot of features comes by default in Frappe helps us not to re-invent the wheel when building the products that use scheduler and auto report generation.

Architecture:

Frappe Architecture

The main key point to understand when looking at Frappe is how the database is declared and model-view building happens internally. It uses meta-data based declaration which is just a JSON file that creates the tables and fields in the database based on it and gives a rich user interface with its bindings to its corresponding database fields.


Frappe Stack:

  • Programming Languages: Python and Javascript
  • Database: MariaDB and Postgres(no support for ERPnext)
  • Webserver: Werkzeug
  • Templating: Jinja
  • Job Queues: Python RQ(Scheduler)
  • CSS Framework: Bootstrap 3
  • Caching: Redis(In-memory)
  • Realtime: NodeJS + Socketio.js
  • Javascript Packaging: Rollup
  • Webserver: gunicorn + NGINX (Production)
  • Process Manager (Production): supervisord
  • Process Manager (Develop): Honcho
  • Command Line: Bench
  • Wkhtmltopdf : Command line tool to process HTML in PDF (report generation)

Reasons to choose Frappe:

  • To build ERP/ business product
  • Ability to customize the architecture
  • Additional components as a default packages(emails, oath)

Relate Frappe with Django(setup):

Initialize the project

Django:

django-admin startproject django-project

Frappe:

bench init frappe-bench

Creating a new app in the project

Django:

python manage.py startapp custom_app

Frappe:

bench new-app custom_app

Start the server

Django:

python manage.py runserver

Frappe:

bench start

Key-terms:

  1. Desk:

The admin interface in Frappe is called Desk which is generated using the meta-data(JSON).DocTypes and automatically builds list views, form views, report views, etc for your DocTypes and allows the option to set permissions for users to view/modify it.

  1. DocType: DocType is responsible for models and views in Frappe, which holds the reason to be called as meta-based. It stores all the fields and its types of databases in JSON data. In short, it describes models and views.

Supports many-to-one relationship to the fields in the form of child DocType to a field.

3.Apps: It is a python package and should be under the directory apps in the frappe-bench directory. Each app should have an entry in apps.txt file just like in Django settinngs.py to be considered.

4.Links: The fields between two tables can be mapped with each other through Links and we need to specify the target fields from the parent table. This acts more of a foreign key reference.

Note: Remember that Link fields are not automatically set as Foreign Keys in the MariaDB database, because that will implicitly index the column. This may not be optimum hence the Foreign Key validation is done by the Framework.

  1. Reports:

Report generation works out of the box for Frappe without the need for the developer to work on it. It also suppors the scheduler to generate the reports and can be exported in many formats including PDF, XLSX.




Linked lists in Golang explained with real world applicationUnderstanding Python Bytecode