Skip to main content

Revolutionary Hybrid Async/Sync Web Framework for Python

Project description

๐Ÿš€ QakeAPI 1.3.0

QakeAPI Logo

Revolutionary Hybrid Async/Sync Web Framework for Python

โšก The first framework with seamless sync/async support and reactive architecture

PyPI version Python 3.9+ License: MIT CI Codecov


Why QakeAPI?

QakeAPI is the only Python web framework with true hybrid sync/async and zero dependencies in core. Write regular functions โ€” the framework automatically converts them to async. Perfect for Flask migration and projects where minimal external dependencies matter.


Framework Comparison

Feature QakeAPI FastAPI Flask
Zero deps (core) โœ… โŒ โŒ
Sync + Async hybrid โœ… โŒ โŒ
OpenAPI / Swagger โœ… โœ… โŒ
WebSocket โœ… โœ… โŒ
Dependency Injection โœ… โœ… โŒ
Rate Limiting (built-in) โœ… โŒ โŒ
Response Caching โœ… โŒ โŒ
Reactive Events โœ… โŒ โŒ
Pipeline Composition โœ… โŒ โŒ

โœจ What Makes QakeAPI Unique?

QakeAPI is a completely new approach to web frameworks:

  1. ๐Ÿ”„ Hybrid Sync/Async โ€” write sync and async code simultaneously
  2. โšก Reactive Routing โ€” reactive routing and events
  3. ๐Ÿš€ Parallel Dependencies โ€” automatic dependency parallelism
  4. ๐Ÿ”— Pipeline Composition โ€” function composition into pipelines
  5. ๐ŸŽฏ Smart Routing โ€” intelligent routing based on conditions

Key Features:

  • โœ… Zero Dependencies โ€” only Python standard library
  • โœ… Production-Ready โ€” ready for real-world projects
  • โœ… Performance โ€” automatic parallelism, optimized routing (Trie-based)
  • โœ… Simplicity โ€” intuitive syntax
  • โœ… Flexibility โ€” simultaneous sync and async support
  • โœ… OpenAPI/Swagger โ€” automatic API documentation
  • โœ… WebSocket Support โ€” real-time communication
  • โœ… Background Tasks โ€” asynchronous task processing
  • โœ… Middleware System โ€” customizable request/response processing
  • โœ… CORS Support โ€” built-in CORS middleware
  • โœ… Dependency Injection โ€” clean architecture with DI
  • โœ… Rate Limiting โ€” built-in rate limiting decorator
  • โœ… Caching โ€” response caching with TTL
  • โœ… Request Validation โ€” automatic data validation
  • โœ… File Upload โ€” multipart file upload with validation
  • โœ… Security โ€” request size limits, validation, error handling

๐Ÿš€ Quick Start

Installation

pip install qakeapi

Simple Example

from qakeapi import QakeAPI, CORSMiddleware

app = QakeAPI(
    title="My API",
    version="1.3.0",
    description="My awesome API"
)

# Add CORS middleware
app.add_middleware(CORSMiddleware(allow_origins=["*"]))

# Sync function works automatically!
@app.get("/users/{id}")
def get_user(id: int):
    return {"id": id, "name": f"User {id}"}

# Async function is also supported
@app.get("/items/{item_id}")
async def get_item(item_id: int):
    return {"item_id": item_id}

# POST with automatic body extraction
@app.post("/users")
async def create_user(request):
    data = await request.json()
    return {"message": "User created", "data": data}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)

Access the API documentation:

  • Swagger UI: http://localhost:8000/docs
  • OpenAPI JSON: http://localhost:8000/openapi.json

Demo

QakeAPI Swagger Demo

Automatic OpenAPI documentation โ€” works out of the box

Architecture

QakeAPI Architecture


๐Ÿ“š Core Features

1. Hybrid Sync/Async

Write synchronous code, the framework automatically handles it:

@app.get("/users/{id}")
def get_user(id: int):  # Regular function!
    # Blocking operations automatically executed in executor
    user = database.get_user(id)
    posts = database.get_user_posts(id)
    return {"user": user, "posts": posts}

2. Parallel Dependencies

Dependencies execute in parallel:

@app.get("/dashboard")
async def dashboard(
    user: User = get_user(),
    stats: Stats = get_stats(),
    notifications: list = get_notifications()
):
    # All three functions execute in parallel!
    return {
        "user": user,
        "stats": stats,
        "notifications": notifications
    }

3. Reactive Events

React to events in your application:

@app.react("order:created")
async def on_order_created(event):
    order = event.data
    await inventory.reserve(order.items)
    await payment.process(order)
    await shipping.schedule(order)

# Emit event
await app.emit("order:created", order_data)

4. Pipeline Composition

Compose functions into pipelines:

@app.pipeline([
    authenticate,
    authorize,
    validate,
    transform,
    save
])
def create_resource(data: ResourceData):
    return {"id": data.id, "status": "created"}

5. Smart Routing

Conditional routing based on conditions:

@app.when(lambda req: req.headers.get("X-Client") == "mobile")
def mobile_handler(request):
    return {"mobile": True}

@app.when(lambda req: req.path.startswith("/api/v2"))
def v2_handler(request):
    return {"version": "2.0"}

6. Automatic API Documentation

OpenAPI/Swagger documentation is automatically generated:

app = QakeAPI(
    title="My API",
    version="1.3.0",
    description="API documentation"
)

# All routes are automatically documented
@app.get("/users/{id}")
def get_user(id: int):
    """Get user by ID."""
    return {"id": id}

7. WebSocket Support

Real-time communication:

@app.websocket("/ws/{room}")
async def websocket_handler(websocket: WebSocket, room: str):
    await websocket.accept()
    await websocket.send_json({"message": f"Welcome to {room}!"})
    
    async for message in websocket.iter_json():
        await websocket.send_json({"echo": message})

8. Background Tasks

Run tasks asynchronously:

from qakeapi.core.background import add_background_task

@app.post("/process")
async def process_data(request):
    data = await request.json()
    
    # Run task in background
    await add_background_task(process_heavy_task, data)
    
    return {"message": "Processing started"}

9. Middleware System

Customize request/response processing:

from qakeapi import CORSMiddleware, LoggingMiddleware, RequestSizeLimitMiddleware

app.add_middleware(CORSMiddleware(allow_origins=["*"]))
app.add_middleware(LoggingMiddleware())
app.add_middleware(RequestSizeLimitMiddleware(max_size=10 * 1024 * 1024))  # 10MB

10. Dependency Injection

Clean architecture with dependency injection:

from qakeapi import QakeAPI, Depends

app = QakeAPI()

def get_database():
    return Database()

@app.get("/users")
async def get_users(db = Depends(get_database)):
    return await db.get_users()

11. Rate Limiting

Protect your API with rate limiting:

from qakeapi import rate_limit

@rate_limit(requests_per_minute=60)
@app.get("/api/data")
def get_data():
    return {"data": "..."}

12. Response Caching

Cache responses for better performance:

from qakeapi import cache

@cache(ttl=300)  # Cache for 5 minutes
@app.get("/expensive-operation")
def expensive_operation():
    return {"result": compute_expensive_result()}

13. File Upload

Handle file uploads with validation and security:

from qakeapi import QakeAPI, FileUpload, IMAGE_TYPES

@app.post("/upload")
async def upload_image(file: FileUpload):
    # Validate file type
    if not file.validate_type(IMAGE_TYPES):
        return {"error": "Only images"}, 400
    
    # Validate size (5MB)
    if not file.validate_size(5 * 1024 * 1024):
        return {"error": "File too large"}, 400
    
    # Save file
    path = await file.save("uploads/")
    return {"path": path}

๐Ÿ“ฆ Architecture

qakeapi/
โ”œโ”€โ”€ core/              # Core components
โ”‚   โ”œโ”€โ”€ app.py        # Main QakeAPI class
โ”‚   โ”œโ”€โ”€ hybrid.py     # Hybrid executor (syncโ†’async)
โ”‚   โ”œโ”€โ”€ router.py     # Smart router (Trie-optimized)
โ”‚   โ”œโ”€โ”€ reactive.py   # Reactive engine
โ”‚   โ”œโ”€โ”€ parallel.py   # Parallel resolver
โ”‚   โ”œโ”€โ”€ pipeline.py   # Pipeline processor
โ”‚   โ”œโ”€โ”€ request.py    # HTTP Request
โ”‚   โ”œโ”€โ”€ response.py   # HTTP Response
โ”‚   โ”œโ”€โ”€ middleware.py # Middleware system
โ”‚   โ”œโ”€โ”€ websocket.py  # WebSocket support
โ”‚   โ”œโ”€โ”€ background.py # Background tasks
โ”‚   โ”œโ”€โ”€ openapi.py    # OpenAPI generation
โ”‚   โ”œโ”€โ”€ files.py      # File upload handling
โ”‚   โ”œโ”€โ”€ dependencies.py # Dependency Injection
โ”‚   โ”œโ”€โ”€ validation.py # Data validation
โ”‚   โ”œโ”€โ”€ rate_limit.py # Rate limiting
โ”‚   โ”œโ”€โ”€ caching.py    # Response caching
โ”‚   โ”œโ”€โ”€ logging.py    # Logging system
โ”‚   โ””โ”€โ”€ exceptions.py # HTTP exceptions
โ””โ”€โ”€ utils/            # Utilities

๐Ÿ“– Documentation

Full documentation is available in the docs/ directory:


๐Ÿ‘ฅ Community


๐Ÿข Used by

Using QakeAPI in production? Add your project!


๐ŸŽฏ Examples

Check out the examples/ directory for complete examples:

  • basic_example.py - Basic features demonstration
  • complete_example.py - Full feature showcase
  • file_upload_example.py - File upload handling
  • financial_calculator.py - Complex real-world application

๐Ÿ”ง Requirements

  • Python 3.9+
  • uvicorn (optional, for running the server)

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

๐Ÿ”’ Security

Please report security vulnerabilities responsibly. See SECURITY.md for details.

๐Ÿ“ License

MIT License - see LICENSE for details.


๐Ÿ™ Acknowledgments

QakeAPI is built from scratch using only Python standard library, demonstrating a new approach to web frameworks.


QakeAPI - Build modern APIs with revolutionary approach! ๐Ÿš€

Made with โค๏ธ by the QakeAPI team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qakeapi-1.3.0.tar.gz (68.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qakeapi-1.3.0-py3-none-any.whl (55.6 kB view details)

Uploaded Python 3

File details

Details for the file qakeapi-1.3.0.tar.gz.

File metadata

  • Download URL: qakeapi-1.3.0.tar.gz
  • Upload date:
  • Size: 68.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for qakeapi-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c837e8847cfe3a7af83a02e62cef2e9766effbf9fe86bcab2220083094993198
MD5 c506e3a8bc687caefcfb950c7a4d17b9
BLAKE2b-256 53a59622ba6648f94527bbfc66d1e9dba06ac6bfe7daa57e3e6e0789fd3c778a

See more details on using hashes here.

File details

Details for the file qakeapi-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: qakeapi-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 55.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for qakeapi-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51b6009dcc7e1a9fd1f4c457fd7cf1ac825f7cd01f45480688e2d193b2d69668
MD5 fa492e4fed61104afce28f79c614ee64
BLAKE2b-256 6a4ea73422b39450db5ddfc7fc6c08df2dcf3027fb92bab53c3e982971140c2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page