Technology Based Blogs

Coding in Comfort: A Deep Dive into Frappe Framework’s Revolutionary Features

Coding in Comfort: A Deep Dive into Frappe Framework’s Revolutionary Features

Introduction:

Choosing the correct framework is essential for developing scalable and reliable solutions in the field of web application development. Among the several options accessible, Frappe Framework stands out as a robust and powerful that streamlines the development process while providing a diverse set of features and functionalities. We’ll go into the world of Frappe in this blog article, examining its features, benefits, and applications.

Frappe is a comprehensive web framework that operates as a full stack, written in Python and Javascript, and utilizing MariaDB as its database, Frappe serves as the backbone for ERPNext. While specifically designed for ERP applications, its versatility extends to the creation of various database-driven applications.

Why Frappe?

Because of its distinct methodology—treating meta-data as data—Frappe stands out from other frameworks. This unique characteristic makes front-end development easier. Adopting a monolithic architecture, Frappe is made to include almost every necessary component needed to construct a contemporary online application.

Frappe is built on a sophisticated Admin UI called the Desk. This extensive interface includes a variety of built-in features such as forms, navigation, lists, menus, permissions, file attachments, and more. By using Frappe, you may quickly and easily create complex web apps with an environment rich with features that streamlines the development process.

Advantages of Using Frappe Framework:

  • Rapid Development: Frappe accelerates the development process by providing pre-built modules, forms, and workflows, allowing developers to focus on building application logic rather than reinventing the wheel.
  • Scalability: Whether you’re building a small business application or a large-scale enterprise solution, Frappe offers scalability and flexibility to meet your evolving needs.
  • Community Support: The Frappe community is vibrant and active, with a wealth of resources, documentation, and forums available for support and collaboration.
  • Open Source: Being an open-source framework, Frappe offers transparency, flexibility, and cost-effectiveness, making it an ideal choice for businesses of all sizes.

Key Features of Frappe:

  • Document Management: Frappe offers a robust document management system that allows developers to define document types, create custom forms, and manage data efficiently.
  • User Interface: With Frappe’s user-friendly interface, developers can easily create intuitive and visually appealing applications. The framework provides pre-built UI components and layouts that can be customized to suit specific requirements.
  • Data Management: Frappe simplifies data management with its built-in Object-Relational Mapping (ORM) system, which abstracts database operations and facilitates seamless interaction with data.
  • Role-Based Permissions: Frappe’s role-based permission system enables developers to define granular access controls, ensuring that users only have access to the information and functionalities that are relevant to their roles.
  • Email and Notification: Frappe includes a built-in email and notification system, allowing applications to send emails, alerts, and reminders to users based on predefined triggers and events.

Use Cases of Frappe:

Frappe finds application across various industries and domains, including:

Prerequisites

  1. Python
  2. MariaDB / Postgres
  3. HTML / CSS
  4. JavaScript / jQuery
  5. Git / GitHub

Getting Started

Install Bench CLI

Install bench via pip3

pip3 install frappe-bench
view raw Frappe_1.py hosted with ❤ by GitHub

Confirm the bench installation by checking version

bench --version
view raw Frappe_2.py hosted with ❤ by GitHub

Create your first bench folder.

cd ~
bench init frappe-bench
view raw Frappe_3.py hosted with ❤ by GitHub

Run the following command from the frappe-bench  directory:

cd frappe-bench
bench start
view raw Frappe_4.py hosted with ❤ by GitHub

Directory Structure

.
├── Procfile
├── apps
│ └── frappe
├── config
│ ├── pids
│ ├── redis_cache.conf
│ ├── redis\_queue.conf
│ └── redis\_socketio.conf
├── env
│ ├── bin
│ ├── include
│ ├── lib
│ └── share
├── logs
│ ├── backup.log
│ └── bench.log
└── sites
├── apps.txt
├── assets
└── common\_site\_config.json

To create library_management app, run the following command from the frappe-bench  directory:

bench new-app library_management
view raw Frappe_5.py hosted with ❤ by GitHub

App directory structure

apps/library_management
├── README.md
├── library_management
│ ├── hooks.py
│ ├── library_management
│ │ └── __init__.py
│ ├── modules.txt
│ ├── patches.txt
│ ├── public
│ │ ├── css
│ │ └── js
│ ├── templates
│ │ ├── __init__.py
│ │ ├── includes
│ │ └── pages
│ │ └── __init__.py
│ └── www
└── pyproject.toml

To create a new site, run the following command from the frappe-bench  directory:

bench new-site library.test
view raw Frappe_6.py hosted with ❤ by GitHub

Site Directory Structure

sites/library.test
├── indexes
│ └── web_routes
├── locks
├── logs
├── private
│ ├── backups
│ └── files
├── public
│ └── files
└── site_config.json

The site_config.json file contains configuration that is specific to this site which should not be version controlled. This is similar to an environment variables file. If you look at the contents of the file, it contains the database configuration values for this site.

{
"db_name": "_ad03fa1a016ca1c4",
"db_password": "pz1d2gN5y35ydRO5",
"db_type": "mariadb"
}

Now, that we have created our first site, we can access it on http://localhost:8000 in our browser.

Access site in your browser

Frappe will identify which site to serve by matching the hostname of the request with the site name, so you should be able to access your site on http://library.test:8000 but this won’t work because we have to tell our operating system that library.test should point to localhost. To do that, you can add the following entry to your /etc/hosts file.

127.0.0.1 library.localhost

 This will map library.test to localhost. Bench has a convenient command to do just that.

bench --site library.localhost add-to-hosts
view raw Frappe_9.py hosted with ❤ by GitHub

This will ask for your root password and will add an entry to your /etc/hosts file.Great, now you can access your site at http://library.test:8000.

frappe framework login

Install app on site:

To install our Library Management app on our site, run the following command:

bench --site library.localhost install-app library_management
view raw Frappe_10.py hosted with ❤ by GitHub

You should see frappe and library_management as installed apps on your site. To confirm if the app was installed, run the following command:

bench --site library.localhost list-apps
view raw Frappe_11.py hosted with ❤ by GitHub

After successful login, you will see the setup wizard. This is a one-time setup wizard used to set up localization details for your site. Go ahead, select your language, and complete the wizard. You should see the Desk that looks something like this:

frappe framework desk

Conclusion:

Frappe is more than just a framework—it’s a powerful platform for building innovative and feature-rich business applications. With its intuitive interface, robust features, and active community support, Frappe empowers developers to bring their ideas to life and create solutions that drive business growth and success.

References:

https://frappeframework.com/docs/user/en/basics

https://frappeframework.com/docs/user/en/tutorial