Files
brunoandClaude 1f54225066 feat: 添加数据库初始化文档和配置优化
- 添加完整的数据库初始化文档 (docs/DATABASE_SETUP.md)
- 添加快速开始指南 (docs/QUICK_START.md)
- 更新 requirements.txt 添加缺失的依赖 (requests, python-docx)
- 优化 .gitignore 配置,保留 uploads 目录结构
- 创建 uploads 目录结构 (images/, pdfs/)
- 支持 PostgreSQL 和 SQLite 两种数据库配置

数据库文档包含:
- PostgreSQL 和 SQLite 安装配置指南
- 完整的表结构说明
- 管理员账户初始化步骤
- 数据库迁移说明
- 常见问题排查
- 备份恢复方案

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
2025-11-27 22:18:14 +08:00

2.8 KiB
Raw Permalink Blame History

快速开始指南

5 分钟快速启动学习助手 Pro 系统。

前置条件

  • Python 3.8+
  • Node.js 16+
  • PostgreSQL 14+ (或使用 SQLite)

快速启动步骤

1. 克隆项目

git clone <repository-url>
cd python-template

2. 数据库设置

选项 A: PostgreSQL (推荐)

# macOS
brew install postgresql@14
brew services start postgresql@14
psql -U postgres -c "CREATE DATABASE wordmaster;"

# Linux
sudo apt install postgresql
sudo systemctl start postgresql
sudo -u postgres psql -c "CREATE DATABASE wordmaster;"

选项 B: SQLite (简单) 无需额外安装,使用文件数据库。

3. 配置环境变量

# 创建 .env 文件
cat > .env << 'EOF'
# PostgreSQL
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/wordmaster

# 或 SQLite
# DATABASE_URL=sqlite:///./wordmaster.db

SECRET_KEY=your-secret-key-change-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
EOF

4. 安装后端依赖

cd backend
python3 -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

5. 初始化数据库

# 创建表和管理员账户
python3 create_admin.py

默认管理员账户:

  • 用户名: admin
  • 密码: admin

6. 安装前端依赖

cd ../frontend
npm install

7. 启动系统

cd ..
./start.sh

系统将自动启动:

验证安装

打开浏览器访问 http://localhost:3008,使用管理员账户登录:

  • 用户名: admin
  • 密码: admin

常用命令

# 启动系统
./start.sh

# 停止系统
./stop.sh

# 查看状态
./status.sh

# 查看日志
tail -f backend/backend.log
tail -f frontend/frontend.log

目录结构

python-template/
├── backend/           # FastAPI 后端
│   ├── main.py       # 主应用文件
│   ├── requirements.txt
│   ├── create_admin.py
│   └── venv/         # Python 虚拟环境
├── frontend/         # Vue 3 前端
│   ├── src/
│   └── package.json
├── docs/             # 文档
│   ├── DATABASE_SETUP.md    # 数据库详细配置
│   └── QUICK_START.md       # 本文件
├── .env              # 环境变量配置
├── start.sh          # 启动脚本
├── stop.sh           # 停止脚本
└── status.sh         # 状态检查脚本

下一步

遇到问题?

参考 DATABASE_SETUP.md 的"常见问题"章节。