ZeeFast - A lightweight FastAPI-like ASGI framework
Project description
# ZeeFast ⚡
**ZeeFast** is a lightweight experimental Python web framework inspired by **FastAPI**.
It is built from scratch to understand how modern ASGI frameworks work internally, including routing, dependency injection, middleware, query parsing, and response handling.
This project is educational and experimental—not intended for production use.
---
# 🚀 Features
- ASGI-compatible (runs on **Uvicorn**)
- FastAPI-style decorators (`@app.get`, `@app.post`, etc.)
- Path parameters (`/user/{id}`)
- Query parameter auto-parsing (`/search?q=python&page=2`)
- Dependency Injection (`Depends` system)
- Response system (HTML, JSON, Plain Text)
- APIRouter (route grouping like FastAPI)
- Middleware system
- Status code module like FastAPI
---
# 📁 Project Structure
zeefast/ │ ├── zeefast/ │ ├── app.py # Core ZeeFast ASGI app │ ├── request.py # Request parsing │ ├── response.py # Response classes │ ├── status.py # HTTP status codes │ ├── depends.py # Dependency Injection system │ ├── api_router.py # APIRouter implementation │ ├── middleware.py # Middleware system │ └── exceptions.py # Custom exceptions │ ├── README.md └── pyproject.toml / setup.py
---
# 🧠 Core Concepts
## 1️⃣ ASGI Application
ZeeFast is an ASGI callable:
```python
async def __call__(self, scope, receive, send):
...
Uvicorn calls this function for every request.
2️⃣ Routing
app = ZeeFast()
@app.get("/hello")
def hello():
return "Hello World"
Path Parameters
@app.get("/user/{id}")
def get_user(id: int):
return {"user_id": id}
Internally converted to regex:
/user/{id} → ^/user/(?P<id>[^/]+)$
3️⃣ Query Parameters (FastAPI-style)
@app.get("/search")
def search(q: str, page: int = 1):
return {"query": q, "page": page}
Request:
/search?q=python&page=2
ZeeFast automatically injects query params into function arguments.
4️⃣ Response System
Base Response
class Response:
def __init__(self, content, status=200, headers=None):
...
Built-in Responses
JsonResponse({...})
HtmlResponse("<h1>Hello</h1>")
PlainTextResponse("Hello")
RedirectResponse("/login")
FastAPI-style auto conversion:
| Return Type | Response Type |
|---|---|
| dict | JSONResponse |
| str | HTMLResponse |
| Response | Used directly |
5️⃣ Dependency Injection (Depends)
from zeefast.depends import Depends
def get_db():
return "DB Connection"
@app.get("/items")
def read_items(db = Depends(get_db)):
return {"db": db}
ZeeFast inspects function signature and executes dependencies automatically.
6️⃣ APIRouter (Route Groups)
router = APIRouter(prefix="/api")
@router.get("/users")
def users():
return ["A", "B"]
app.include_router(router)
Equivalent route:
/api/users
7️⃣ Middleware System
@app.middleware
async def logger(request, call_next):
print("Request:", request.path)
response = await call_next(request)
return response
Middleware wraps request → response pipeline.
8️⃣ Status Codes
from zeefast.status import status
status.HTTP_200_OK
status.HTTP_404_NOT_FOUND
Based on Python http.HTTPStatus.
🧪 Example App
from zeefast.app import ZeeFast
app = ZeeFast()
@app.get("/")
def home():
return "Hello ZeeFast"
@app.get("/user/{id}")
def user(id: int):
return {"id": id}
@app.get("/search")
def search(q: str, page: int = 1):
return {"q": q, "page": page}
Run:
uvicorn test:app --reload
🎯 Goals of ZeeFast
- Learn how FastAPI internals work
- Learn ASGI protocol
- Learn routing internals
- Learn DI system design
- Learn middleware pipelines
- Build a micro framework from scratch
⚠️ Disclaimer
ZeeFast is NOT production ready.
Missing:
- Pydantic validation
- OpenAPI docs
- Security layers
- High-performance routing
- Async dependency graphs
This is purely an educational framework.
🧑💻 Author
Zeeshan Aftab Software Engineering Student | AI & Backend Developer Pakistan 🇵🇰
⭐ Future Roadmap
- Request body parsing (JSON, form, file upload)
- Pydantic-like validation
- OpenAPI schema generator
- WebSocket support
- Template engine (Jinja-like)
- CLI tool:
zeefast run app:app
📜 License
MIT License
Made by Zeeshan Aftab
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 zeefast-0.1.0.tar.gz.
File metadata
- Download URL: zeefast-0.1.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80e2c4b9e2dd66cbc2f9d57419af1e89fd16fd3d7ca1e5a4730a1e84fa7d7847
|
|
| MD5 |
e3fd73ab3088865e3d400b8eb8b63ada
|
|
| BLAKE2b-256 |
0cc7b8f4e4bd7d66c6238494114c7817b7281de543112afe92a8c0e506f05511
|
File details
Details for the file zeefast-0.1.0-py3-none-any.whl.
File metadata
- Download URL: zeefast-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ae7017c50e237c2d762e3e39a753cd85272187945a2abcd1ecbc57cfe6ce501
|
|
| MD5 |
b45e236959afbff3e37c2ab6ba7685b1
|
|
| BLAKE2b-256 |
094f4adc7729b9e6e6af6690aeaa85438872df5f6f08cf1c969b75c40dfc345e
|