Metadata-Version: 2.4
Name: ai4i-core
Version: 1.0.2
Summary: AI4I Core - consolidated utility libraries (exceptions, logging, telemetry, observability, bootstrap, email) for AI4I microservices
Author-email: AI4Inclusion <support@ai4inclusion.org>
License: MIT
Project-URL: Homepage, https://github.com/COSS-India/ai4i-core
Project-URL: Repository, https://github.com/COSS-India/ai4i-core
Project-URL: Issues, https://github.com/COSS-India/ai4i-core/issues
Project-URL: Source, https://github.com/COSS-India/ai4i-core/tree/master/libs/ai4i_core
Keywords: ai4i,fastapi,logging,telemetry,observability,bootstrap,email,exceptions
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Framework :: FastAPI
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Logging
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.104.0
Requires-Dist: starlette>=0.27.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: redis>=5.0.0
Requires-Dist: sqlalchemy[asyncio]>=2.0.0
Requires-Dist: slowapi>=0.1.9
Requires-Dist: aiosmtplib<4.0.0,>=3.0.0
Requires-Dist: jinja2<4.0.0,>=3.1.0
Requires-Dist: python-json-logger>=2.0.7
Requires-Dist: kafka-python>=2.0.2
Requires-Dist: aiokafka>=0.8.0
Requires-Dist: prometheus-client>=0.19.0
Requires-Dist: psutil>=5.9.0
Requires-Dist: PyJWT>=2.8.0
Requires-Dist: tritonclient[http]>=2.40.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: packaging>=21.0
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.20.0
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.41b0
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.20.0
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Dynamic: license-file

# ai4i-core

Consolidated utility libraries for AI4I microservices — a single installable
package providing the cross-cutting concerns (FastAPI bootstrap helpers, logging,
observability, telemetry, exceptions, and email) shared across the AI4I backend
services.

## Installation

```bash
pip install ai4i-core
```

## Subpackages

| Subpackage | Purpose |
| --- | --- |
| `ai4i_core.bootstrap` | FastAPI app-factory helpers: cache, database, Redis, health router, rate limiting, schemas, API versioning |
| `ai4i_core.context` | Shared `contextvars` (trace id, tenant id, user id, endpoint path) read by the logging and telemetry layers |
| `ai4i_core.email` | Provider-agnostic transactional email client (SMTP, console; pluggable providers) |
| `ai4i_core.exceptions` | Shared exception hierarchy, response envelope, and FastAPI exception handlers |
| `ai4i_core.logging` | Structured JSON logging with trace/tenant correlation and request middleware |
| `ai4i_core.observability` | Prometheus metrics collection and ASGI middleware |
| `ai4i_core.telemetry` | OpenTelemetry tracing, W3C context propagation, OpenSearch query clients |

## Usage

```python
from ai4i_core.bootstrap import create_service_app, init_database, init_redis
from ai4i_core.logging import get_logger, RequestMiddleware
from ai4i_core.exceptions import AppError, InsufficientPermissionsError
from ai4i_core.observability import setup_observability, ObservabilityMiddleware
from ai4i_core.telemetry import TraceManager, trace_stage
from ai4i_core.email import EmailClient, EmailMessage
from ai4i_core.context import get_trace_id, get_tenant_id
```

Each subpackage's `__init__.py` (`__all__`) lists its full public surface.

## Requirements

- Python `>= 3.11`

## License

MIT — see [LICENSE](LICENSE).

## Links

- Source: <https://github.com/COSS-India/ai4i-core>
- Issues: <https://github.com/COSS-India/ai4i-core/issues>
