Skip to content

Commit 9c71d97

Browse files
committed
v2.5.3f
1 parent 8cdaad7 commit 9c71d97

45 files changed

Lines changed: 3536 additions & 1743 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 98 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -2,119 +2,115 @@
22

33
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
44

5-
## 🤖 代理专属规则
6-
> 重要:以下规则仅对开发代理有效
7-
- 用户用中文提问时,请用中文回答
8-
- 编辑已存在的文件时,优先使用 edit 工具,不要使用 write 工具
9-
- 编辑前端代码后运行 `pnpm type-check`**禁止自动运行 `pnpm build`**,除非用户明确要求
10-
- 提交代码前必须执行对应语言的格式化和检查命令
5+
## 🤖 Agent Rules
6+
> Important: The following rules apply to development agents only
7+
- When the user asks in Chinese, respond in Chinese
8+
- When editing existing files, prefer the `edit` tool over the `write` tool
9+
- After editing frontend code, run `pnpm type-check`. **Do NOT auto-run `pnpm build`** unless explicitly requested
10+
- Before committing code, run the corresponding language's formatting and linting commands
11+
- Do NOT add code comments unless explicitly asked
12+
- Keep responses concise and technical; avoid conversational filler
1113

1214
---
1315

14-
## 项目概述
15-
基于 FastAPI + Vue 3 的全栈阅读清单管理与个人博客系统,包含用户认证、书籍管理、微信读书导入、博客系统、留言板、RSS 阅读器、AI 助手、后台监控等功能。
16+
## Project Overview
17+
Full-stack reading list management and personal blog system built with FastAPI + Vue 3. Features include user authentication, book management, WeRead import, blog system, guestbook, RSS reader, AI assistant, and admin monitoring.
1618

17-
## 常用命令
19+
## Common Commands
1820

19-
### 后端 (在 `backend/` 目录下执行)
21+
### Backend (run from `backend/`)
2022
```bash
21-
# 开发
22-
python dev.py # 启动开发服务器 (:5555)
23-
ruff format . && ruff check . # 格式化 + 代码检查
24-
ruff check . --fix # 自动修复 lint 问题
25-
alembic revision --autogenerate -m "描述" # 生成数据库迁移
26-
alembic upgrade head # 执行所有迁移
27-
28-
# 测试
29-
python -m pytest # 运行所有后端测试
30-
python -m pytest tests/test_x.py -v # 运行单个测试文件
31-
python -m pytest tests/test_x.py::test_func -v # 运行单个测试函数
32-
python -m pytest -k "关键字" # 按关键字过滤测试
23+
python dev.py # Start dev server (:5555)
24+
ruff format . && ruff check . # Format + lint
25+
ruff check . --fix # Auto-fix lint issues
26+
alembic revision --autogenerate -m "desc" # Generate migration
27+
alembic upgrade head # Run all migrations
28+
29+
# Testing
30+
python -m pytest # All tests
31+
python -m pytest tests/test_books.py -v # Single file
32+
python -m pytest tests/test_books.py::test_list -v # Single function
33+
python -m pytest -k "keyword" # Filter by keyword
34+
python -m pytest --tb=short # Short traceback
3335
```
3436

35-
### 前端 (在 `frontend/` 目录下执行)
37+
### Frontend (run from `frontend/`)
3638
```bash
37-
# 开发
38-
pnpm run dev # 启动开发服务器 (:5173)
39-
pnpm run format # Prettier 格式化代码
40-
pnpm run lint # 运行 Oxlint + ESLint 检查
41-
pnpm run type-check # 运行 TypeScript 类型检查
42-
pnpm run build # 完整构建 (类型检查 + 编译)
43-
pnpm run build-only # 仅构建 (跳过类型检查)
44-
45-
# 测试
46-
pnpm run test:unit # 运行 Vitest 单元测试
47-
npx playwright test # 运行 Playwright E2E 测试
48-
npx playwright test --headed # 可视化模式运行 E2E 测试
49-
npx playwright test --debug # 调试 E2E 测试
39+
pnpm run dev # Start dev server (:5173)
40+
pnpm run format # Prettier format
41+
pnpm run lint # Oxlint + ESLint check
42+
pnpm run type-check # TypeScript type-check (vue-tsc)
43+
pnpm run build # Full build (type-check + compile)
44+
pnpm run build-only # Build only (skip type-check)
45+
46+
# Testing
47+
pnpm run test:unit # Vitest unit tests
48+
npx playwright test # Playwright E2E
49+
npx playwright test --headed # E2E with browser UI
50+
npx playwright test --debug # Debug E2E
5051
```
5152

52-
## 架构概览
53+
## Architecture
5354
```
54-
├── backend/ # FastAPI 后端
55-
│ ├── app/
56-
│ │ ├── api/v1/ # API 端点 (auth, books, blog, messages, weread, rss, admin, aiagent, todos 等)
57-
│ │ ├── models/ # 数据库模型 (SQLAlchemy 2.0 + MongoDB Beanie)
58-
│ │ ├── schemas/ # Pydantic 请求/响应 schema (按领域拆分的独立模块)
59-
│ │ ├── repositories/ # 数据访问层
60-
│ │ ├── services/ # 业务逻辑层
61-
│ │ ├── core/ # 核心配置、日志、AI Agent
62-
│ │ ├── utils/ # 工具函数
63-
│ │ ├── tasks/ # Taskiq 异步任务
64-
│ │ └── main.py # FastAPI 应用入口
65-
│ ├── alembic/ # 数据库迁移
66-
│ └── ruff.toml # Ruff 配置
67-
├── frontend/ # Vue 3 + TypeScript 前端
68-
│ └── src/
69-
│ ├── views/ # 页面组件
70-
│ ├── components/ # 可复用 Vue 组件
71-
│ ├── stores/ # Pinia 状态管理
72-
│ ├── router/ # Vue Router 配置
73-
│ ├── types/ # TypeScript 类型定义
74-
│ ├── lib/ # 第三方库封装
75-
│ ├── utils/ # 工具函数
76-
│ └── layouts/ # 布局组件
77-
├── tests/ # Pytest 后端测试 + Playwright E2E 测试
78-
└── scripts/ # 工具脚本
55+
backend/app/
56+
├── api/v1/ # API endpoints (auth, books, blog, messages, weread, rss, admin, ai, todos, monitor)
57+
├── models/ # SQLAlchemy 2.0 (models.py) + MongoDB Beanie (beanie.py)
58+
├── schemas/ # Pydantic schemas (per-domain: auth, book, blog, rss, etc.)
59+
├── repositories/ # Data access layer
60+
├── services/ # Business logic
61+
├── core/ # Config, logging, AI agent
62+
├── utils/ # Utility functions
63+
├── tasks/ # Taskiq async tasks
64+
└── main.py # FastAPI entry point
65+
66+
frontend/src/
67+
├── views/ # Page components (auth, blog, rss, books, general)
68+
├── components/ # Reusable Vue components (ui/, bento/, basic/, icons/, editor/)
69+
├── stores/ # Pinia state management
70+
├── router/ # Vue Router config
71+
├── types/ # TypeScript type definitions
72+
├── lib/ # Third-party library wrappers
73+
├── utils/ # Utility functions
74+
├── layouts/ # Layout components
75+
└── assets/ # Static assets
7976
```
8077

81-
## 技术栈
82-
- **后端**: FastAPI, SQLAlchemy 2.0, Alembic, PostgreSQL, MongoDB (Beanie), Redis, Taskiq
83-
- **前端**: Vue 3.5, TypeScript, Vite, Tailwind CSS v4, Pinia, shadcn-vue
84-
- **AI**: Agno (替代 Langchain)
85-
- **端口**: 后端 `:5555`,前端 `:5173`
86-
87-
## 代码规范
88-
89-
### 后端 (Python)
90-
- Ruff 配置 (`ruff.toml`):行宽 79 字符,4 空格缩进,双引号,Python 3.14 目标
91-
- 类型注解:使用 Python 3.14+ 现代语法 (`list[str]` 而非 `List[str]`)
92-
- 命名:函数/变量用 `snake_case`,类用 `PascalCase`,常量用 `UPPER_SNAKE_CASE`
93-
- 禁止空 `except:` 块,必须指定异常类型
94-
- 所有公共函数/类需要 Google 风格 docstring
95-
- 数据库操作使用 async 驱动 + `async/await`
96-
- import 排序:标准库 → 第三方 → 本地 (isort)
97-
- 禁止相对导入,使用 `from app.xxx import ...` 绝对路径
98-
- Schema 按领域拆分到 `app/schemas/` 下独立文件 (auth, book, blog, rss 等)
99-
100-
### 前端 (Vue/TypeScript)
101-
- 使用 `<script setup lang="ts">` + Composition API (禁止使用 Options API)
102-
- 严格 TypeScript:避免 `any`,使用 `unknown` + 类型守卫
103-
- 命名:函数/变量用 `camelCase`,组件/类型用 `PascalCase`
104-
- 组件文件用 `PascalCase.vue`,工具文件用 `camelCase.ts`
105-
- 优先使用 Tailwind CSS 工具类,避免自定义 CSS
106-
- 路径使用 `@/` 别名指向 `frontend/src/` 目录
107-
- 包管理器使用 `pnpm`,不要使用 `npm`
108-
109-
### 数据库
110-
- SQLAlchemy 模型:`backend/app/models/models.py`
111-
- MongoDB Beanie 模型:`backend/app/models/beanie.py`
112-
- Pydantic Schema:`backend/app/schemas/` (按领域拆分的独立模块)
113-
- 迁移文件:`backend/alembic/versions/`
114-
115-
## 提交规范
116-
1. 后端提交前:`cd backend && ruff format . && ruff check .`
117-
2. 前端提交前:`cd frontend && pnpm format && pnpm lint && pnpm type-check`
118-
3. 提交信息遵循 Conventional Commits 格式:`feat:`, `fix:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, `chore:`
119-
4. 分支命名:`feature/xxx`, `fix/xxx`, `refactor/xxx`
120-
5. 禁止提交:`.env`, `node_modules/`, `.venv/`, `__pycache__/`, 临时文件
78+
## Tech Stack
79+
- **Backend**: FastAPI, SQLAlchemy 2.0, Alembic, PostgreSQL, MongoDB (Beanie), Redis, Taskiq
80+
- **Frontend**: Vue 3.5, TypeScript, Vite, Tailwind CSS v4, Pinia, shadcn-vue, motion-v
81+
- **AI**: Agno
82+
- **Ports**: Backend `:5555`, Frontend `:5173`
83+
84+
## Code Style
85+
86+
### Backend (Python)
87+
- Ruff config (`ruff.toml`): 79 char line width, 4-space indent, double quotes, Python 3.14 target
88+
- Type annotations: modern Python 3.14+ syntax (`list[str]` not `List[str]`)
89+
- Naming: `snake_case` for functions/variables, `PascalCase` for classes, `UPPER_SNAKE_CASE` for constants
90+
- No bare `except:` — always specify exception type
91+
- Google-style docstrings for all public functions/classes
92+
- Use `async/await` for all database operations
93+
- Import order: stdlib → third-party → local (isort)
94+
- Absolute imports only: `from app.xxx import ...`
95+
- Schemas split by domain in `app/schemas/` (auth, book, blog, rss, etc.)
96+
97+
### Frontend (Vue/TypeScript)
98+
- Always use `<script setup lang="ts">` + Composition API (no Options API)
99+
- Strict TypeScript: avoid `any`, use `unknown` + type guards
100+
- Naming: `camelCase` for functions/variables, `PascalCase` for components/types
101+
- Component files: `PascalCase.vue`, utility files: `camelCase.ts`
102+
- Prefer Tailwind CSS utilities over custom CSS
103+
- Use `@/` alias for imports from `frontend/src/`
104+
- Package manager: `pnpm` only, never `npm`
105+
106+
### Error Handling
107+
- Backend: raise custom exceptions in services, catch in API layer with proper HTTP status codes
108+
- Frontend: use try/catch in async handlers, show user-friendly messages via notification store
109+
- Never swallow errors silently — always log or notify
110+
111+
## Commit Guidelines
112+
1. Backend pre-commit: `cd backend && ruff format . && ruff check .`
113+
2. Frontend pre-commit: `cd frontend && pnpm format && pnpm lint && pnpm type-check`
114+
3. Commit messages: Conventional Commits (`feat:`, `fix:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, `chore:`)
115+
4. Branch naming: `feature/xxx`, `fix/xxx`, `refactor/xxx`
116+
5. Never commit: `.env`, `node_modules/`, `.venv/`, `__pycache__/`, temp files

README.md

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
## 技术栈
3030

3131
- **后端**: FastAPI + SQLAlchemy 2.0 + Alembic + PostgreSQL + MongoDB (Beanie) + Redis
32-
- **前端**: Vue 3.5 + TypeScript + Vite + Tailwind CSS v4 + Pinia + shadcn-vue
32+
- **前端**: Vue 3.5 + TypeScript + Vite + Tailwind CSS v4 + Pinia + shadcn-vue + motion-v
3333
- **AI**: Agno (Langchain 替代方案)
3434
- **安全**: JWT 认证、CSRF 保护、输入验证
3535

@@ -60,29 +60,30 @@ cd ../frontend && pnpm install && pnpm run dev # 前端 :5173
6060

6161
```bash
6262
cd backend
63+
python dev.py # 启动 (:5555)
6364
ruff format . && ruff check . # 格式化 + 检查
6465
ruff check . --fix # 自动修复
6566
alembic revision --autogenerate -m "x" # 生成迁移
6667
alembic upgrade head # 执行迁移
67-
python dev.py # 启动 (:5555)
6868

6969
# 测试
70-
python -m pytest # 运行所有测试
71-
python -m pytest tests/test_x.py -v # 运行单个测试文件
72-
python -m pytest tests/test_x.py::test_func -v # 运行单个测试函数
73-
python -m pytest -k "keyword" # 按关键字过滤测试
70+
python -m pytest # 运行所有测试
71+
python -m pytest tests/test_books.py -v # 单个测试文件
72+
python -m pytest tests/test_books.py::test_list -v # 单个测试函数
73+
python -m pytest -k "keyword" # 按关键字过滤
74+
python -m pytest --tb=short # 简短 traceback
7475
```
7576

7677
### 前端
7778

7879
```bash
7980
cd frontend
8081
pnpm run dev # 启动 (:5173)
81-
pnpm run build # 构建 (先 type-check 再 build)
82-
pnpm run build-only # 仅构建 (跳过 type-check)
8382
pnpm run format # Prettier 格式化
8483
pnpm run lint # Oxlint + ESLint 检查
85-
pnpm run type-check # Vue-tsc 类型检查
84+
pnpm run type-check # TypeScript 类型检查
85+
pnpm run build # 完整构建 (type-check + compile)
86+
pnpm run build-only # 仅构建 (跳过 type-check)
8687

8788
# 测试
8889
pnpm run test:unit # Vitest 单元测试
@@ -94,46 +95,47 @@ npx playwright test --debug # 调试模式
9495
## 项目结构
9596

9697
```
97-
backend/
98-
├── app/
99-
│ ├── routers/ # API: auth, books, blog, users, messages, weread, rss, admin, aiagent
100-
│ ├── models/ # SQLAlchemy 2.0 (models.py) + MongoDB (mgmodel.py)
101-
│ ├── schemas/ # Pydantic schemas
102-
│ ├── dependencies/ # FastAPI 依赖注入
103-
│ ├── middleware/ # 中间件
104-
│ ├── configs/ # 配置 (settings, logger)
105-
│ ├── utils/ # 工具函数
106-
│ └── tasks/ # Taskiq 异步任务
107-
├── alembic/ # 数据库迁移
108-
└── dev.py # 入口 (:5555)
98+
backend/app/
99+
├── api/v1/ # API 端点 (auth, books, blog, messages, weread, rss, admin, ai, todos, monitor)
100+
├── models/ # 数据库模型 (SQLAlchemy 2.0 + MongoDB Beanie)
101+
├── schemas/ # Pydantic schemas (按领域拆分)
102+
├── repositories/ # 数据访问层
103+
├── services/ # 业务逻辑层
104+
├── core/ # 配置、日志、AI Agent
105+
├── utils/ # 工具函数
106+
├── tasks/ # Taskiq 异步任务
107+
└── main.py # FastAPI 入口
109108
110109
frontend/src/
111-
├── views/ # 页面 (auth, books, blog, rss, general)
112-
├── components/ # Vue 组件
113-
├── stores/ # Pinia 状态管理
114-
├── router/ # Vue Router
115-
├── types/ # TypeScript 类型定义
116-
├── lib/ # 库封装
117-
├── utils/ # 工具函数
118-
└── layouts/ # 布局组件
119-
120-
tests/ # Pytest (后端) + Playwright (E2E)
121-
scripts/ # 工具脚本
110+
├── views/ # 页面组件 (auth, blog, rss, books, general)
111+
├── components/ # 可复用组件 (ui/, bento/, basic/, icons/, editor/)
112+
├── stores/ # Pinia 状态管理
113+
├── router/ # Vue Router
114+
├── types/ # TypeScript 类型定义
115+
├── lib/ # 第三方库封装
116+
├── utils/ # 工具函数
117+
├── layouts/ # 布局组件
118+
└── assets/ # 静态资源
119+
120+
tests/ # Pytest (后端) + Playwright (E2E)
121+
scripts/ # 工具脚本
122122
```
123123

124124
## API 端点 (:5555)
125125

126126
| 路由 | 描述 |
127127
| ------------------ | ------------------------- |
128-
| `/api/v1/auth` | 认证 (登录/注册/登出) |
128+
| `/api/v1/auth` | 认证 (登录/注册/Passkey/OAuth) |
129129
| `/api/v1/books` | 书籍管理 (CRUD、阅读进度) |
130130
| `/api/v1/users` | 用户资料 (设置、头像) |
131131
| `/api/v1/blog` | 博客系统 (文章/评论/分类) |
132132
| `/api/v1/messages` | 留言板 |
133133
| `/api/v1/weread` | 微信读书导入 |
134134
| `/api/v1/rss` | RSS 订阅器 |
135135
| `/api/v1/admin` | 管理员 (内容审核) |
136-
| `/api/v1/aiagent` | AI 助手 (文章摘要) |
136+
| `/api/v1/ai` | AI 助手 (文章摘要) |
137+
| `/api/v1/todos` | 待办事项 |
138+
| `/api/v1/monitor` | 系统监控 |
137139

138140
## 配置
139141

@@ -148,7 +150,14 @@ REDIS_URL=redis://localhost:6379/0
148150

149151
- **后端**: Ruff (79字符, 4空格, 双引号), Python 3.14+ 类型注解
150152
- **前端**: Prettier + ESLint + Oxlint, Tailwind CSS, `<script setup>`
151-
- **详细规范**: 见 [AGENTS.md](./AGENTS.md)
153+
- **详细规范**: 见 [CLAUDE.md](./CLAUDE.md)
154+
155+
## 提交规范
156+
157+
1. 后端提交前: `cd backend && ruff format . && ruff check .`
158+
2. 前端提交前: `cd frontend && pnpm format && pnpm lint && pnpm type-check`
159+
3. 提交信息: Conventional Commits (`feat:`, `fix:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, `chore:`)
160+
4. 分支命名: `feature/xxx`, `fix/xxx`, `refactor/xxx`
152161

153162
## 部署
154163

backend/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ extract_messages.py
3333
babel.cfg
3434
legacy/
3535
jwt
36-
response_data
36+
response_data
37+
media/

0 commit comments

Comments
 (0)