# cb-python **Repository Path**: zhaojianchn/cb-python ## Basic Information - **Project Name**: cb-python - **Description**: 跨境工具箱-后端 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-30 - **Last Updated**: 2025-11-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CB项目后端 CB项目后端API服务,基于FastAPI、MySQL和Redis构建。 ## 技术栈 - FastAPI 0.110.0+ - SQLAlchemy 2.0+ - Redis 7.0+ - MySQL 8.0+ ## 项目结构 ``` app/ ├── api/ # API路由模块 │ ├── deps.py # 依赖项函数 │ └── v1/ # API版本1 ├── core/ # 核心配置 ├── crud/ # CRUD操作函数 ├── db/ # 数据库会话和模型 ├── models/ # SQLAlchemy模型 ├── schemas/ # Pydantic模型 ├── services/ # 业务逻辑服务 ├── tests/ # 测试目录 ├── utils/ # 工具函数 └── main.py # 应用创建和配置 ``` ## 本地开发环境设置 ### 前置条件 - Python 3.8+ - MySQL 8.0+ - Redis 7.0+ ### 安装步骤 1. 克隆项目代码 ```bash git clone https://github.com/your-org/cb.git cd cb/cb-python ``` 2. 创建并激活虚拟环境 ```bash python -m venv venv source venv/bin/activate # Linux/Mac # 或 venv\Scripts\activate # Windows ``` 3. 安装依赖 ```bash pip install -r requirements.txt ``` 4. 创建.env文件 ```bash cp .env.example .env # 然后编辑.env文件,设置数据库和Redis连接信息 ``` 5. 运行数据库迁移 ```bash alembic upgrade head ``` 6. 启动开发服务器 ```bash uvicorn app.main:app --reload ``` 现在可以访问 http://localhost:8000/api/docs 查看API文档。 ## 主要功能 - 用户认证与授权 - 用户管理 - 旋转验证码生成与验证 ## API文档 API文档可通过以下URL访问: - Swagger UI: http://localhost:8000/api/docs - ReDoc: http://localhost:8000/api/redoc ## 测试 运行测试: ```bash pytest ``` ## 部署 项目支持Docker部署,详见Dockerfile和docker-compose.yml文件。 ```bash docker-compose up -d ```