Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions QUICK_START.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
**访问地址:**
- 后端 API: http://localhost:8000
- API 文档: http://localhost:8000/docs
- 前端界面: http://localhost:3000
- 前端界面: http://localhost:5173
- 健康检查: http://localhost:8000/health

### 2. 仅启动后端 (`./start.sh backend`)
Expand Down Expand Up @@ -118,7 +118,7 @@ LINKEDIN_PASSWORD=your-linkedin-password
```bash
# 查看端口占用
lsof -i :8000
lsof -i :3000
lsof -i :5173

# 停止占用进程
./start.sh stop
Expand All @@ -128,7 +128,7 @@ LINKEDIN_PASSWORD=your-linkedin-password
```bash
# 清理并重新安装
uv sync --reinstall
cd frontend && npm install
cd frontend-vue && npm install
```

3. **环境变量问题**
Expand Down Expand Up @@ -170,7 +170,7 @@ docker-compose logs -f inspector
curl http://localhost:8000/health

# 测试前端访问
curl http://localhost:3000
curl http://localhost:5173
```

## 📚 下一步
Expand Down
63 changes: 41 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ EMAIL_RECIPIENTS=recipient1@example.com,recipient2@example.com
uv sync

# 安装前端依赖
cd frontend
cd frontend-vue
npm install
cd ..
```
Expand All @@ -127,20 +127,24 @@ cd ..

```bash
# 方式1: 使用启动脚本
chmod +x start-all.sh
./start-all.sh
chmod +x start.sh
./start.sh dev

# 方式2: 手动启动
# 终端1 - 启动后端
# 方式2: 统一入口启动 (后端 + 前端)
uv run python main.py

# 终端2 - 启动前端
cd frontend && npm start
# 默认启用热重载,可通过设置 `INSPECTOR_RELOAD=0` 关闭

# 可选:仅启动后端
uv run python main.py --backend-only

# 可选:仅启动前端
uv run python main.py --frontend-only
```

### 5. 访问应用

- **前端界面**: http://localhost:3000
- **前端界面**: http://localhost:5173
- **API文档**: http://localhost:8000/docs
- **健康检查**: http://localhost:8000/health

Expand All @@ -159,21 +163,37 @@ uv run python tests/validate_config.py --skip-api
# 跳过外部服务和API端点测试
uv run python tests/validate_config.py --skip-external --skip-api

# 测试AI配置
uv run python tests/test_openai_config.py
# 测试数据库健康检查
uv run python tests/test_db_health.py

# 测试阿里云通义千问配置
uv run python tests/test_aliyun_openai.py
# 测试API端点
uv run python tests/test_api_endpoints.py

# 测试GitHub配置
uv run python tests/test_github_token.py
# 测试API集成
uv run python tests/test_api_integration.py
```

## 🧭 前端 Vue3 版本说明

项目使用 `frontend-vue` 目录(**Vue3 + NaiveUI**)作为唯一前端实现,默认端口为 `5173`。

```bash
cd frontend-vue
npm install
npm run dev
```

## 🔍 监控快速接入

提供 `quick-start` 接口以简化接入流程,详细说明见文档:

- `docs/MONITORING_QUICKSTART.md`

## 📖 使用指南

### 添加团队成员

1. 访问 http://localhost:3000/members
1. 访问 http://localhost:5173/members
2. 点击"添加成员"按钮
3. 填写成员信息(姓名、邮箱、职位)
4. 保存成员信息
Expand All @@ -188,7 +208,7 @@ uv run python tests/test_github_token.py

### 运行监控

1. 访问 http://localhost:3000
1. 访问 http://localhost:5173
2. 点击"运行监控"按钮
3. 系统将自动抓取所有配置的社交动态
4. 查看实时更新的活动列表
Expand Down Expand Up @@ -337,13 +357,12 @@ Inspector/
│ │ └── monitor_manager.py
│ └── summarizers/ # 总结器
│ └── llm_summarizer.py
├── frontend/ # 前端应用
├── frontend-vue/ # 前端应用 (Vue3 + NaiveUI)
│ ├── src/
│ │ ├── components/ # React组件
│ │ ├── components/ # 通用组件
│ │ ├── pages/ # 页面组件
│ │ ├── services/ # API服务
│ │ └── types/ # TypeScript类型
│ ├── public/ # 静态资源
│ │ ├── router/ # 路由配置
│ │ └── styles/ # 样式文件
│ └── package.json
├── main.py # 应用入口
├── pyproject.toml # Python配置
Expand Down Expand Up @@ -392,7 +411,7 @@ WEEKLY_SUMMARY_DAY=monday
uv run pytest

# 运行前端测试
cd frontend && npm test
cd frontend-vue && npm run build
```

## 🐛 故障排除
Expand Down
4 changes: 2 additions & 2 deletions app/api/v1/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def export_activities_csv(
activity.content or "",
activity.url or "",
activity.created_at.isoformat() if activity.created_at else "",
activity.created_at.isoformat() if activity.created_at else "" # Activity没有updated_at字段
"" # Activity没有updated_at字段
])

output.seek(0)
Expand Down Expand Up @@ -175,7 +175,7 @@ def export_activities_excel(
"Content": activity.content or "",
"URL": activity.url or "",
"Created At": activity.created_at.isoformat() if activity.created_at else "",
"Updated At": activity.created_at.isoformat() if activity.created_at else "" # Activity没有updated_at字段
"Updated At": "" # Activity没有updated_at字段
})

# Create DataFrame and Excel file
Expand Down
77 changes: 74 additions & 3 deletions app/api/v1/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
from fastapi.responses import StreamingResponse
from sqlalchemy.orm import Session
from app.core.database.database import get_db
from app.models.member import Member, Activity, Summary
from app.models.schemas import Activity as ActivitySchema, Summary as SummarySchema, DashboardStats, MonitoringResult, Member as MemberSchema
from app.models.member import Member, Activity, Summary, SocialProfile
from app.models.schemas import (
Activity as ActivitySchema,
Summary as SummarySchema,
DashboardStats,
MonitoringResult,
Member as MemberSchema,
MonitoringQuickStartRequest,
MonitoringQuickStartResponse,
SocialProfile as SocialProfileSchema
)
from app.services.monitors.monitor_manager import MonitorManager
from app.services.summarizers.llm_summarizer import LLMSummarizer
import json
Expand Down Expand Up @@ -68,6 +77,68 @@ async def run_monitoring(
)


@router.post("/quick-start", response_model=MonitoringQuickStartResponse, status_code=status.HTTP_201_CREATED)
async def quick_start_monitoring(
payload: MonitoringQuickStartRequest,
db: Session = Depends(get_db)
):
"""Create a member profile and trigger monitoring in one request."""
existing_member = db.query(Member).filter(Member.email == payload.email).first()
if existing_member:
member = existing_member
else:
member = Member(
name=payload.name,
email=payload.email,
position=payload.position,
department=payload.department
)
db.add(member)
db.commit()
db.refresh(member)

existing_profile = db.query(SocialProfile).filter(
SocialProfile.member_id == member.id,
SocialProfile.platform == payload.platform
).first()
if existing_profile:
profile = existing_profile
else:
profile = SocialProfile(
member_id=member.id,
platform=payload.platform,
profile_url=str(payload.profile_url),
username=payload.username
)
db.add(profile)
db.commit()
db.refresh(profile)
Comment on lines +113 to +115
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate platform before persisting profile

The quick-start endpoint commits a new SocialProfile before checking whether the requested platform is supported. If a client posts an unsupported platform, the API returns 400 but still leaves a persisted member/profile record that can never be monitored, polluting the database. Validate the platform prior to inserting or roll back on error to avoid creating unusable profiles.

Useful? React with 👍 / 👎.


monitor_manager = MonitorManager(db)
platform_key = payload.platform.lower()
if platform_key not in monitor_manager.monitors:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"Unsupported platform: {payload.platform}"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform validation occurs after database records are committed

Medium Severity

In the quick-start endpoint, the platform validation check happens after the member and social profile have already been committed to the database. If an unsupported platform like "twitter" is provided, the code creates and commits the member (line 97) and profile (line 114), then fails validation at line 119. This leaves orphaned records with invalid platform values in the database since the HTTPException doesn't trigger a rollback.

Additional Locations (2)

Fix in Cursor Fix in Web


monitoring_result = None
if payload.run_monitoring:
activities = await monitor_manager.monitor_specific_profile(profile.id)
activity_payload = [ActivitySchema.from_orm(activity) for activity in activities]
monitoring_result = MonitoringResult(
status="completed",
new_activities=len(activities),
platform_results={profile.platform: activity_payload}
)

return MonitoringQuickStartResponse(
member=MemberSchema.from_orm(member),
profile=SocialProfileSchema.from_orm(profile),
monitoring_result=monitoring_result
)


@router.post("/monitor-profile/{profile_id}", status_code=status.HTTP_200_OK)
async def monitor_specific_profile(
profile_id: int,
Expand Down Expand Up @@ -684,4 +755,4 @@ async def generate_member_summary(
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"Member summary generation failed: {str(e)}"
)
)
19 changes: 18 additions & 1 deletion app/models/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ class MonitoringResult(BaseModel):
platform_results: Optional[dict] = None


class MonitoringQuickStartRequest(BaseModel):
name: str = Field(..., min_length=1, max_length=100)
email: str = Field(..., pattern=r"^[^@]+@[^@]+\.[^@]+$")
position: Optional[str] = Field(None, max_length=100)
department: Optional[str] = Field(None, max_length=100)
platform: str = Field(..., min_length=1, max_length=50)
profile_url: str = Field(..., min_length=1, max_length=500)
username: Optional[str] = Field(None, max_length=100)
run_monitoring: bool = True


class MonitoringQuickStartResponse(BaseModel):
member: Member
profile: SocialProfile
monitoring_result: Optional[MonitoringResult] = None


# Member schemas with relationships
class MemberWithProfiles(Member):
social_profiles: List[SocialProfile] = []
Expand Down Expand Up @@ -147,4 +164,4 @@ class ApiSettings(BaseModel):

class SettingsResponse(BaseModel):
system: SystemSettings
api: ApiSettings
api: ApiSettings
2 changes: 1 addition & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
start_period: 40s

inspector-frontend:
build: ./frontend
build: ./frontend-vue
depends_on:
- inspector
restart: unless-stopped
Expand Down
2 changes: 2 additions & 0 deletions docs/API_ENDPOINT_FIX.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# API 端点修复说明

> ⚠️ 当前前端已迁移至 `frontend-vue`(Vue3 + NaiveUI),以下内容为历史修复记录,仅供参考。

## 🔍 问题描述

前端访问 API 端点时出现 `307 Temporary Redirect` 错误,而不是预期的 `200 OK` 响应。
Expand Down
4 changes: 3 additions & 1 deletion docs/API_FIXES_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# API 修复总结

> ⚠️ 当前前端已迁移至 `frontend-vue`(Vue3 + NaiveUI),以下内容为历史修复记录,仅供参考。

## 问题概述

在项目启动过程中,发现前端调用的一些 API 端点返回 404 错误,主要问题包括:
Expand Down Expand Up @@ -154,7 +156,7 @@ curl http://localhost:8000/api/v1/members/
### ✅ 前端编译成功

```bash
cd frontend && npm run build
cd frontend-vue && npm run build
# 编译成功,只有少量警告(未使用的变量)
```

Expand Down
3 changes: 1 addition & 2 deletions docs/CLEANUP_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@

### 配置文件
- `nginx.conf` - 生产环境 nginx 配置
- `frontend/nginx.conf` - 前端容器 nginx 配置
- `deploy.sh` - 生产部署脚本

## 清理效果
Expand Down Expand Up @@ -164,7 +163,7 @@ uv run python main.py
# 2. 访问服务
# 后端 API: http://localhost:8000
# API 文档: http://localhost:8000/docs
# 前端界面: http://localhost:3000
# 前端界面: http://localhost:5173

# 3. 停止服务
./start.sh stop
Expand Down
4 changes: 3 additions & 1 deletion docs/DASHBOARD_FIX.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Dashboard 数据显示问题修复说明

> ⚠️ 当前前端已迁移至 `frontend-vue`(Vue3 + NaiveUI),以下内容为历史修复记录,仅供参考。

## 🔍 问题描述

用户反映 Dashboard 中看不到成员统计数据和活动统计数据,即使监控已经成功运行并找到了20个新活动。
Expand Down Expand Up @@ -166,7 +168,7 @@ curl -s http://localhost:8000/api/v1/monitoring/stats

5. **重启前端服务**:重新启动开发服务器
```bash
cd frontend && npm start
cd frontend-vue && npm run dev
```

### 如果数据显示为 0
Expand Down
4 changes: 2 additions & 2 deletions docs/DATABASE_RESET_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
```

### 2. 配置成员信息
访问 `http://localhost:3000/members` 或使用 API:
访问 `http://localhost:5173/members` 或使用 API:

```bash
# 创建新成员
Expand Down Expand Up @@ -61,7 +61,7 @@ curl -X POST http://localhost:8000/api/v1/members/1/social-profiles \
```

### 4. 配置监控设置
访问 `http://localhost:3000/settings` 配置:
访问 `http://localhost:5173/settings` 配置:

- **监控间隔**: 设置监控频率
- **OpenAI API**: 配置 AI 总结功能
Expand Down
2 changes: 1 addition & 1 deletion docs/DEPLOYMENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```mermaid
graph TB
A[用户] --> B[nginx:80/443]
B --> C[前端:3000]
B --> C[前端:5173]
B --> D[后端API:8000]
D --> E[PostgreSQL:5432]

Expand Down
Loading