Skip to main content

A lightweight, FastAPI-inspired web framework

Project description

🚀 Tachyon API

Version Python License Status

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)
  • 🧰 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, 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, and now end-to-end safety with OpenAPI:

  • /orjson-demo: default JSON powered by orjson
  • /api/v1/users/e2e: Body + response_model, unified errors and deep OpenAPI schemas

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 }.

📝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some 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 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

tachyon_api-0.5.7.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

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

tachyon_api-0.5.7-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file tachyon_api-0.5.7.tar.gz.

File metadata

  • Download URL: tachyon_api-0.5.7.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tachyon_api-0.5.7.tar.gz
Algorithm Hash digest
SHA256 6b96e98ab035ece133e728147a4746c3a7daf5a5469506945bb2dacad053139b
MD5 6ae26dc0e5204b1684a38c161d7e37db
BLAKE2b-256 f5aad40198aaebd62fda123992a44d4ceff6c7a3ef3a322a80f73c0de29ea498

See more details on using hashes here.

File details

Details for the file tachyon_api-0.5.7-py3-none-any.whl.

File metadata

  • Download URL: tachyon_api-0.5.7-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tachyon_api-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d70ec84c3659f2f4625bdddbe8573be0a06b1ea06705513d6de8d0665309283f
MD5 cc55f517e8f905a50f427c33f5a8aae5
BLAKE2b-256 a0ed7e1a89e4989845e1fd657274bf3d2ae0f9e1030f801d9416ae3e66ecc483

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