Files
SatoNano/README.md
2026-01-06 23:49:23 +08:00

121 lines
2.5 KiB
Markdown
Raw 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.

# SatoNano
云服务综合管理平台
## 功能特性
- ✅ 用户注册、登录、退出
- ✅ JWT 令牌认证Access + Refresh Token
- ✅ 密码修改
- ✅ 用户信息管理
- 🔜 邀请码注册
- 🔜 OAuth2 第三方登录
## 技术栈
- **Web 框架**: FastAPI
- **ORM**: SQLAlchemy 2.0 (异步)
- **密码哈希**: Argon2
- **认证**: JWT (PyJWT)
- **数据验证**: Pydantic v2
## 快速开始
### 环境要求
- Python 3.12+
- [uv](https://github.com/astral-sh/uv) (推荐)
### 安装
```bash
# 克隆项目
git clone <repo-url>
cd SatoNano
# 安装依赖
uv sync
# 配置环境变量(可选)
cp .env.example .env
# 编辑 .env 文件设置 SECRET_KEY 等配置
```
### 启动服务
```bash
# 开发模式(自动重载)
uv run python main.py
# 或使用 uvicorn
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
```
### 访问 API
- API 文档: http://localhost:8000/docs
- ReDoc 文档: http://localhost:8000/redoc
- 健康检查: http://localhost:8000/health
## API 接口
| 接口 | 方法 | 描述 |
|------|------|------|
| `/api/v1/auth/register` | POST | 用户注册 |
| `/api/v1/auth/login` | POST | 用户登录 |
| `/api/v1/auth/logout` | POST | 用户退出 |
| `/api/v1/auth/refresh` | POST | 刷新令牌 |
| `/api/v1/auth/change-password` | POST | 修改密码 |
| `/api/v1/users/me` | GET | 获取当前用户 |
| `/api/v1/users/me` | PATCH | 更新用户信息 |
详细文档请查看 [docs/auth-api.md](docs/auth-api.md)
## 项目结构
```
app/
├── api/ # API 路由层
├── core/ # 核心功能(配置、安全、异常)
├── models/ # 数据库模型
├── repositories/ # 数据访问层
├── schemas/ # 数据验证模式
├── services/ # 业务逻辑层
├── database.py # 数据库连接
└── main.py # 应用入口
```
详细架构说明请查看 [docs/architecture.md](docs/architecture.md)
## 开发
```bash
# 安装开发依赖
uv sync --dev
# 代码格式化
uv run ruff format .
# 代码检查
uv run ruff check .
# 运行测试
uv run pytest
```
## 配置说明
支持通过环境变量或 `.env` 文件配置:
| 变量 | 默认值 | 说明 |
|------|--------|------|
| `SECRET_KEY` | - | JWT 签名密钥(生产必改) |
| `DEBUG` | false | 调试模式 |
| `DATABASE_URL` | sqlite+aiosqlite:///./satonano.db | 数据库连接 |
| `ACCESS_TOKEN_EXPIRE_MINUTES` | 30 | 访问令牌有效期 |
| `REFRESH_TOKEN_EXPIRE_DAYS` | 7 | 刷新令牌有效期 |
## License
MIT