This guide walks you through creating a simple “Library Management” app to demonstrate Frappe’s core features. By the end, you’ll have a working application with data entry forms, list views, and a REST API.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/frappe/frappe/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites: Complete the installation guide and have a Frappe site running locally.
Create your first app
Apps in Frappe are Python packages that contain your business logic, DocTypes, and customizations.Create a new app
Use bench to scaffold a new application:You’ll be prompted for:
- App title: Library Management
- App description: Manage library books and members
- Publisher: Your name
- Email: Your email
- License: MIT
~/frappe-bench/apps/library_management with the following structure:Create your first DocType
DocTypes are Frappe’s metadata models. They define the structure of your data and automatically generate forms, APIs, and database tables.Create the Article DocType
We’ll create an Article DocType to represent library books:
- Open your browser and go to
http://frappe.localhost:8000/app - In the search bar (Ctrl+K or ⌘K), type “New DocType”
- Fill in the following:
Basic information
Basic information
- Name: Article
- Module: Library Management
- Is Submittable: Unchecked (for now)
Fields
Fields
Add these fields by clicking “Add Row” in the Fields table:
| Label | Type | Options | Mandatory |
|---|---|---|---|
| Article Name | Data | - | Yes |
| Image | Attach Image | - | No |
| Author | Data | - | No |
| Description | Text Editor | - | No |
| ISBN | Data | - | No |
| Status | Select | Issued\nAvailable | Yes |
| Publisher | Data | - | No |
- Set Naming to “field:article_name”
- Click Save
Add server-side logic
Let’s add Python code to validate and process Article documents.Create the Python controller
Create a file at
apps/library_management/library_management/library_management/doctype/article/article.py:Frappe automatically calls these methods at the right time in the document lifecycle:
before_save()- Before saving to databasevalidate()- During validationafter_insert()- After creating a new documenton_update()- After updatingon_trash()- Before deletion
Add a whitelisted API method
Create a custom API endpoint that can be called from the frontend or external systems.Add an API method
Add this method to your The
article.py file:@frappe.whitelist() decorator makes this method accessible via HTTP.Use the automatic REST API
Frappe automatically generates REST API endpoints for all DocTypes.For authenticated requests, you’ll need to include API keys or session cookies. See REST API authentication for details.
Add a child table
Let’s create a Library Member DocType with a child table for tracking borrowed articles.Create Library Member DocType
Create a new DocType named “Library Member” with these fields:
| Label | Type | Options |
|---|---|---|
| Full Name | Data | - |
| Data | - | |
| Phone | Data | - |
| Borrowed Articles | Table | Library Transaction |
Create Library Transaction child DocType
Create another DocType named “Library Transaction”:
- Check Is Child Table
-
Add these fields:
Label Type Options Article Link Article Date Borrowed Date - Date Returned Date -
Add client-side scripting
Customize form behavior with JavaScript.Query the database
Frappe provides multiple ways to query your data.Background jobs
For long-running tasks, use Frappe’s background job queue.What you’ve learned
Congratulations! You’ve built a working Frappe application with:DocTypes
Metadata-driven data models
Server-side logic
Python controllers and validation
REST API
Automatic and custom endpoints
Client scripting
Form customization with JavaScript
Next steps
Architecture overview
Understand Frappe’s architecture
DocType deep dive
Master DocTypes and field types
Permissions
Set up role-based permissions
Hooks
Extend Frappe with hooks