Metadata-Version: 2.4
Name: elric-core
Version: 0.1.0
Summary: Runtime core for the Elric framework: settings, providers, middleware, routing and AI base classes
Project-URL: Homepage, https://github.com/marcoinsabato/elric-framework
Project-URL: Repository, https://github.com/marcoinsabato/elric-framework
Author: Marco Insabato
License-Expression: MIT
Keywords: ai,elric,fastapi,framework,langgraph
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Requires-Dist: asyncpg>=0.31.0
Requires-Dist: fastapi>=0.135.1
Requires-Dist: greenlet>=3.5.2
Requires-Dist: pydantic-settings>=2.14.2
Requires-Dist: redis[asyncio]>=5.0
Requires-Dist: sqlmodel>=0.0.37
Requires-Dist: structlog>=26.1.0
Provides-Extra: ai
Requires-Dist: langchain-anthropic>=0.3; extra == 'ai'
Requires-Dist: langchain>=1.2.12; extra == 'ai'
Requires-Dist: langgraph>=1.2.6; extra == 'ai'
Requires-Dist: langsmith>=0.7.20; extra == 'ai'
Provides-Extra: cohere
Requires-Dist: langchain-cohere>=0.4; extra == 'cohere'
Provides-Extra: google
Requires-Dist: langchain-google-genai>=2.0; extra == 'google'
Provides-Extra: openai
Requires-Dist: langchain-openai>=0.2; extra == 'openai'
Description-Content-Type: text/markdown

# elric-core

Runtime core of the [Elric framework](https://github.com/marcoinsabato/elric-framework).

`elric-core` is a **runtime dependency of every generated Elric project**. It holds
the code the framework owns and keeps upgrading for you: settings, providers,
middleware, route discovery, error handling, and the AI component base classes.

Code that `elric new` copies into your project belongs to you and is never
touched by an upgrade. Anything the framework must be able to change later lives
here instead.

## Installation

You normally get it via the project scaffold:

```bash
uv tool install elric-cli
elric new my_app
```

Standalone:

```bash
uv add elric-core
```

## Usage

```python
# config/settings.py
from functools import lru_cache
from elric_core import ElricSettings


class Settings(ElricSettings):
    """Project settings. Add your own fields here."""


@lru_cache
def get_settings() -> Settings:
    return Settings()
```

```python
# app/__init__.py
from pathlib import Path

from elric_core import create_application
from config.settings import get_settings

ROUTES_DIR = Path(__file__).resolve().parent / "routes"


def create_app():
    return create_application(get_settings(), routes_dir=ROUTES_DIR)
```

`create_application` wires the lifespan (database, Redis, LangSmith), the
middleware stack, the global exception handler, and auto-discovers every module
under `routes_dir` that exposes a module-level `router`.

## What's inside

| Module | Contents |
|---|---|
| `elric_core.config` | `ElricSettings` base class + settings registry |
| `elric_core.logging` | structlog setup, trace-id context |
| `elric_core.providers` | async SQLAlchemy engine, Redis, LangSmith |
| `elric_core.middleware` | API key auth, sliding-window rate limit, request logging |
| `elric_core.routing` | filesystem route auto-discovery |
| `elric_core.exceptions` | exception hierarchy + uniform JSON error handler |
| `elric_core.security` | API key generation, hashing, verification |
| `elric_core.models` | framework SQLModel tables (`ApiKey`) |
| `elric_core.ai` | `BaseAgent`, `BaseChain`, `BaseTool` |

## Schema ownership

`elric-core` never creates tables. Alembic owns the schema — run `elric migrate`.
`init_db()` only verifies connectivity at startup.

## License

MIT
