feat: initial MVP - FastAPI backend + Vue3 frontend + docker-compose

- backend: FastAPI + SQLAlchemy 2.0(async) + asyncpg + Alembic
- 7 API routes: auth/me/articles/sources/bookmarks/subscriptions/admin
- models: User/Source/Article/Bookmark/Subscription/ApiToken
- services: RSS fetcher (feedparser) + Tencent TMT translator with quota + cache + local NLLB fallback
- workers: APScheduler + asyncio pipeline (fetch -> dedupe -> insert -> translate)
- seed scripts: create_user, seed_sources (5 RSS: Reuters/BBC/Al Jazeera/NHK/DW)
- frontend: Vue 3 + Vite + Naive UI + Pinia + vue-router
- pages: Login, Feed (24h), ArticleDetail, Sources, Bookmarks, AdminSources
- deploy: docker-compose (postgres/redis/api/worker/frontend/caddy)
- docs: README, DEPLOY, architecture, acceptance
This commit is contained in:
Mavis
2026-06-07 21:51:01 +08:00
commit 60b062daf2
81 changed files with 5540 additions and 0 deletions

75
README.md Normal file
View File

@@ -0,0 +1,75 @@
# Diary News · 私人新闻汇总系统
> 抓取境外权威源 → 自动翻译 → 网页 + Android 双端展示。
> 跑在一台 30G 香港 VPS 上,自用 + 家人/小圈子。
完整方案见 [`docs/architecture.md`](./docs/architecture.md),部署步骤见 [`DEPLOY.md`](./DEPLOY.md)。
## 仓库结构
```
diary-news/
├── backend/ # FastAPI 后端 + worker + scheduler
│ ├── app/
│ │ ├── api/ # 路由
│ │ ├── core/ # 安全 / 依赖
│ │ ├── models/ # SQLAlchemy 模型
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── services/ # 采集 / 翻译
│ │ ├── workers/ # 抓取 / 翻译 pipeline + APScheduler
│ │ ├── scripts/ # 初始化脚本
│ │ ├── config.py # Pydantic Settings
│ │ ├── database.py # 异步 SQLAlchemy
│ │ └── main.py # FastAPI 入口
│ ├── alembic/ # 迁移
│ ├── Dockerfile
│ └── pyproject.toml
├── frontend/ # Vue 3 + Vite + Naive UI
├── docs/
│ └── architecture.md
├── Caddyfile # 反代
├── docker-compose.yml
├── .env.example
├── DEPLOY.md
└── README.md
```
## 快速开始(本地开发)
```bash
# 1. 准备环境
cp .env.example .env
# 编辑 .env 填入密钥
# 2. 启动
docker compose up -d
# 3. 初始化数据库 + 创建 owner 账号 + 导入 5 个种子源
docker compose exec api alembic upgrade head
docker compose exec api python -m app.scripts.create_user --username owner --password YOUR_PASS
docker compose exec api python -m app.scripts.seed_sources
# 4. 触发一次抓取(看效果)
docker compose exec api python -c "import asyncio; from app.workers.pipeline import run_once; asyncio.run(run_once())"
# 5. 打开
# http://localhost/
```
## 设计原则
- **轻量**:单机 30G 能跑,不堆重型服务
- **可控**:源管理 / 翻译配额 / 抓取调度全部可视化
- **可扩展**:ML 字段已建好(分类/点评/实体),不需改表
- **不反爬对抗**:愿意被 ban IP 就 ban,优先合规
## 当前阶段
**Phase 1 · MVP(本仓库)**
- ✅ 5 个权威 RSS 源采集(Reuters/BBC/Al Jazeera/NHK/DW)
- ✅ 腾讯云 TMT 翻译 + 字符配额监控 + 降级
- ✅ 网页:登录 / 24h 列表 / 详情 / 源管理
- ✅ 凌晨分波次调度
- ⏳ Android(Phase 3)
- ⏳ 智能分类/点评(Phase 4)
- ⏳ PWA 离线 / 推送(Phase 2)