Step 1 - Installation & Environment
Install ZCore properly and configure your environment variables securely using the built-in CLI.
In this first step, we will set up the foundation of our project. ZCore is designed to be zero-config out of the box, with automated virtual environment initialization and cryptographically secure secret generation.
Install the Framework
Install ZCore with all its standard dependencies (FastAPI, SQLAlchemy, Pydantic, Questionary, Rich, etc.). The [all] extra ensures you get the complete toolkit.
pip install fastapi-zcore-framework[all]Scaffold the Project with the CLI
Use the zc init command to create a project structure. The CLI will interactively ask for your database preference (SQLite, PostgreSQL, or MySQL) and package manager (uv or pip).
zc init task_manager && cd task_managerThis command automatically:
- Generates a pre-configured
.envfile with a freshly generated 64-characterSECRET_KEY. - Creates
main.py,requirements.txt, and.gitignore. - Initializes an isolated virtual environment (
.venv) and installs project dependencies if selected.
Secret Keys & Environment Management
zc init already populates .env with a cryptographically strong SECRET_KEY. However, if you need to generate a new key or rotate credentials later, run:
zc gensecretTo generate a clean .env.example schema from your Pydantic settings at any time:
zc genenv -o .env.example -fUnderstand the Settings Class
Open main.py. You will see that ZCore imports settings from zcore. This settings object is a SettingsProxy that reads from your .env file using Pydantic V2 Settings.
# main.py (excerpt)
from zcore import settings
# ZCore reads DATABASE_URL, SECRET_KEY, DEBUG, etc., automatically
print(settings.PROJECT_NAME)
print(settings.DATABASE.url)In addition to core connectivity, all framework runtime boundaries are tunable via environment variables with sensible defaults:
# .env (Tunable framework parameters)
PAGINATION_DEFAULT_SIZE=20
PAGINATION_MAX_SIZE=100
SEARCH_MAX_DEPTH=3
AUTH_CACHE_TTL=300
CACHE_DEFAULT_TTL=3600
CACHE_LOCAL_MAXSIZE=1000
CACHE_EVICTION_INTERVAL=60
STREAM_QUEUE_MAXSIZE=100Deep Dive: The settings object is a Proxy. This means importing it at the top of your files is completely safe and doesn't trigger premature initialization of the Dependency Injection container. Values are resolved lazily when accessed.
Excellent! Your environment is now secure and ready. In the next step, we will examine database initialization.