Metadata-Version: 2.4
Name: fastapi-bootstrap
Version: 0.2.5
Summary: 🚀 Easy FastAPI Setup Kit - Production-ready FastAPI boilerplate with logging, error handling, metrics, security headers, and more
Author-email: JunSeok Kim <infend@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/bestend/fastapi_bootstrap
Project-URL: Documentation, https://github.com/bestend/fastapi_bootstrap#readme
Project-URL: Repository, https://github.com/bestend/fastapi_bootstrap.git
Project-URL: Issues, https://github.com/bestend/fastapi_bootstrap/issues
Keywords: fastapi,logging,error-handling,api,web,framework,production,metrics,security,opentelemetry
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Framework :: FastAPI
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.109.0
Requires-Dist: uvicorn>=0.27.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: loguru>=0.7.2
Requires-Dist: opentelemetry-api>=1.22.0
Requires-Dist: PyYAML>=6.0.1
Provides-Extra: auth
Requires-Dist: python-jose[cryptography]>=3.3.0; extra == "auth"
Requires-Dist: httpx>=0.26.0; extra == "auth"
Provides-Extra: metrics
Provides-Extra: all
Requires-Dist: python-jose[cryptography]>=3.3.0; extra == "all"
Requires-Dist: httpx>=0.26.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
Requires-Dist: httpx>=0.26.0; extra == "dev"
Requires-Dist: ruff>=0.2.0; extra == "dev"
Requires-Dist: mypy>=1.8.0; extra == "dev"
Requires-Dist: types-PyYAML>=6.0.12; extra == "dev"
Requires-Dist: python-jose[cryptography]>=3.3.0; extra == "dev"
Dynamic: license-file

# FastAPI Bootstrap

Production-ready FastAPI boilerplate with batteries included.

[한국어](./README.ko.md) | English

## Features

- **📝 Structured Logging** — Loguru-based logging with request tracking and trace IDs
- **🛡️ Exception Handling** — Centralized error handling with consistent responses
- **📊 Prometheus Metrics** — Built-in `/metrics` endpoint with request statistics
- **🔒 Security Headers** — HSTS, CSP, X-Frame-Options middleware
- **🔐 OIDC Authentication** — Optional JWT/JWKS validation
- **⚡️ Type Safety** — Pydantic V2 integration with enhanced BaseModel

## Installation

```bash
pip install fastapi-bootstrap
```

## Quick Start

```python
from fastapi import APIRouter
from fastapi_bootstrap import create_app, LoggingAPIRoute

router = APIRouter(route_class=LoggingAPIRoute)

@router.get("/hello")
async def hello():
    return {"message": "Hello, World!"}

app = create_app([router], title="My API", version="1.0.0")
```

Run with: `uvicorn app:app --reload`

## Core Components

### Application Factory

```python
from fastapi_bootstrap import create_app

app = create_app(
    routers=[router],
    title="My API",
    version="1.0.0"
)
```

### Logging

```python
from fastapi_bootstrap import get_logger, LoggingAPIRoute

logger = get_logger(__name__)
router = APIRouter(route_class=LoggingAPIRoute)

@router.get("/users/{user_id}")
async def get_user(user_id: int):
    logger.info("Fetching user", user_id=user_id)
    return {"user_id": user_id}
```

### Exception Handling

```python
from fastapi_bootstrap.exception import NotFoundException

@router.get("/users/{user_id}")
async def get_user(user_id: int):
    user = db.get(user_id)
    if not user:
        raise NotFoundException(detail="User not found")
    return user
```

Error response:
```json
{
  "error": {
    "code": "NOT_FOUND",
    "message": "User not found"
  }
}
```

### Metrics

```python
from fastapi_bootstrap import MetricsMiddleware, get_metrics_router

app.add_middleware(MetricsMiddleware)
app.include_router(get_metrics_router())  # GET /metrics
```

## Documentation

For advanced features, see [ADVANCED.md](./ADVANCED.md):
- Security Headers Configuration
- Request ID & Timing Middleware
- Max Request Size Limits
- OIDC Authentication Setup
- CORS Configuration
- Health Checks
- Complete Examples

## Examples

See [examples/](./examples/) directory for complete working examples.

## License

MIT License - see [LICENSE](./LICENSE)
