Metadata-Version: 2.4
Name: aury-boot
Version: 0.0.65
Summary: Aury Boot - 基于 FastAPI 生态的企业级 API 开发框架
Requires-Python: >=3.13
Requires-Dist: aiofiles>=23.0.0
Requires-Dist: aiohttp>=3.11.0
Requires-Dist: alembic>=1.17.2
Requires-Dist: aury-sdk-storage[aws]>=0.0.6
Requires-Dist: babel>=2.17.0
Requires-Dist: broadcaster[redis]>=0.3.1
Requires-Dist: faker>=38.2.0
Requires-Dist: fastapi>=0.122.0
Requires-Dist: greenlet>=3.2.4
Requires-Dist: loguru>=0.7.3
Requires-Dist: pydantic-settings>=2.12.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: rich>=14.2.0
Requires-Dist: sqlalchemy>=2.0.44
Requires-Dist: tenacity>=9.1.2
Requires-Dist: typer>=0.20.0
Requires-Dist: uvicorn[standard]>=0.30.0
Provides-Extra: admin
Requires-Dist: itsdangerous>=2.2.0; extra == 'admin'
Requires-Dist: sqladmin>=0.16.0; extra == 'admin'
Provides-Extra: all
Requires-Dist: aiomysql>=0.3.2; extra == 'all'
Requires-Dist: aiosqlite>=0.21.0; extra == 'all'
Requires-Dist: apscheduler>=3.11.1; extra == 'all'
Requires-Dist: asyncpg>=0.31.0; extra == 'all'
Requires-Dist: aury-sdk-storage[aws]>=0.0.1; extra == 'all'
Requires-Dist: dramatiq>=1.18.0; extra == 'all'
Requires-Dist: pika>=1.3.2; extra == 'all'
Requires-Dist: prometheus-fastapi-instrumentator>=7.0.0; extra == 'all'
Requires-Dist: psutil>=7.0.0; extra == 'all'
Requires-Dist: pyroscope-io>=0.8.7; extra == 'all'
Requires-Dist: redis>=7.1.0; extra == 'all'
Provides-Extra: broadcaster
Requires-Dist: broadcaster[redis]>=0.3.1; extra == 'broadcaster'
Provides-Extra: dev
Requires-Dist: httpx>=0.28.1; extra == 'dev'
Requires-Dist: mypy>=1.19.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
Requires-Dist: pytest>=9.0.1; extra == 'dev'
Requires-Dist: ruff>=0.14.7; extra == 'dev'
Provides-Extra: docs
Requires-Dist: materialx>=1.39.0; extra == 'docs'
Requires-Dist: mkdocs-material>=9.7.0; extra == 'docs'
Requires-Dist: mkdocs>=1.6.0; extra == 'docs'
Provides-Extra: metrics
Requires-Dist: prometheus-fastapi-instrumentator>=7.0.0; extra == 'metrics'
Provides-Extra: mysql
Requires-Dist: aiomysql>=0.3.2; extra == 'mysql'
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.40.0; extra == 'otel'
Requires-Dist: opentelemetry-instrumentation-aiohttp-client>=0.61b0; extra == 'otel'
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.61b0; extra == 'otel'
Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.61b0; extra == 'otel'
Requires-Dist: opentelemetry-sdk>=1.40.0; extra == 'otel'
Provides-Extra: otel-exporter
Requires-Dist: opentelemetry-exporter-otlp>=1.40.0; extra == 'otel-exporter'
Provides-Extra: postgres
Requires-Dist: asyncpg>=0.31.0; extra == 'postgres'
Provides-Extra: profiling
Requires-Dist: psutil>=7.0.0; extra == 'profiling'
Requires-Dist: pyroscope-io>=0.8.7; extra == 'profiling'
Provides-Extra: rabbitmq
Requires-Dist: amqp>=5.3.1; extra == 'rabbitmq'
Provides-Extra: recommended
Requires-Dist: aiosqlite>=0.21.0; extra == 'recommended'
Requires-Dist: apscheduler>=3.11.1; extra == 'recommended'
Requires-Dist: asyncpg>=0.31.0; extra == 'recommended'
Requires-Dist: aury-sdk-storage[aws]>=0.0.1; extra == 'recommended'
Requires-Dist: dramatiq>=1.18.0; extra == 'recommended'
Requires-Dist: opentelemetry-api>=1.40.0; extra == 'recommended'
Requires-Dist: opentelemetry-instrumentation-aiohttp-client>=0.61b0; extra == 'recommended'
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.61b0; extra == 'recommended'
Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.61b0; extra == 'recommended'
Requires-Dist: opentelemetry-sdk>=1.40.0; extra == 'recommended'
Requires-Dist: prometheus-fastapi-instrumentator>=7.0.0; extra == 'recommended'
Requires-Dist: redis>=7.1.0; extra == 'recommended'
Provides-Extra: redis
Requires-Dist: redis>=7.1.0; extra == 'redis'
Provides-Extra: s3
Requires-Dist: aury-sdk-storage[aws]>=0.0.1; extra == 's3'
Provides-Extra: scheduler
Requires-Dist: apscheduler>=3.11.1; extra == 'scheduler'
Provides-Extra: sqlite
Requires-Dist: aiosqlite>=0.21.0; extra == 'sqlite'
Provides-Extra: tasks
Requires-Dist: dramatiq>=1.18.0; extra == 'tasks'
Requires-Dist: redis>=7.1.0; extra == 'tasks'
Description-Content-Type: text/markdown

# Aury Boot

基于 FastAPI 生态的企业级 API 开发框架，提供所有微服务共用的基础设施组件。

## 快速开始

```bash
# 1. 创建项目目录并初始化
mkdir my-service && cd my-service
uv init . --name my_service --no-package --python 3.13

# 2. 添加依赖
uv add "aury-boot[recommended,admin]"  # admin 可选，提供 SQLAdmin 管理后台

# 3. 初始化项目结构
aury init

# 4. 启动开发服务器
aury server dev
```

## 功能模块

- **core**: 核心功能（数据库、缓存、任务调度等）
- **utils**: 工具函数（日志、安全、HTTP客户端等）
- **models**: 共享数据模型和响应模型
- **repositories**: 基础仓储模式
- **services**: 基础服务类
- **adapters**: 第三方服务适配器
- **rpc**: RPC通信框架
- **exceptions**: 错误处理系统
- **i18n**: 国际化支持
- **testing**: 测试框架
- **migrations**: 数据库迁移工具

## 主要功能

### 1. 国际化支持 (i18n)

提供完整的多语言支持，包括文本翻译、日期/数字本地化等：

```python
from aury.boot.i18n import Translator, translate, set_locale

# 设置语言环境
set_locale("zh_CN")

# 使用翻译器
translator = Translator(locale="zh_CN")
message = translator.translate("user.created", name="张三")

# 使用简写函数
message = translate("user.created", name="张三")

# 装饰器方式
@_("user.title")
def get_user_title():
    return "User Title"  # 会被翻译
```

### 2. 测试框架

提供便捷的测试工具，包括测试基类、测试客户端、数据工厂等：

```python
from aury.boot.testing import TestCase, TestClient, Factory

class UserServiceTest(TestCase):
    """测试基类，自动处理数据库事务回滚"""
    
    async def setUp(self):
        """测试前准备"""
        self.client = TestClient(app)
        self.user_factory = Factory(User)
    
    async def test_create_user(self):
        """测试创建用户"""
        user = await self.user_factory.create(name="张三")
        response = await self.client.post("/users", json={"name": "张三"})
        assert response.status_code == 201
```

### 3. 数据库迁移工具

提供便捷的数据库迁移管理，类似 Django 的命令行接口：

```python
from aury.boot.migrations import MigrationManager

# 使用 Python API
migration_manager = MigrationManager()
await migration_manager.make_migrations(message="add user table")
await migration_manager.migrate_up()
await migration_manager.migrate_down(version="previous")
status = await migration_manager.status()
```

命令行工具：

```bash
# 生成迁移文件
aury migrate make -m "add user table"

# 执行迁移
aury migrate up

# 回滚迁移
aury migrate down

# 查看状态
aury migrate status

# 显示迁移历史
aury migrate show
```

### 4. 代码生成器

快速生成标准的 CRUD 代码（模型、仓储、服务、API 路由）：

```bash
# 生成完整 CRUD（Model + Repository + Service + API）
aury generate crud user

# 单独生成各层代码
aury generate model user      # SQLAlchemy 模型
aury generate repo user       # Repository 仓储层
aury generate service user    # Service 服务层
aury generate api user        # API 路由

# 交互式生成（推荐）：逐步选择字段、类型、验证规则
aury generate crud user -i
aury generate model user -i

# 指定字段（非交互式）
aury generate model user --fields "name:str,email:str,age:int"
```

**交互式模式 (`-i`)** 会引导你：
- 添加字段名称和类型
- 设置字段约束（唯一、可空、默认值等）
- 配置关系字段（外键、多对多等）
- 自动插入 API 路由到 `api/__init__.py`

生成的代码遵循项目架构模式，开箱即用。

## 使用方式

在AUM工作区内的其他包中，可以直接导入：

```python
from aury.boot.infrastructure.database import DatabaseManager
from aury.boot.infrastructure.logging import logger
from aury.boot.core import BaseModel, BaseRepository, BaseService
from aury.boot.interfaces import BaseRequest, BaseResponse
from aury.boot.application.rpc import RPCClient
```

## 开发指南

修改此包后，所有依赖它的服务都会自动使用最新版本，无需重新安装。

## 安装

```bash
# 推荐（PostgreSQL + Redis + 任务队列 + 调度器）
uv add "aury-boot[recommended]"

# 或按需组合
uv add "aury-boot[postgres,redis]"

# 全部依赖
uv add "aury-boot[all]"
```

### 可选依赖

| 名称 | 说明 |
|------|------|
| `postgres` | PostgreSQL 数据库 |
| `mysql` | MySQL 数据库 |
| `sqlite` | SQLite 数据库 |
| `redis` | Redis 缓存 |
| `s3` | S3 对象存储 |
| `tasks` | 任务队列 |
| `rabbitmq` | RabbitMQ 支持 |
| `scheduler` | 定时调度 |
| `recommended` | 推荐组合 |
| `all` | 全部依赖 |

## 开发环境设置

```bash
# 克隆仓库
git clone https://github.com/AuriMyth/aury-boot.git
cd aury-boot

# 安装依赖
uv sync --group dev

# 运行测试
pytest

# 代码检查
ruff check .
mypy aury/
```




