Skip to main content

Modern asynchronous web framework for Python - all methods implemented independently

Project description

🚀 QakeAPI

Modern asynchronous web framework for Python

⚡ Built from scratch using only Python standard library

Python Version License Version PyPI version


✨ Features

  • ⚡ High Performance: Asynchronous request processing
  • 🔧 Built from Scratch: All methods implemented independently
  • 📦 Minimal Dependencies: Uses only Python standard library
  • 🔒 Built-in Security: Authentication, authorization, CORS, CSRF, rate limiting
  • 📚 Automatic Documentation: OpenAPI (Swagger) documentation generation
  • 🔌 WebSocket Support: Full WebSocket connection support
  • 💉 Dependency Injection: Powerful dependency injection system
  • 🛠️ Middleware System: Flexible middleware system
  • 📝 Data Validation: Automatic data validation
  • 🔄 Full Async/Await: Complete async/await support
  • 📊 Monitoring: Built-in metrics and health checks
  • 💾 Caching: In-memory caching support

🎯 Philosophy

QakeAPI is built with the philosophy that all core functionality should be implemented independently, using only Python's standard library. This ensures:

  • No External Dependencies: Core framework has zero dependencies
  • Full Control: Complete understanding and control over all code
  • Lightweight: Minimal overhead and fast performance
  • Educational: Learn how web frameworks work from the ground up

📦 Installation

From Source

# Clone the repository
git clone https://github.com/qakeapi/qakeapi.git
cd qakeapi

# Install in development mode
pip install -e .

# Or install with development dependencies
pip install -e ".[dev]"

Dependencies

Required:

  • Python 3.9+

Optional (for running server):

pip install uvicorn

For development:

pip install -e ".[dev]"

The framework itself has zero external dependencies - all core functionality uses only Python's standard library!


🚀 Quick Start

Create a file main.py:

from qakeapi import QakeAPI

app = QakeAPI(title="My First API")

@app.get("/")
async def root():
    return {"message": "Hello, World!"}

@app.get("/items/{item_id}")
async def get_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}

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

Run the server:

python main.py

Open your browser at http://localhost:8000 - you'll see a JSON response.


📚 Examples

Basic Usage

from qakeapi import QakeAPI

app = QakeAPI(title="My API")

@app.get("/")
async def root():
    return {"message": "Hello, World!"}

@app.get("/items/{item_id}")
async def get_item(item_id: int, q: str = None):
    return {"item_id": item_id, "query": q}

Validation

from qakeapi import QakeAPI
from qakeapi.validation import BaseModel, Field

app = QakeAPI()

class UserCreate(BaseModel):
    name: str = Field(min_length=3, max_length=50)
    email: str = Field(regex=r"^[^@]+@[^@]+\.[^@]+$")
    age: int = Field(min_value=18, max_value=120)

@app.post("/users")
async def create_user(user: UserCreate):
    return {"user": user.dict()}

Dependency Injection

from qakeapi import QakeAPI, Depends

app = QakeAPI()

async def get_database():
    return {"connected": True}

@app.get("/")
async def root(db: dict = Depends(get_database)):
    return {"database": db}

WebSocket

from qakeapi import QakeAPI, WebSocket

app = QakeAPI()

@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()
    await websocket.send_json({"message": "Hello!"})
    
    async for message in websocket.iter_json():
        await websocket.send_json({"echo": message})

Security

from qakeapi import QakeAPI
from qakeapi.security import AuthManager, CORSMiddleware

app = QakeAPI()
app.add_middleware(CORSMiddleware, allow_origins=["*"])

auth_manager = AuthManager(secret_key="your-secret-key")

@app.post("/login")
async def login(request: Request):
    data = await request.json()
    token = auth_manager.create_access_token({"user_id": 1})
    return {"access_token": token}

See the examples/ directory for more complete examples.


🏗️ Architecture

QakeAPI follows a modular architecture:

  • Core: Application, Request, Response, Router, Middleware, WebSocket
  • Validation: Data validators and models
  • Security: Authentication, authorization, CORS, CSRF, rate limiting
  • Caching: In-memory caching
  • Monitoring: Metrics and health checks
  • Utils: Static files, templates, JSON utilities
  • Testing: Test client and helpers

See ARCHITECTURE_PLAN.md for detailed architecture documentation.


📋 Development Status

Current Status: Alpha - Core features implemented

See DEVELOPMENT_PLAN.md for the complete development roadmap.

✅ Completed

  • ✅ Project structure and development environment
  • ✅ Core framework (Request, Response, Router, Application, Middleware)
  • ✅ Validation system (validators and models)
  • ✅ Dependency Injection
  • ✅ WebSocket support
  • ✅ Security features (JWT, password hashing, CORS, CSRF, Rate Limiting)
  • ✅ Caching (in-memory cache with TTL)
  • ✅ OpenAPI documentation generation
  • ✅ Static files and templates support

🚧 In Progress

  • 🚧 Additional examples and documentation

⏳ Planned

  • ⏳ Performance optimizations
  • ⏳ Additional middleware
  • ⏳ Enhanced template features

🧪 Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=qakeapi --cov-report=html

# Run specific test file
pytest tests/test_core.py

📚 Documentation


🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

QakeAPI is built from scratch as an educational project to understand how web frameworks work at a fundamental level.


QakeAPI - Build modern APIs from scratch! 🚀

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.1.1.tar.gz (161.7 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.1.1-py3-none-any.whl (198.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qakeapi-1.1.1.tar.gz
Algorithm Hash digest
SHA256 fe39e951ccebb3af048efc2f6b468301ec2912a81bcd7e66c1ff0b9f24ce98df
MD5 21889d587313c1e1146720601c222573
BLAKE2b-256 43124bfffec087f3ea84ecd1ac204fbae9bc84456d5f73d0b944d9d5fc9227b1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for qakeapi-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 231e19117f6e13f5886d8a2c05724e5585a43e376047138965d38a227375b509
MD5 0752daa0c4f669a01ab42cf41b674244
BLAKE2b-256 df8694eb78ba12a7d101299616739983b199c94763e46e85a9ef127851101be9

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