refactor(structure): reorganize app layout

BREAKING CHANGE: root backend/frontend directories and old run/manage entrypoints were removed. Use apps/backend, apps/frontend, and python main.py commands instead.
This commit is contained in:
2026-05-03 16:43:11 +08:00
parent 7e8852877e
commit d4d6f87730
112 changed files with 347 additions and 1596 deletions
+2 -2
View File
@@ -152,7 +152,7 @@ CheckIn App V2 采用用户-任务分离架构,一个用户可管理多个打
### 后端分层
```
backend/
apps/backend/
├── api/ # 路由层(29 个端点)
├── services/ # 业务逻辑层
├── models/ # 数据模型层
@@ -164,7 +164,7 @@ backend/
### 前端分层
```
frontend/src/
apps/frontend/src/
├── api/ # API 调用封装
├── views/ # 页面组件
├── components/ # 可复用组件
+4 -4
View File
@@ -37,7 +37,7 @@ python3 -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r backend/requirements.txt
pip install -r apps/backend/requirements.txt
# 生产环境额外依赖
pip install gunicorn
@@ -50,7 +50,7 @@ vim .env # 修改环境变量
#### 2. 前端部署
```bash
cd frontend
cd apps/frontend
# 安装依赖
npm install
@@ -63,11 +63,11 @@ npm run build
**使用 Nginx 托管**:
[示例文件](../nginx.conf.example)
[示例文件](../deploy/nginx/checkin-app.conf.example)
#### 3. 使用 Systemd 管理
[示例文件](../checkin-app.service.example)
[示例文件](../deploy/systemd/checkin-app.service.example)
### 方式二:Docker 部署(推荐)
+11 -11
View File
@@ -15,18 +15,18 @@ source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# 安装依赖
pip install -r backend/requirements.txt
pip install -r apps/backend/requirements.txt
# 安装开发依赖
pip install pytest pytest-asyncio black flake8
python3 run.py
python main.py backend
```
### 前端开发
```bash
cd frontend
cd apps/frontend
# 安装依赖
npm install
@@ -44,7 +44,7 @@ npm run format
### 后端目录说明
```
backend/
apps/backend/
├── main.py # FastAPI 应用入口,CORS、路由注册
├── config.py # Pydantic Settings 配置
├── dependencies.py # 依赖注入(认证、权限)
@@ -89,7 +89,7 @@ backend/
### 前端目录说明
```
frontend/src/
apps/frontend/src/
├── main.js # Vue 应用入口
├── App.vue # 根组件
@@ -162,8 +162,8 @@ def create_tag(db: Session, task_id: int, tag_data: TaskTagCreate):
def add_tag(task_id: int, tag: TaskTagCreate, db: Session = Depends(get_db)):
return tag_service.create_tag(db, task_id, tag)
# main.py
from api import tags
# apps/backend/main.py
from backend.api import tags
app.include_router(tags.router, prefix="/api")
```
@@ -211,10 +211,10 @@ export const useTagStore = defineStore('tag', {
```bash
# 修改模型后生成迁移脚本
# 手动创建脚本在 backend/scripts/migrate_*.py
# 手动创建脚本在 apps/backend/scripts/migrate_*.py
# 执行迁移
python backend/scripts/migrate_xxx.py
PYTHONPATH=apps python apps/backend/scripts/migrate_xxx.py
```
### 测试
@@ -232,7 +232,7 @@ def test_create_task():
assert task.is_active == True
# 运行测试
pytest backend/tests/
PYTHONPATH=apps pytest apps/backend/tests/
```
#### 前端测试
@@ -257,7 +257,7 @@ npm run test
### 后端规范
- 使用 Black 格式化: `black backend/`
- 使用 Black 格式化: `black apps/backend/`
- 遵循 PEP 8
- 函数添加类型注解
- API 路由使用 Pydantic 模型验证