Application

The Vorte class is the entry point for every project. It wraps FastAPI, manages module registration, and provides lifecycle hooks for startup and shutdown orchestration.

Creating an Application

example.py
python
Copied!
1from vorte import Vorte
2
3app = Vorte(
4 auto_load=True,
5 config_path="config/development.yaml",
6)

Constructor Parameters

ParameterTypeDefaultDescription
auto_loadboolFalseAutomatically discover and load all modules
moduleslist[str] | NoneNoneExplicit list of module names to load
excludelist[str] | NoneNoneModule names to skip during auto_load
configdict | NoneNoneInline configuration dictionary
config_pathstr | NoneNonePath to a YAML or JSON config file
titlestr"Vorte App"Application title shown in docs and OpenAPI
versionstr"0.1.0"Application version
debugboolFalseEnable debug mode with verbose logging

Module Loading Strategies

Auto-Load Everything

Set auto_load=True to scan the modules/ directory and register every discovered module.

example.py
python
Copied!
1from vorte import Vorte
2
3app = Vorte(auto_load=True)

Cherry-Pick Modules

Pass an explicit list to load only the modules your service needs. This reduces startup time and memory footprint.

example.py
python
Copied!
1from vorte import Vorte
2
3app = Vorte(
4 modules=["auth", "database", "ai", "cache"],
5 auto_load=False,
6)

Exclude Specific Modules

example.py
python
Copied!
1from vorte import Vorte
2
3app = Vorte(
4 auto_load=True,
5 exclude=["graphql", "queue", "storage"],
6)

Lifecycle Hooks

Vorte provides decorators to register async callbacks that run at application startup and shutdown. Use them to initialize database pools, warm caches, or gracefully close connections.

on_startup

initialize_services.py
python
Copied!
1from vorte import Vorte
2
3app = Vorte(auto_load=True)
4
5@app.on_startup
6async def initialize_services():
7 await db.connect()
8 await cache.warm()
9 print("Services initialized")
10
11@app.on_startup(priority=10)
12async def load_ml_models():
13 await ai.load_model("gpt-4o")
14 print("ML models loaded")

on_shutdown

cleanup_services.py
python
Copied!
1@app.on_shutdown
2async def cleanup_services():
3 await db.disconnect()
4 await cache.flush()
5 print("Services shut down")
6
7@app.on_shutdown(priority=100)
8async def final_log():
9 print("Application stopped")

Hook Priority

Hooks with lower priority numbers execute first. The default priority is 50. Startup hooks run in ascending order; shutdown hooks run in descending order so that the last resource initialized is the first cleaned up.

PriorityTypical Use
1-10Core infrastructure (logging, config validation)
10-30Database and cache connections
30-50AI model loading, external service clients
50-70Default application logic
70-100Health check registration, metrics setup

Built-in Endpoints

Every Vorte application exposes the following endpoints automatically. They can be disabled individually through configuration.

EndpointMethodDescription
/healthGETReturns application health status
/readyGETReturns readiness probe for orchestrators
/liveGETReturns liveness probe for orchestrators
/infoGETReturns version and module information
/metricsGETReturns Prometheus-compatible metrics
/dashboardGETServes the Vorte admin dashboard UI

Disabling Built-in Endpoints

example.py
python
Copied!
1from vorte import Vorte
2
3app = Vorte(
4 auto_load=True,
5 config={
6 "builtins": {
7 "health": True,
8 "ready": True,
9 "live": True,
10 "info": False,
11 "metrics": False,
12 "dashboard": False,
13 }
14 },
15)

Running the Application

terminal
bash
Copied!
1# Development mode with hot reload
2vorte serve --reload
3
4# Production mode with Uvicorn
5vorte serve --workers 4 --host 0.0.0.0 --port 8000
6
7# Programmatically
8if __name__ == "__main__":
9 app.run(host="0.0.0.0", port=8000, workers=4)
Stay in the loop

Get Vorte release notes, module guides, and developer deep-dives. No spam — unsubscribe anytime.