ZCore LogoZCore
Quick learn

Step 3 - Scaffolding Domain Modules

Use the ZCore CLI to generate a structured, decoupled domain module for your tasks.

A core philosophy of ZCore is organizing applications into decoupled, modular domains. Instead of throwing all files into a single routers.py or models.py, we structure them by business capability.

Generate the Domain Module

Run the zc startapp command to scaffold a tasks domain. The --template flag populates all standard layers with working boilerplate code.

zc startapp tasks --template

You can also run zc startapp tasks without flags for an interactive prompt where you can select specific architectural layers to generate.

Examine the 7-Layer Structure

ZCore generates a self-contained directory for your domain:

__init__.py
models.py
schemas.py
repositories.py
services.py
routers.py
plugin.py
test_tasks.py

Separation of Concerns: This structure cleanly decouples:

  • Data Mapping: models.py (SQLAlchemy 2.0)
  • Validation & Projection: schemas.py (Zchema / Pydantic V2)
  • Data Access: repositories.py (BaseRepository)
  • Business Logic: services.py (BaseService)
  • HTTP Endpoints: routers.py (BaseRouter)
  • Lifecycle & Wiring: plugin.py (Plugin)
  • Integration Tests: test_tasks.py (ZTestClient)

Now we have a clean modular domain ready. In the next step, we will define our database model inside tasks/models.py.

On this page