浙江大学学生网络空间安全协会后端服务
现代化、高性能、企业级的Python Web API服务
- Python: 3.8+ (推荐 3.11+)
- 操作系统: Linux/macOS/Windows
- 内存: 最低 2GB,推荐 4GB+
git clone https://github.com/zjucsa/csa-backend.git
cd csa-backendpython -m venv venv
source venv/bin/activate # Linux/macOS
# 或
venv\Scripts\activate # Windowspip install -r requirements.txt创建 .env 文件:
# 数据库配置
DB_PATH=sqlite:///data.sqlite
# 安全配置
CSA_SECRET_KEY=your-secret-key-here
CSA_SECRET_KEY_ADMIN=your-admin-secret-key-here
# 微信配置
WEIXIN_APP_ID=your-weixin-app-id
WEIXIN_APP_SECRET=your-weixin-app-secret
# 钉钉配置
DINGTALK_APPID=your-dingtalk-appid
DINGTALK_APPKEY=your-dingtalk-appkey
DINGTALK_SECRET=your-dingtalk-secret
DINGTALK_ENABLED=true# 运行数据库迁移
alembic upgrade head
# 或直接创建表(开发环境)
python -c "from models import Base, engine; Base.metadata.create_all(bind=engine)"# 开发环境
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# 生产环境
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4- API文档: http://localhost:8000/docs
- ReDoc文档: http://localhost:8000/redoc
- 健康检查: http://localhost:8000/health
csa-backend/
├── 📁 models/ # 数据模型
├── 📁 routes/ # API路由
├── 📁 misc/ # 工具模块
├── 📁 test/ # 测试文件
├── 📁 uploads/ # 文件上传目录
├── 📄 main.py # 应用入口
├── 📄 config.py # 配置管理
└── 📄 requirements.txt # 依赖列表
详见仓库Wiki
| 技术 | 版本 | 用途 |
|---|---|---|
| FastAPI | 0.115+ | Web框架 |
| SQLAlchemy | 2.0+ | ORM框架 |
| Pydantic | 2.10+ | 数据验证 |
| Alembic | 1.15+ | 数据库迁移 |
| Uvicorn | 0.34+ | ASGI服务器 |
我们欢迎各种形式的贡献!
- Fork 项目
- 创建功能分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 创建 Pull Request
本项目采用 MIT License 许可证。
Made with ❤️ by ZJU CSA Team