Metadata-Version: 2.4
Name: simple_module_core
Version: 0.0.3
Summary: Module-system primitives for the simple_module framework — ModuleBase, discovery, diagnostics, events
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
Project-URL: Repository, https://github.com/antosubash/simple_module_python
Project-URL: Issues, https://github.com/antosubash/simple_module_python/issues
Project-URL: Changelog, https://github.com/antosubash/simple_module_python/blob/main/CHANGELOG.md
Author-email: Anto Subash <antosubash@live.com>
License-Expression: MIT
License-File: LICENSE
Keywords: fastapi,modular-monolith,module-discovery,plugin-system,simple-module
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: babel>=2.14
Requires-Dist: fastapi>=0.115
Requires-Dist: packaging>=23.0
Requires-Dist: pydantic-settings>=2.0
Requires-Dist: pydantic>=2.0
Requires-Dist: pyee>=12.0
Description-Content-Type: text/markdown

# simple_module_core

Module-system primitives for the [simple_module](https://github.com/antosubash/simple_module_python) framework — a modular-monolith for Python/FastAPI where each feature is a plugin package discovered at boot.

This package defines `ModuleBase`, the `ModuleMeta` descriptor, the `discover_modules()` entry-point loader, topological dependency sorting, event bus primitives, and the diagnostic codes (`SM001`–`SM017`) used by `make doctor`.

## Install

```bash
pip install simple_module_core
```

You usually don't install this directly — it's pulled in by `simple_module_hosting` and every `simple_module_*` module.

## What it provides

- `ModuleBase` — the subclass every module extends to opt into lifecycle hooks.
- `ModuleMeta` — required `meta = ModuleMeta(name=..., depends_on=...)` attribute on each module.
- `discover_modules()` — loads all `[project.entry-points.simple_module]` modules, topologically sorts by `depends_on`.
- Diagnostic registry — `SM001` missing meta, `SM003` orphan page, `SM008` duplicate name, `SM009` framework→plugin coupling violation, and ~ten others.
- Tiny event-bus (`pyee`) for decoupled module-to-module communication.

## Usage

```python
# modules/orders/orders/module.py
from simple_module_core import ModuleBase, ModuleMeta


class OrdersModule(ModuleBase):
    meta = ModuleMeta(name="orders", depends_on=["users"])

    def register_routes(self, api_router, view_router):
        from .endpoints import api, views
        api_router.include_router(api.router)
        view_router.include_router(views.router)
```

And in `pyproject.toml`:

```toml
[project.entry-points.simple_module]
orders = "orders.module:OrdersModule"
```

The host's `discover_modules()` call picks this up automatically at boot.

## Depends on

- `fastapi`, `pydantic`, `pydantic-settings`, `pyee`, `babel`, `packaging`

## License

MIT — see [LICENSE](https://github.com/antosubash/simple_module_python/blob/main/LICENSE).
