一个基于 React + FastAPI 的全栈二手交易平台,支持商品发布、收藏、购物车、即时通讯等功能。
shopping/
├── frontend/ # 前端项目 (React + TypeScript + Vite)
├── backend-api/ # 后端项目 (FastAPI + SQLite)
└── .trae/documents/ # 项目文档
- Node.js 18+
- Python 3.9+
git clone <repository-url>
cd shoppingcd backend-api
source venv/bin/activate
./venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload后端服务将运行在: http://localhost:8000
cd frontend
npm install
npm run dev前端服务将运行在: http://localhost:5173
打开浏览器访问: http://localhost:5173
如果你使用的是 Windows,推荐在 PowerShell 中按下面步骤启动:
# 终端 1:启动后端
cd backend-api
python -m venv venv
.\venv\Scripts\Activate.ps1
pip install -r requirements.txt
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload# 终端 2:启动前端
cd frontend
npm install
npm run dev访问地址:
- 🔐 用户注册/登录/登出
- 👤 个人资料管理
- 📝 发布二手商品
- ❤️ 商品收藏/取消收藏
- 🛒 购物车管理
- 💬 即时消息通知
- 🔍 商品搜索与筛选
- 📂 商品分类浏览
- 📷 商品图片上传
- ✏️ 商品编辑/删除
- 📱 响应式瀑布流展示
- 📊 后台管理面板
- 📋 商品审核管理
- 🏷️ 商品分类管理
- 👥 用户管理
- 框架: React 18 + TypeScript
- 构建工具: Vite 5
- UI 组件库: Ant Design 6
- 路由: React Router DOM 7
- 状态管理: React Context
- HTTP 客户端: Axios
- 日期处理: Day.js
- 框架: FastAPI
- 数据库: SQLite + SQLAlchemy ORM
- 认证: JWT + bcrypt
- 数据校验: Pydantic
- 文件上传: Python-multipart
- 使用 TypeScript 进行类型检查
- 组件文件使用 PascalCase 命名
- 使用函数组件 + Hooks
- CSS 使用 Tailwind CSS 类名
- 遵循 RESTful API 设计规范
- 使用 Pydantic 模型进行数据校验
- 数据库操作使用 SQLAlchemy ORM
- 敏感信息使用环境变量管理
cd frontend
npm run build构建产物将生成在 frontend/dist 目录
cd backend-api
source venv/bin/activate
./venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000- Fork 本仓库
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 创建 Pull Request
如有问题或建议,欢迎提交 Issue 或 Pull Request。