#1 Frappe 框架
低代码 Frappe 2023-05-08Frappe Framework 是一个基于 Python 的开源 Web 应用框架,定位于低代码业务平台,强调通过元数据驱动快速构建企业级系统。其核心抽象是 DocType(数据模型),开发者通过定义数据结构即可自动生成数据库表、表单界面、列表视图及基础 API,大幅降低 CRUD 类系统开发成本。框架内置权限控制、工作流引擎、报表系统和 REST 接口,支持多租户架构,适合 SaaS 化部署。
在 UI 层,Frappe 采用“后端驱动 + 自动生成”的模式,基于 DocType 自动生成标准后台界面(Form、List、Report 等),多数中后台场景无需手写前端代码。同时也提供分层扩展能力:通过 Client Script 实现表单交互与校验,通过 Custom Page 构建自定义页面,或在需要时完全接管前端,采用 Vue/React 等框架调用其 REST API,实现 Headless 架构。
后端方面,开发者可基于 Python 扩展业务逻辑(如 hooks、controller、scheduler),并通过模块化 App 机制进行功能解耦与复用。Frappe 提供完整的开发与运维工具链(如 Bench),支持插件化扩展,生态中典型应用包括 ERPNext 等。总体来看,Frappe 更接近一个“可编程业务平台”,适用于中后台系统、流程驱动型应用以及需要快速迭代的企业级场景。
授权协议:Frappe 框架是 MIT 协议,官方提供的应用都是 GPLv3 或者 AGPLv3 协议。
架构
- https://github.com/frappe/frappe
- https://frappeframework.com/docs/v14/user/en/basics/architecture
- https://frappeframework.com/docs/v14/user/en/basics/directory-structure

依赖
- 后端
- Python 3.10+
- Jinja2 模板
- Werkzeug
- MariaDB / Postgres
- Redis 6
- Nginx
- cron
- Python 3.10+
- 前端
- Node.js 16
- BootStrap
- jQuery
安装
sudo apt install -y git python-dev python-pip redis-server
sudo apt install -y mariadb-server mariadb-client
pip3 install frappe-bench
bench --version
➜ type bench
bench is /home/catroll/.python/bin/bench
➜ cat /home/catroll/.python/bin/bench
#!/home/catroll/.python/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from bench.cli import cli
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(cli())
➜ bench --help
WARN: Command not being executed in bench directory
Usage: [OPTIONS] COMMAND [ARGS]...
Options:
--version
--use-feature TEXT
-v, --verbose
--help Show this message and exit.
Commands:
app-cache View or remove items belonging to bench...
backup-all-sites Backup all sites in current bench
config Change bench configuration
disable-production Disables production environment for the bench.
download-translations Download latest translations
drop
exclude-app Exclude app from updating
find Finds benches recursively from location
get Clone an app from the internet or filesystem...
get-app Clone an app from the internet or filesystem...
include-app Include app for updating
init Initialize a new bench instance in the...
install Install system dependencies for setting up...
migrate-env Migrate Virtual Environment to desired Python...
new-app Create a new Frappe application under apps folder
pip For pip help use `bench pip help [COMMAND]` or...
remote-reset-url Reset app remote url to frappe official
remote-set-url Set app remote url
remote-urls Show apps remote url
remove Completely remove app from bench and re-build...
remove-app Completely remove app from bench and re-build...
renew-lets-encrypt Sets Up latest cron and Renew Let's Encrypt...
restart Restart supervisor processes or systemd units
retry-upgrade Retry a failed upgrade
rm Completely remove app from bench and re-build...
set-mariadb-host Set MariaDB host for bench
set-nginx-port Set NGINX port for site
set-redis-cache-host Set Redis cache host for bench
set-redis-queue-host Set Redis queue host for bench
set-redis-socketio-host Set Redis socketio host for bench
set-ssl-certificate Set SSL certificate path for site
set-ssl-key Set SSL certificate private key path for site
set-url-root Set URL root for site
setup Setup command group for enabling setting up a...
src Prints bench source folder path, which can be...
start Start Frappe development processes
switch-to-branch Switch all apps to specified branch, or...
switch-to-develop Switch frappe and erpnext to develop branch
update Performs an update operation on current bench.
validate-dependencies Validates that all requirements specified in...
bench init
➜ sudo mkdir -p /opt/frappe
➜ sudo chown catroll:catroll /opt/frappe
➜ cd /opt/frappe
bench init helloworld --skip-redis-config-generation --version version-15 --frappe-path https://gitee.com/mirrors/frappe
# 通过 Git 克隆一个 Frappe 项目到本地,
# git clone https://gitee.com/mirrors/frappe --branch version-16 --depth 1 --origin upstream
# 创建 Python 虚拟环境并安装 Python 依赖,
# uv pip install --quiet --upgrade -e helloworld/apps/frappe --python helloworld/env/bin/python
# 然后使用 yarn 安装 Node 依赖,
# yarn install --check-files
# 还有就是编译多语言文件(MO 文件)。
# --skip-redis-config-generation
# 默认 Redis Server 在本地安装,会执行本地命令获取 Redis 版本号等操作。
# 跳过 Redis 配置,后面在 common-site-config 中手动配置。
# --version version-15
# 默认使用主干开发分支,我这里制定一个稳定版本。
# 而且 16/17 要求 Python 3.14 以上,而我本地安装的是 Python 3.12,懒得折腾。
# --frappe-path https://gitee.com/mirrors/frappe
# 使用国内镜像,稍微提提速。
cd helloworld
bench start
➜ tree -L 2
.
├── Procfile
├── apps
│ └── frappe
├── config
│ └── pids
├── env
│ ├── CACHEDIR.TAG
│ ├── bin
│ ├── lib
│ ├── lib64 -> lib
│ ├── pyvenv.cfg
│ └── share
├── logs
│ └── bench.log
├── patches.txt
└── sites
├── apps.json
├── apps.txt
├── assets
└── common_site_config.json
13 directories, 8 files
默认生成的 helloworld/sites/common_site_config.json 文件:
{
"background_workers": 1,
"file_watcher_port": 6787,
"frappe_user": "catroll",
"gunicorn_workers": 41,
"live_reload": true,
"rebase_on_pull": false,
"redis_cache": "redis://127.0.0.1:13000",
"redis_queue": "redis://127.0.0.1:11000",
"redis_socketio": "redis://127.0.0.1:13000",
"restart_supervisor_on_update": false,
"restart_systemd_on_update": false,
"serve_default_site": true,
"shallow_clone": true,
"socketio_port": 9000,
"use_redis_auth": false,
"webserver_port": 8000
}
Frappe Products
Business Apps
-
ERPNext
Manage accounting, inventory, and operations -
Frappe HR
Handle employees, attendance, payroll, and HR processes -
Learning(在线课程 LMS)
Create, manage, and deliver structured online courses -
Insights(BI)
Analyze data and create interactive dashboards and reports -
CRM
Track leads, contacts, deals, and customer interactions -
Helpdesk
Deliver customer support through tickets and workflows -
Lending(金融借贷)
Manage loans, repayments, and borrower accounts
Developer Tools
-
Framework(低代码框架)
Build and customize full-stack web applications -
Builder(可视化建站)
Create websites and pages visually without writing code
Productivity Tools
-
Gameplan(项目管理)
Plan work, share updates, and track progress across teams -
Drive(类似 Google Drive 的文件系统)
Store, share, and collaborate on documents
Infrastructure
-
Cloud(官方 SaaS 平台)
The official Cloud platform for Frappe applications -
Press(自建云平台)
Full service cloud hosting for the Frappe stack
Libraries
-
Bench(开发与运维工具)
Command-line tool for managing multi-tenant Frappe deployments -
Datatable(表格库)
JavaScript library for building interactive data tables -
Charts(图表库)
JavaScript library for creating interactive charts and visualizations -
Gantt(甘特图库)
Gantt chart library for creating interactive project timelines