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.2.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.2-py3-none-any.whl (198.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qakeapi-1.1.2.tar.gz
Algorithm Hash digest
SHA256 2f0b908c408d1646f95d9e3b92946d6c66eb8626508c04fbbab0c7562a39bcd0
MD5 cc5d335cd87114ec5781102421514986
BLAKE2b-256 092e9c5637b430d36f4ea5ecf7d8dc3c83bf52a76c61c1f1e9117cd0c1f1351a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qakeapi-1.1.2-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.11.14

File hashes

Hashes for qakeapi-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e4da94593a0edbe56895504a4ab066d3146482b009b9c47de649f1e845a5866
MD5 108219e3d8a550a2585c27e568b2a109
BLAKE2b-256 c88d21804e434f3c2982a8d288758ae19fffc37c55b1c27da342535e062abe45

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