Skip to content

MarkTina/BackendTemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Scaffold

一个基于 Django 5 + DRF + Celery 的后端脚手架模板,开箱具备:

  • 全链路追踪日志:trace_id / request_id / order_id / user_id 自动注入,正式环境输出 JSON,便于 PLG (Promtail / Loki / Grafana) 采集。
  • 支付中心对接:HMAC-SHA256 签名客户端 + 异步回调验签 + Celery 履约任务模板,与外置支付中心微服务直接通信。
  • JWT 认证 + DRF + drf-spectacular OpenAPI 文档。
  • Docker / docker-compose 一键部署,1panel 网络兼容。

目录结构

.
├── Dockerfile
├── docker-compose.yml
├── .env.development            # 开发环境变量(示例)
├── .env.production             # 生产环境变量(示例,由 docker-compose 注入)
├── docs/
│   └── 2026-05-07_01_脚手架使用说明.md
└── app/
    ├── manage.py
    ├── requirements.txt
    ├── backend_scaffold/       # Django 项目(settings/wsgi/asgi/celery/urls)
    │   ├── settings/
    │   │   ├── base.py
    │   │   ├── development.py
    │   │   └── production.py
    │   └── ...
    ├── core/                   # 基础设施(脚手架不可删)
    │   ├── common/             # 日志过滤器、日志工具
    │   └── middleware/         # 链路追踪中间件
    ├── users/                  # 自定义 User 模型(仅保留 phone/openid 占位)
    └── payment/                # 支付中心对接示例
        ├── payment_client.py
        ├── payment_config.py
        ├── views.py
        ├── webhook_views.py
        └── tasks.py

快速开始

详细使用说明请阅读 docs/2026-05-07_01_脚手架使用说明.md

# 1. 安装依赖
cd app && pip install -r requirements.txt

# 2. 准备 .env.development(复制根目录下的示例并填值)
cp ../.env.development ../.env.development.local  # 按需

# 3. 数据库迁移
python manage.py makemigrations
python manage.py migrate

# 4. 启动
python manage.py runserver

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors