Files
DjangoAdmin_Tornado_EleVue/项目重构结构.txt
T
gitadmin fda0fe1a53
CI / lint (push) Canceled after 0s
CI / test (push) Canceled after 0s
签入版本
2026-09-16 10:08:07 +08:00

303 lines
16 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
DjangoAdmin_Tornado_EleVue/
├── app.py # ★ 应用入口(极简版)
├── pyproject.toml # ★ 项目配置(Poetry迁移)
├── poetry.lock # ★ 依赖锁定文件
├── .env # 环境配置
├── .env.example # 环境变量示例
├── .gitignore
├── .flake8 # 代码规范
├── .pre-commit-config.yaml # Git钩子
├── .mypy.ini # ★ 新增:类型检查配置
├── Makefile # ★ 常用命令(增强版)
├── Dockerfile # ★ 多阶段构建(优化版)
├── docker-compose.yml # ★ 端口8041(增强版)
├── docker-compose.override.yml # ★ 新增:开发覆盖配置
├── alembic.ini # 数据库迁移
├── LICENSE
├── README.md
├── README.en.md
├── CHANGELOG.md # ★ 新增:版本变更日志
├── CONTRIBUTING.md # ★ 新增:贡献指南
│
├── src/ # ★★★ 主要源代码
│ ├── __init__.py
│ ├── app.py # ★ 应用工厂函数(增强版)
│ ├── bootstrap.py # ★ 新增:启动引导程序
│ │
│ ├── core/ # ★ 核心基础设施层(增强版)
│ │ ├── __init__.py
│ │ ├── base_handler.py # ★ 增强:添加健康检查、优雅关闭
│ │ ├── base_repository.py # ★ 增强:添加软删除、审计
│ │ ├── base_service.py # ★ 增强:添加事件发布
│ │ ├── base_module.py # ★ 新增:模块CRUD基类(统一通用逻辑)
│ │ ├── response.py # ★ 统一响应
│ │ ├── exceptions.py # ★ 自定义异常(细化分类)
│ │ ├── jwt.py # ★ JWT管理(增强)
│ │ ├── database.py # ★ 连接池(添加读写分离)
│ │ ├── redis.py # ★ Redis(添加缓存装饰器)
│ │ ├── logger.py # ★ 结构化日志
│ │ ├── session.py # ★ Session管理
│ │ ├── event_bus.py # ★ 新增:事件总线
│ │ ├── cache.py # ★ 新增:缓存管理器
│ │ ├── metrics.py # ★ 新增:指标收集
│ │ └── tracer.py # ★ 新增:链路追踪
│ │
│ ├── config/ # ★ 配置层(增强版)
│ │ ├── __init__.py
│ │ ├── settings.py # ★ Pydantic配置(细化分类)
│ │ ├── constants.py # ★ 常量定义
│ │ ├── messages.py # ★ 消息定义
│ │ └── logging.py # ★ 新增:日志配置独立
│ │
│ ├── domain/ # ★★★ 新增:领域层(DDD)
│ │ ├── __init__.py
│ │ ├── entities/ # ★ 实体对象
│ │ │ ├── __init__.py
│ │ │ ├── user.py
│ │ │ ├── role.py
│ │ │ └── menu.py
│ │ ├── value_objects/ # ★ 值对象
│ │ │ ├── __init__.py
│ │ │ ├── email.py
│ │ │ ├── phone.py
│ │ │ └── password.py # ★ 密码值对象(bcrypt)
│ │ ├── events/ # ★ 领域事件
│ │ │ ├── __init__.py
│ │ │ ├── user_events.py
│ │ │ └── auth_events.py
│ │ └── repositories/ # ★ 仓储接口
│ │ ├── __init__.py
│ │ ├── user_repository.py
│ │ └── role_repository.py
│ │
│ ├── modules/ # ★★★ 业务模块(重构版)
│ │ ├── __init__.py
│ │ │
│ │ ├── auth/ # 认证授权模块
│ │ │ ├── __init__.py
│ │ │ ├── handlers.py # ★ 请求处理器(继承BaseHandler)
│ │ │ ├── service.py # ★ 业务逻辑(继承BaseService)
│ │ │ ├── repository.py # ★ 数据访问(继承BaseRepository)
│ │ │ ├── models.py # ★ 数据模型
│ │ │ ├── schemas.py # ★ Pydantic模型
│ │ │ └── constants.py
│ │ │
│ │ ├── user/ # 用户管理模块
│ │ │ ├── __init__.py
│ │ │ ├── handlers.py # ★ 使用BaseModuleCRUD
│ │ │ ├── service.py # ★ 使用领域实体
│ │ │ ├── repository.py
│ │ │ ├── models.py
│ │ │ └── schemas.py
│ │ │
│ │ ├── role/ # 角色管理模块
│ │ │ ├── __init__.py
│ │ │ ├── handlers.py # ★ 使用BaseModuleCRUD
│ │ │ ├── service.py
│ │ │ ├── repository.py
│ │ │ ├── models.py
│ │ │ └── schemas.py
│ │ │
│ │ ├── menu/ # 菜单管理模块
│ │ │ ├── __init__.py
│ │ │ ├── handlers.py # ★ 使用BaseModuleCRUD
│ │ │ ├── service.py
│ │ │ ├── repository.py
│ │ │ ├── models.py
│ │ │ └── schemas.py
│ │ │
│ │ ├── permission/ # ★ 新增:权限管理模块
│ │ │ ├── __init__.py
│ │ │ ├── handlers.py # ★ 使用BaseModuleCRUD
│ │ │ ├── service.py
│ │ │ ├── repository.py
│ │ │ ├── models.py
│ │ │ └── schemas.py
│ │ │
│ │ ├── dept/ # 部门管理模块
│ │ │ ├── __init__.py
│ │ │ ├── handlers.py # ★ 使用BaseModuleCRUD
│ │ │ ├── service.py
│ │ │ ├── repository.py
│ │ │ ├── models.py
│ │ │ └── schemas.py
│ │ │
│ │ ├── dict/ # 字典管理模块
│ │ │ ├── __init__.py
│ │ │ ├── handlers.py # ★ 使用BaseModuleCRUD
│ │ │ ├── service.py
│ │ │ ├── repository.py
│ │ │ ├── models.py
│ │ │ └── schemas.py
│ │ │
│ │ └── ... # 其他模块(依此类推)
│ │
│ ├── common/ # ★ 公共模块
│ │ ├── __init__.py
│ │ │
│ │ ├── middleware/ # 中间件
│ │ │ ├── __init__.py
│ │ │ ├── authentication.py # ★ 认证(增强)
│ │ │ ├── permission.py # ★ 权限(增强)
│ │ │ ├── cors.py # CORS
│ │ │ ├── rate_limit.py # 限流
│ │ │ ├── operation_log.py # 操作日志
│ │ │ ├── trace_id.py # ★ 新增:链路追踪ID
│ │ │ └── metrics.py # ★ 新增:性能监控
│ │ │
│ │ ├── utils/ # 工具函数
│ │ │ ├── __init__.py
│ │ │ ├── captcha.py # 验证码
│ │ │ ├── crypto.py # ★ 加密工具(bcrypt)
│ │ │ ├── file.py # 文件操作
│ │ │ ├── image.py # 图片处理
│ │ │ ├── validators.py # 数据验证
│ │ │ ├── helpers.py # 辅助函数
│ │ │ └── fonts/
│ │ │ └── Vera.ttf
│ │ │
│ │ └── decorators/ # ★ 新增:装饰器
│ │ ├── __init__.py
│ │ ├── cache.py # 缓存装饰器
│ │ ├── retry.py # 重试装饰器
│ │ ├── timer.py # 性能计时
│ │ └── transaction.py # 事务装饰器
│ │
│ ├── extensions/ # ★ 扩展
│ │ ├── __init__.py
│ │ ├── sqlalchemy.py # ★ SQLAlchemy(增强审计)
│ │ ├── redis.py # ★ Redis(增强)
│ │ ├── session.py # Session
│ │ ├── swagger.py # ★ 新增:Swagger文档
│ │ └── sentry.py # ★ 新增:错误监控
│ │
│ └── api/ # ★ 新增:API版本管理
│ ├── __init__.py
│ ├── v1/ # API v1版本
│ │ ├── __init__.py
│ │ ├── auth.py
│ │ ├── users.py
│ │ └── ...
│ └── v2/ # API v2版本(预留)
│ └── __init__.py
│
├── tests/ # ★★★ 测试(大幅增强)
│ ├── __init__.py
│ ├── conftest.py # ★ pytest配置(增强)
│ ├── unit/ # 单元测试
│ │ ├── __init__.py
│ │ ├── core/
│ │ │ ├── test_cache.py
│ │ │ ├── test_jwt.py
│ │ │ ├── test_base_module.py # ★ 新增:测试BaseModuleCRUD
│ │ │ └── ...
│ │ ├── domain/ # ★ 领域层测试
│ │ │ ├── test_user_entity.py
│ │ │ └── test_password_value.py
│ │ └── modules/
│ │ ├── test_auth.py
│ │ ├── test_user.py
│ │ └── ...
│ ├── integration/ # 集成测试
│ │ ├── __init__.py
│ │ ├── test_api.py
│ │ ├── test_database.py
│ │ └── test_redis.py
│ ├── e2e/ # ★ 新增:端到端测试
│ │ ├── __init__.py
│ │ ├── test_user_flow.py
│ │ └── test_auth_flow.py
│ ├── performance/ # ★ 新增:性能测试
│ │ ├── __init__.py
│ │ ├── test_load.py
│ │ └── test_stress.py
│ ├── fixtures/ # 测试数据
│ │ ├── __init__.py
│ │ ├── users.json
│ │ ├── data.sql
│ │ └── factories.py # ★ 新增:工厂模式
│ └── reports/ # ★ 新增:测试报告
│ └── .keep
│
├── scripts/ # ★★★ 运维脚本(增强版)
│ ├── __init__.py
│ ├── init_db.py # 数据库初始化
│ ├── seed.py # 测试数据填充
│ ├── migrate.py # 数据库迁移
│ ├── deploy.py # 部署脚本
│ ├── health_check.py # ★ 新增:健康检查脚本
│ ├── backup.py # ★ 新增:数据库备份
│ └── monitor.py # ★ 新增:监控脚本
│
├── alembic/ # 数据库迁移
│ ├── env.py # ★ 自动检测模型(增强)
│ ├── script.py.mako
│ └── versions/
│ └── .keep
│
├── logs/ # 日志目录
│ ├── .keep
│ ├── app.log
│ ├── error.log
│ └── access.log
│
├── uploads/ # 上传文件
│ ├── demo/
│ ├── images/
│ │ ├── user/
│ │ ├── article/
│ │ └── ...
│ ├── temp/
│ └── level.xlsx
│
├── static/ # 静态文件
├── templates/ # 模板文件
│ └── errors/ # ★ 新增:错误页面
│ ├── 404.html
│ └── 500.html
│
├── document/ # 文档
│ ├── sql/ # ★ 数据库脚本
│ │ ├── init.sql
│ │ └── data.sql
│ ├── adr/ # ★ 新增:架构决策记录
│ │ ├── 001-use-poetry.md
│ │ ├── 002-event-driven.md
│ │ └── ...
│ ├── api/ # ★ 新增:API文档
│ │ └── swagger.yaml
│ ├── djangoadmin.tornado.elevue.sql
│ ├── 开发笔记.txt
│ └── 版本更新说明.txt
│
├── deploy/ # ★★★ 部署配置(增强版)
│ ├── nginx/
│ │ ├── nginx.conf
│ │ └── ssl/ # ★ 新增:SSL证书目录
│ │ ├── cert.pem
│ │ └── key.pem
│ ├── supervisor/
│ │ └── supervisor.conf
│ ├── prometheus/ # ★ 新增:监控配置
│ │ └── prometheus.yml
│ ├── grafana/ # ★ 新增:可视化配置
│ │ └── dashboards/
│ │ └── app.json
│ ├── elk/ # ★ 新增:日志收集
│ │ ├── elasticsearch.yml
│ │ └── logstash.conf
│ └── kubernetes/ # ★ 新增:K8s部署(可选)
│ ├── deployment.yaml
│ ├── service.yaml
│ └── ingress.yaml
│
└── .github/ # ★ 新增:GitHub CI/CD
├── workflows/
│ ├── ci.yml # ★ CI流水线
│ ├── cd.yml # ★ CD流水线
│ └── security-scan.yml # ★ 安全扫描
└── ISSUE_TEMPLATE/
├── bug_report.md
└── feature_request.md
重置为纯净结构,可 python scripts/init_db.py(按模型建空表)再 python scripts/seed.py(创建 admin)