This release is a pre-release and may not be stable for production use.
A pragmatic and complementary architectural layer built on top of FastAPI.
Standardize your structure, protect your data, and manage atomic transactions—without losing your development freedom.
What is ZCore?
ZCore is not a framework that hides FastAPI — it is the chassis that stabilizes it.
While FastAPI provides a high-performance engine for HTTP, it leaves the architecture of medium-to-large applications entirely to the developer. ZCore fills that gap with:
- 🔐 Context-Aware Data Masking — Write one schema; sensitive fields are automatically pruned per-user across validation, serialization, and OpenAPI specs.
- 🔗 Atomic Unit of Work — Coordinate multi-repository operations into all-or-nothing transactions with deferred event dispatching.
- ⚡ Scoped Dependency Injection — High-performance constructor auto-wiring for Singleton, Transient, and request-scoped dependencies.
- 🏗️ Modular Plugin Architecture — Organize business domains into decoupled plugins with topological dependency ordering.
- 🔍 Secure Dynamic Search Engine — Nested JSON filters, eager loading, cursor/offset pagination, and column-level access controls.
- 📦 Interactive TUI & Scaffolding Engine — Context-aware terminal dashboard, lightning-fast
uvvirtualenv orchestration, and granular layer-by-layer domain generators.
Why ZCore?
| Concern | Raw FastAPI | With ZCore |
|---|---|---|
| Endpoint Scaffolding | Manually write 7+ routes and handlers per model | One BaseRouter class → 7 secure endpoints out-of-the-box |
| Data Leakage | Multiple Pydantic models per role; manual conditionals | Zchema auto-prunes restricted fields per active context |
| Database Transactions | Scattered commit() / rollback() calls |
UnitOfWork guarantees atomicity + post-commit domain events |
| Dependency Wiring | Deeply nested, verbose Depends() parameter chains |
Clean constructor auto-wiring via IoC container + Inject[T] |
| Search & Pagination | Hand-crafted SQL parsing per endpoint | Declarative JSON filters + keyset cursor and offset pagination |
| Project Tooling & Layout | Manual folder creation, fragmented glue scripts | zc interactive TUI with auto uv setup & granular layer picking |
| Startup Orchestration | Fragile @app.on_event chains |
Plugin protocol with dependency DAG → topological sorting |
⚡ Quick Start
1. Install
pip install fastapi-zcore-framework[all]
2. Scaffold
Launch the interactive wizard or run directly:
# Interactive mode (prompts for DB driver, uv/.venv installation, etc.)
zc init my_app && cd my_app
zc startapp tasks
# Or instant non-interactive scaffolding with defaults
zc init my_app -y && cd my_app
zc startapp tasks -y
3. Define
Open tasks/models.py:
import uuid
from zcore import Base
from sqlalchemy.orm import Mapped, mapped_column
class Task(Base):
__tablename__ = "tasks"
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
title: Mapped[str]
is_completed: Mapped[bool] = mapped_column(default=False)
4. Run
zc run
Your API is live at http://127.0.0.1:8000 with 7 secure endpoints (CRUD + Dynamic Search) ready.
📖 Full walkthrough: Quick Start Guide
🏛️ Core Pillars
🔐 Context Shielding (Zchema)
Write a single schema. ZCore dynamically prunes input fields (preventing mass assignment) and output fields (preventing data leakage) based on the active user's permission scopes.
import uuid
from zcore import Zchema
class TaskResponse(Zchema):
__model__ = "tasks"
id: uuid.UUID
title: str
salary: float | None = None # Automatically pruned if unauthorized
When an authenticated user lacks view permissions for tasks.salary, the field vanishes from both JSON serialization and the OpenAPI schema — with zero manual if statements.
🔗 Atomic Transactions (Unit of Work)
Group multiple repository operations into a single atomic unit. Events are buffered and dispatched only after a successful database commit. If any operation fails, the entire transaction rolls back and pending events are discarded.
from zcore import UnitOfWork
async with UnitOfWork(session, dispatcher) as uow:
order = await order_repo.create(order_data)
await inventory_repo.decrement_stock(product_id, quantity)
# Queued safely: Dispatches ONLY after the DB commit succeeds!
uow.register_event("order.completed", {"order_id": str(order.id)})
⚡ Scoped Dependency Injection
Inject services, repositories, and infrastructure dependencies via standard constructor type hints. ZCore's IoC container auto-wires them dynamically and purges request-scoped instances after each response.
from zcore import BaseService
class TaskService(BaseService[Task]):
# Pure Python constructor: Auto-wired by ZCore's DI container
def __init__(self, repository: TaskRepo):
super().__init__(model=Task, repository=repository)
🏗️ Modular Plugin System
Each domain is an isolated Plugin conforming to a strict lifecycle contract. The Kernel resolves dependencies topologically using a Directed Acyclic Graph (DAG) to guarantee deterministic startup and shutdown sequences.
from fastapi import FastAPI
from zcore import Plugin
from .routers import router_instance
class TasksPlugin(Plugin):
name = "tasks"
version = "0.1.0"
dependencies = ["auth"] # Requires AuthPlugin to start first
def setup(self, app: FastAPI) -> None:
app.include_router(router_instance.router)
async def on_startup(self) -> None:
pass
🔍 Secure Dynamic Search Engine
A dynamic query builder that translates nested JSON filters into safe SQLAlchemy 2.0 AST queries — featuring relation eager-loading, keyset cursor pagination, and depth-limit protection against DoS attacks.
{
"filters": [
{
"op": "and",
"items": [
{ "field": "is_completed", "op": "eq", "value": false },
{ "field": "title", "op": "ilike", "value": "urgent" }
]
}
],
"include": ["assignee"],
"sort": [
{ "field": "created_at", "order": "desc" }
],
"page": 1,
"size": 20
}
📦 Interactive TUI & Scaffolding Engine
The zc CLI gives you a rich, interactive Terminal User Interface (TUI) powered by Questionary and Rich. It features:
- Workspace & Context Awareness: Detects whether you are inside an active project, in a root workspace containing multiple services, or starting fresh.
- Automated
uv/.venvSetup: Initializes isolated virtual environments and installs dependencies automatically usinguv(recommended) or standardpip. - Multi-Engine Driver Bootstrapping: Configures SQLite (
aiosqlite), PostgreSQL (asyncpg), or MySQL (aiomysql) in.envandrequirements.txtout-of-the-box. - Granular Architectural Scaffolding: Generates modular domain apps in 3 modes (Full Boilerplate, Clean/Blank, or Custom Layer Selection across Models, Schemas, Repositories, Services, Routers, Plugins, and Pytest suites).
$ zc
⚡ ZCore Framework v0.1.0-rc.1 • Modern Modular Monolith
FastAPI • SQLAlchemy 2.0 • Pydantic V2
? What framework task would you like to perform? 📦 init — Scaffold a new full ZCore project
┌ Initialize New ZCore Project
│
? Project directory name: core_api
? Select primary database driver: PostgreSQL (asyncpg) — Production Ready
? Initialize virtual environment (.venv) and install dependencies? Yes (uv)
│ ✓ Environment & dependencies installed successfully.
└ Project 'core_api' ready!
CLI Command Reference
| Command | Interactive | Non-Interactive Flags | Purpose |
|---|---|---|---|
zc |
✅ | — | Launch interactive orchestration dashboard |
zc init [name] |
✅ | --db [sqlite|postgres|mysql], -y |
Bootstrap a new project with settings, .env, and dependencies |
zc startapp [name] |
✅ | --template / --no-template, --test / --no-test, -y |
Scaffold domain modules with granular layer selection |
zc run |
✅ | — | Launch local Uvicorn dev server with auto-reload |
zc gensecret |
— | — | Generate a 64-character cryptographically secure SECRET_KEY |
zc genenv |
✅ | -o <output>, -f / --force |
Introspect active Settings classes and scaffold .env.example |
📖 Documentation
| Resource | Description |
|---|---|
| 🚀 Quick Start | Build a complete Task Manager API from scratch |
| 📚 10-Step Quick Learn | Deep dive into each architectural layer step-by-step |
| 🔧 How-To Guides | Pagination, search, file uploads, caching, and testing |
| 🏛️ Core Concepts | Deep dive into DI, Kernel, Security, UoW, and Zchema |
| 📜 API Reference | Complete class and method specifications |
| 🕒 Changelog | Release notes, breaking changes, and migrations |
🤝 Contributing
Contributions are welcome! Please read our guidelines before submitting a PR.
- Issues: Bug reports and feature requests via GitHub Issues
- PRs: Open a pull request with a clear description of the change
- Local Setup:
pip install -e ".[all,dev]"and runhatch testto verify
📄 License
ZCore is licensed under the Apache License 2.0.
See LICENSE for details.
Built with ☕ and architectural rigor by Ali Alf Ostovar / Baseryn.
Metadata
Release files for fastapi-zcore-framework 0.1.0rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_zcore_framework-0.1.0rc1.tar.gz | 136.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_zcore_framework-0.1.0rc1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 241.3 kB
Release files / fastapi_zcore_framework-0.1.0rc1.tar.gz
| Download URL | fastapi_zcore_framework-0.1.0rc1.tar.gz |
|---|---|
| Size | 136.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5505d44df55e70b54cd1730ff67e0c40fcc1a704107d324a68c5c558200df20
|
|
BLAKE2b-256 checksum How to use checksums |
87818adc3343a0823a5e003eea15e951886af64b7106f1170ccd28cbe4cbd381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / fastapi_zcore_framework-0.1.0rc1-py3-none-any.whl
| Download URL | fastapi_zcore_framework-0.1.0rc1-py3-none-any.whl |
|---|---|
| Size | 104.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
920c8abb1da27dad1435f6c326cf06981e35e53421c27b597f55107a8ccdb374
|
|
BLAKE2b-256 checksum How to use checksums |
34b40142714fe4e2bd17adf9002148761c5ef9816dd7e92c728327623c2cb279
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency log