A lightweight, FastAPI-inspired web framework
Project description
🚀 Tachyon API
A lightweight, high-performance API framework for Python with the elegance of FastAPI and the speed of light.
Tachyon API combines the intuitive decorator-based syntax you love with minimal dependencies and maximal performance. Built with Test-Driven Development from the ground up, it offers a cleaner, faster alternative with full ASGI compatibility.
from tachyon_api import Tachyon
from tachyon_api.models import Struct
app = Tachyon()
class User(Struct):
name: str
age: int
@app.get("/")
def hello_world():
return {"message": "Tachyon is running at lightspeed!"}
@app.post("/users")
def create_user(user: User):
return {"created": user.name}
✨ Features
- 🔍 Intuitive API (decorators) and minimal core
- 🧩 Implicit & explicit DI
- 📚 OpenAPI with Scalar, Swagger, ReDoc
- 🛠️ Router system
- 🔄 Middlewares (class + decorator)
- 🧠 Cache decorator with TTL (in-memory, Redis, Memcached)
- 🚀 High-performance JSON (msgspec + orjson)
- 🧾 Unified error format (422/500) + global exception handler (500)
- 🧰 Default JSON response (TachyonJSONResponse)
- 🔒 End-to-end safety: request Body validation + typed response_model
- 📘 Deep OpenAPI schemas: nested Structs, Optional/List (nullable/array), formats (uuid, date-time)
🧪 Test-Driven Development
Tachyon API is built with TDD principles at its core. The test suite covers routing, DI, params, body validation, responses, OpenAPI generation, caching, and example flows.
🔌 Core Dependencies
- Starlette (ASGI)
- msgspec (validation/serialization)
- orjson (fast JSON)
- uvicorn (server)
💉 Dependency Injection System
- Implicit injection: annotate with registered types
- Explicit injection: Depends() for clarity and control
🔄 Middleware Support
- Built-in: CORSMiddleware and LoggerMiddleware
- Use app.add_middleware(...) or @app.middleware()
⚡ Cache with TTL
- @cache(TTL=...) on routes and functions
- Per-app config and pluggable backends (InMemory, Redis, Memcached)
📚 Example Application
The example demonstrates clean architecture, routers, middlewares, caching, end-to-end safety, and global exception handling:
- /orjson-demo: default JSON powered by orjson
- /api/v1/users/e2e: Body + response_model, unified errors and deep OpenAPI schemas
- /error-demo: triggers an unhandled exception to showcase the global handler (structured 500)
Run the example:
cd example
python app.py
Docs at /docs (Scalar), /swagger, /redoc.
✅ Response models, OpenAPI params, and deep schemas
- Response models: set response_model=YourStruct to validate/convert outputs via msgspec before serializing.
- Parameter schemas: Optional[T] → nullable: true; List[T] → type: array with items.
- Deep schemas: nested Struct components, Optional/List items, and formats (uuid, date-time) are generated and referenced in components.
🧾 Default JSON response and unified error format
- Default response: TachyonJSONResponse serializes complex types (UUID/date/datetime, Struct) via orjson and centralized encoders.
- 422 Validation: { success: false, error, code: VALIDATION_ERROR, [errors] }.
- 500 Response model: { success: false, error: "Response validation error: ...", detail, code: RESPONSE_VALIDATION_ERROR }.
- 500 Unhandled exceptions (global): { success: false, error: "Internal Server Error", code: INTERNAL_SERVER_ERROR }.
📝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📜 License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
🔮 Roadmap
- Exception system and global handlers
- CLI, scaffolding, and code quality tooling
- Authentication middleware and benchmarks
- More examples and deployment guides
Built with 💜 by developers, for developers
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
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 tachyon_api-0.5.11.tar.gz.
File metadata
- Download URL: tachyon_api-0.5.11.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37dd02c7f7a16c0d9b14e7742033d42631b7f3386610669a79390b1ce1e54399
|
|
| MD5 |
de0440725b1690e8adba833ade25ee27
|
|
| BLAKE2b-256 |
0833db9fab36c107c716db794e3976b02a9751d06758611f1029098f01d5d4c0
|
File details
Details for the file tachyon_api-0.5.11-py3-none-any.whl.
File metadata
- Download URL: tachyon_api-0.5.11-py3-none-any.whl
- Upload date:
- Size: 31.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e2d00cc4846ce28ad72e0367adeaf5b23610bff9957923afbe08e5b9c97355b
|
|
| MD5 |
71007c6cef2660bc296046526da79520
|
|
| BLAKE2b-256 |
0d5d888ac7f9818ac234c40ff2018f2820753e915a4856e37ead1e8fd63058da
|