# 快速开始指南 5 分钟快速启动学习助手 Pro 系统。 ## 前置条件 - Python 3.8+ - Node.js 16+ - PostgreSQL 14+ (或使用 SQLite) ## 快速启动步骤 ### 1. 克隆项目 ```bash git clone cd python-template ``` ### 2. 数据库设置 **选项 A: PostgreSQL (推荐)** ```bash # 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. 配置环境变量 ```bash # 创建 .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. 安装后端依赖 ```bash cd backend python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt ``` ### 5. 初始化数据库 ```bash # 创建表和管理员账户 python3 create_admin.py ``` 默认管理员账户: - 用户名: `admin` - 密码: `admin` ### 6. 安装前端依赖 ```bash cd ../frontend npm install ``` ### 7. 启动系统 ```bash cd .. ./start.sh ``` 系统将自动启动: - 后端服务: http://localhost:8888 - 前端服务: http://localhost:3008 - API 文档: http://localhost:8888/docs ## 验证安装 打开浏览器访问 http://localhost:3008,使用管理员账户登录: - 用户名: `admin` - 密码: `admin` ## 常用命令 ```bash # 启动系统 ./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) 了解详细配置 - 查看 [CLAUDE.md](../CLAUDE.md) 了解项目架构 - 访问 API 文档: http://localhost:8888/docs ## 遇到问题? 参考 [DATABASE_SETUP.md](./DATABASE_SETUP.md) 的"常见问题"章节。