Frappe Framework is a full-stack web framework built on a metadata-driven architecture. This guide explains the core architectural components and how they work together.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.
High-level overview
Core components
1. Metadata-driven architecture
At the heart of Frappe is its metadata system. Instead of writing repetitive code for forms, APIs, and database schemas, you define what your data looks like, and Frappe generates the how.- Database table schema
- REST API endpoints
- Admin UI forms and list views
- JavaScript form controllers
- Permission checks
- Validation logic
This is the “best code is no code” philosophy in action. You get full CRUD applications with minimal custom code.
2. DocType system
DocTypes are Frappe’s metadata models that describe business objects.What is a DocType?
What is a DocType?
A DocType is a model definition that contains:
- Field definitions (name, type, options)
- Naming rules
- Permission rules
- Behavior flags (is_submittable, is_child, etc.)
- Hooks for custom logic
DocType types
DocType types
- Standard: Regular documents (e.g., Sales Order, User)
- Child: Nested in parent documents (e.g., Order Item)
- Single: Only one instance exists (e.g., Settings)
- Virtual: No database storage, computed on-the-fly
Field types
Field types
Frappe provides 40+ field types:
- Basic: Data, Int, Float, Currency
- Text: Text, Long Text, Text Editor
- Relations: Link, Table
- Special: Attach, Image, Signature, Barcode
- And many more…
3. Document lifecycle
Documents (instances of DocTypes) flow through a predictable lifecycle: Key lifecycle hooks:4. Database layer
Frappe abstracts database operations through multiple interfaces:5. Multi-tenancy (Sites)
Frappe is multi-tenant by design. Each site is an isolated instance with:- Its own database
- Separate file storage
- Independent configuration
- Different installed apps
6. Application structure
Frappe apps follow a conventional structure:7. Hooks system
Hooks are Frappe’s extension mechanism. Define hooks inhooks.py to inject custom behavior:
8. Permission system
Frappe has a sophisticated role-based permission system:DocType permissions
Define what each role can do with a DocType (read, write, create, delete, submit, etc.)
User permissions
Restrict access to specific documents (e.g., a user can only see their own articles)
9. REST API layer
Frappe automatically exposes REST APIs for all DocTypes:| Method | Endpoint | Action |
|---|---|---|
| GET | /api/resource/:doctype | List documents |
| GET | /api/resource/:doctype/:name | Get document |
| POST | /api/resource/:doctype | Create document |
| PUT | /api/resource/:doctype/:name | Update document |
| DELETE | /api/resource/:doctype/:name | Delete document |
10. Real-time communication
Frappe includes SocketIO for real-time features:11. Background jobs
Long-running tasks run in background workers using RQ (Redis Queue):12. Request-response flow
Here’s what happens when a request hits Frappe:Framework components in detail
frappe.local
Thread-local storage for request context:frappe.db
Database interface:frappe.cache
Redis-backed cache:Design principles
Convention over configuration
Follow Frappe’s conventions, and things work automatically
Metadata-driven
Define data structures once, get UI, API, and storage
Modular apps
Build reusable apps that can be installed on any site
Multi-tenant by default
Every deployment can host multiple isolated sites
Performance considerations
Caching
Caching
- Redis caches DocType metadata, user permissions, and custom data
- Use
@frappe.whitelist(allow_guest=True)for public pages - Implement page caching for public websites
Database optimization
Database optimization
- Add indexes for frequently queried fields
- Use
frappe.get_all()instead of loading full documents - Batch operations when possible
- Use Query Builder for complex queries
Background jobs
Background jobs
- Move heavy processing to background workers
- Use appropriate queue (short/default/long)
- Implement progress tracking with
publish_progress()
Next steps
DocType guide
Deep dive into DocTypes and field types
Python API reference
Explore the full Python API
Building apps
Build production-ready applications
Deployment
Deploy Frappe to production