Modern Python web framework for building APIs with minimal boilerplate
Project description
Zenith Framework
A modern Python web framework with intuitive developer experience and exceptional performance.
๐ฏ Modern DX: Zero-config setup, database models with chainable queries, one-liner features, and clean architecture patterns - making Python web development incredibly productive.
What is Zenith?
Zenith brings together exceptional productivity, outstanding performance, and full type safety:
- ๐ Zero-config setup -
app = Zenith()just works with intelligent defaults - ๐๏ธ Intuitive models -
User.where(active=True).order_by('-created_at').limit(10) - โก One-liner features -
app.add_auth(),app.add_admin(),app.add_api() - ๐ฏ Enhanced DX - No session management, ZenithModel handles it automatically
- ๐๏ธ Exceptional performance - 9,600+ req/s with full async support
- ๐ก๏ธ Production-ready - Security, monitoring, and middleware built-in
๐ Zero-Config Quick Start
pip install zenithweb
from zenith import Zenith
from zenith import Session # Database session dependency
from zenith.db import ZenithModel # Modern database models
from sqlmodel import Field
from typing import Optional
# ๐ฏ Zero-config setup - just works!
app = Zenith()
# โก Add features in one line each
app.add_auth() # JWT authentication + /auth/login
app.add_admin() # Admin dashboard at /admin
app.add_api("My API", "1.0.0") # API docs at /docs
# ๐๏ธ Modern models with chainable query patterns
class User(ZenithModel, table=True):
id: Optional[int] = Field(primary_key=True)
name: str = Field(max_length=100)
email: str = Field(unique=True)
active: bool = Field(default=True)
# ๐จ Clean routes with enhanced DX
@app.get("/")
async def home():
return {"message": "Modern DX in Python!"}
@app.get("/users")
async def list_users(): # โจ No session management needed!
# Clean chaining: User.where().order_by().limit()
query = await User.where(active=True)
users = await query.order_by('-id').limit(10).all()
return {"users": [user.to_dict() for user in users]}
@app.post("/users")
async def create_user(user_data: dict):
# Clean API: User.create() - no session management!
user = await User.create(**user_data)
return {"user": user.to_dict()}
@app.get("/users/{user_id}")
async def get_user(user_id: int):
# Automatic 404 handling
user = await User.find_or_404(user_id)
return {"user": user.to_dict()}
# ๐โโ๏ธ Run it
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)
Run with:
uvicorn main:app --reload
๐ฏ Modern DX Features
๐ Zero-Config Setup
app = Zenith() # Just works! No complex configuration needed
- Intelligent defaults - Development vs production auto-detection
- Automatic middleware - Security, CORS, logging configured automatically
- Environment-aware - Uses
ZENITH_ENVor sensible detection
๐๏ธ Intuitive Database Models
# Intuitive database operations
users = await User.where(active=True).order_by('-created_at').limit(10).all()
user = await User.find_or_404(123) # Automatic 404 handling
user = await User.create(name="Alice", email="alice@example.com")
- ZenithModel - Modern ORM with chainable queries
- Automatic sessions - No manual database session management
- Type-safe queries - Full async support with SQLModel integration
โก One-Liner Features
app.add_auth() # JWT authentication + /auth/login endpoint
app.add_admin() # Admin dashboard at /admin with health checks
app.add_api() # API documentation at /docs and /redoc
- Instant features - Complex functionality in single lines
- Production-ready - Each feature includes monitoring and security
- Configurable - Sensible defaults with full customization options
๐ฏ Clean Dependency Injection
@app.get("/users")
async def get_users(session: AsyncSession = Session):
# Simple database session injection
users = await User.all() # ZenithModel uses the session automatically
return users
- Simple patterns -
Sessionfor database,Authfor current user - Service injection -
Inject(ServiceClass)for business logic - Type-safe - Full IDE support and autocompletion
๐๏ธ Exceptional Performance
- 9,600+ req/s - Exceptional performance with modern features
- No performance penalty - Zero overhead from convenience features
- Async-first - Full async/await with Python 3.12+ optimizations
- Production tested - 70% middleware retention with full feature stack
๐ก๏ธ Production-Ready
- Security by default - CSRF, CORS, security headers automatic
- Built-in monitoring -
/health,/metrics, request tracing - Error handling - Structured errors with proper HTTP status codes
- Testing framework - Comprehensive testing utilities included
๐ Full-Stack Support
- Serve SPAs (React, Vue, SolidJS) with
app.spa("dist") - WebSocket support with connection management
- Static file serving with caching
- Database integration with async SQLAlchemy
๐ Project Structure
Clean organization with zero configuration:
your-app/
โโโ main.py # app = Zenith() + routes
โโโ models.py # ZenithModel classes
โโโ services.py # Business logic (optional)
โโโ migrations/ # Database migrations (auto-generated)
โโโ tests/ # Testing with built-in TestClient
Or traditional clean architecture:
your-app/
โโโ main.py # Application entry point
โโโ models/ # ZenithModel classes
โโโ services/ # Service classes with @Service decorator
โโโ routes/ # Route modules (optional)
โโโ middleware/ # Custom middleware
โโโ tests/ # Comprehensive test suite
Performance
Verified Benchmark Results:
- Simple endpoints: 9,557 req/s
- JSON endpoints: 9,602 req/s
- With full middleware: 6,694 req/s (70% retention)
Run your own benchmarks:
python scripts/run_performance_tests.py --quick
Performance varies by hardware and application complexity.
Documentation
- Quick Start Guide - Get up and running in 5 minutes
- API Reference - Complete API documentation
- Architecture Guide - Framework design patterns
- Examples - Real-world usage examples
- Contributing - Development guidelines
๐ Examples
๐ฅ Modern DX Examples:
- Modern Developer Experience - Complete modern patterns showcase
- One-Liner Features - Convenience methods demonstration
- One-liner Features -
app.add_auth(),app.add_admin(),app.add_api() - Zero-config Setup - Automatic environment detection
๐ Complete Examples:
- Hello World - Simple setup (
app = Zenith()) - Basic API - Routing and validation
- Authentication - JWT authentication
- WebSocket Chat - Real-time communication
- Background Jobs - Task processing
- Security Middleware - Production security
CLI Tools
# Create new project with secure defaults
zen new my-api
# Generate secure SECRET_KEY
zen keygen
# Development server with hot reload
zen dev
# Production server
zen serve --workers 4
Installation
# Basic installation
pip install zenithweb
# With production dependencies
pip install "zenithweb[production]"
# With development tools
pip install "zenithweb[dev]"
Production Deployment
Docker
FROM python:3.12-slim
WORKDIR /app
COPY . .
RUN pip install "zenithweb[production]"
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Environment Configuration
from zenith import Zenith
app = Zenith()
# Environment-specific behavior:
# development (or dev): Enhanced error reporting, auto-generated secrets
# production (or prod): Optimized for deployment, requires SECRET_KEY
# test: Testing mode with rate limiting disabled
# staging: Production-like with enhanced monitoring
# Manual configuration if needed
from zenith.config import Config
app = Zenith(
config=Config(
database_url=os.getenv("DATABASE_URL"),
redis_url=os.getenv("REDIS_URL"),
secret_key=os.getenv("SECRET_KEY")
# debug automatically set based on ZENITH_ENV
)
)
Contributing
We welcome contributions! Please see our Contributing Guide.
git clone https://github.com/nijaru/zenith.git
cd zenith
pip install -e ".[dev]"
pytest # Run tests
Status
Latest Version: v0.0.3
Python Support: 3.12-3.13
Test Suite: 100% passing (862 tests)
Performance: Production-ready with 9,600+ req/s capability
Architecture: Clean separation with Service system and simple dependency patterns
Zenith is production-ready with comprehensive middleware, performance optimizations, and clean architecture patterns for modern Python applications.
License
MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zenithweb-0.0.3.tar.gz.
File metadata
- Download URL: zenithweb-0.0.3.tar.gz
- Upload date:
- Size: 259.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27ce23e49c6dfb117d195ae8554354850ab9c4a602d897b3a042c5ce17ea1dcf
|
|
| MD5 |
15188a12bc0caa3774254685a136a77c
|
|
| BLAKE2b-256 |
bde5d2e63b02c133b91b999b7eaf2b3553ad9d5238c8fc061cfd4fc949163d6f
|
File details
Details for the file zenithweb-0.0.3-py3-none-any.whl.
File metadata
- Download URL: zenithweb-0.0.3-py3-none-any.whl
- Upload date:
- Size: 211.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
801b4815228b806604269859625745630e3a2b498696f5eaaee7717c2e6b099f
|
|
| MD5 |
c2231f2a3934e7c2a02c47e82279bc9c
|
|
| BLAKE2b-256 |
00a4baab161d3c5c831e09586b9b1bc8b6d8024d35c78a933a80652dd9280ce3
|