tori/app-templates/webapp/INSTRUCTIONS.md
Fam Zheng ee4a5dfc95 App-templates: LLM auto-selects project template based on user requirement
- Add webapp template (FastAPI + SQLite) with INSTRUCTIONS.md and setup.sh
- select_template() scans templates, asks LLM to match; apply_template() copies to workspace
- ensure_workspace() runs setup.sh if present, otherwise falls back to default venv
- INSTRUCTIONS.md injected into planning and execution prompts
- Fix pre-existing clippy warning in kb.rs (filter_map → map)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:33:40 +00:00

32 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 项目模板Web 应用 (FastAPI + SQLite)
## 技术栈
- **后端**Python FastAPI
- **数据库**SQLite通过 aiosqlite 异步访问)
- **前端**:单页 HTML + 原生 JavaScript内嵌在 Python 中或作为静态文件)
- **包管理**uv
## 项目结构约定
```
app.py # FastAPI 主应用(入口)
database.py # 数据库初始化和模型(可选,小项目可放在 app.py
static/ # 静态文件目录(可选)
```
## 关键约定
1. **入口文件**`app.py`FastAPI 应用实例命名为 `app`
2. **启动命令**`uvicorn app:app --host 0.0.0.0 --port $PORT`
3. **数据库**:使用 SQLite数据库文件放在工作区根目录`data.db`
4. **依赖安装**:使用 `uv add <包名>` 安装依赖
5. **前端**:优先使用单文件 HTML通过 FastAPI 的 `HTMLResponse` 返回或放在 `static/` 目录
6. **API 路径**:应用通过反向代理 `/api/projects/{project_id}/app/` 访问,前端 JS 中的 fetch 必须使用相对路径(如 `fetch('items')`,不要用 `fetch('/items')`
## 注意事项
- venv 已在 `.venv/` 中预先创建,直接使用即可
- 不要使用 `pip install`,使用 `uv add` 管理依赖
- SQLite 不需要额外服务,适合单机应用