Skip to content

A lightweight, high-performance Python API framework with the elegance of FastAPI and minimal dependencies.

License

Notifications You must be signed in to change notification settings

jmpanozzoz/tachyon_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

65 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Tachyon API

Version Python License Tests 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.

๐Ÿš€ Quick Start

from tachyon_api import Tachyon, Struct, Body, Query

app = Tachyon()

class User(Struct):
    name: str
    email: str

@app.get("/")
def hello():
    return {"message": "Tachyon is running at lightspeed!"}

@app.post("/users")
def create_user(user: User = Body(...)):
    return {"created": user.name}

@app.get("/search")
def search(q: str = Query(...), limit: int = Query(10)):
    return {"query": q, "limit": limit}
pip install tachyon-api
uvicorn app:app --reload

๐Ÿ“– Docs: http://localhost:8000/docs


โšก Performance with tachyon-engine (Experimental)

Tachyon API v1.0.0 includes adapter infrastructure for tachyon-engine, a Rust-powered ASGI implementation:

from tachyon_api import Tachyon, AsgiEngine

# Default: Stable Starlette engine (production-ready)
app = Tachyon()

# Experimental: Rust-powered engine (4-7x faster when complete)
app = Tachyon(engine=AsgiEngine.TACHYON)

Current Status: tachyon-engine v0.1.0 is experimental. Production default uses Starlette. See docs/tachyon-engine.md for details.

Performance Goals (when tachyon-engine v0.2.0+ is ready):

  • 10x faster path matching
  • 2-3x faster request processing
  • 1.7x faster JSON serialization
  • 2-4x overall throughput improvement

โœจ Features

Category Features
Core Decorators API, Routers, Middlewares, ASGI compatible
Parameters Path, Query, Body, Header, Cookie, Form, File
Validation msgspec Struct (ultra-fast), automatic 422 errors
DI @injectable (implicit), Depends() (explicit)
Security HTTPBearer, HTTPBasic, OAuth2, API Keys
Async Background Tasks, WebSockets
Performance orjson serialization, @cache decorator
Docs OpenAPI 3.0, Scalar UI, Swagger, ReDoc
CLI Project scaffolding, code generation, linting
Testing TachyonTestClient, dependency_overrides

๐Ÿ“š Documentation

Complete documentation is available in the docs/ folder:

Guide Description
Getting Started Installation and first project
Architecture Clean architecture patterns
Dependency Injection @injectable and Depends()
Parameters Path, Query, Body, Header, Cookie, Form, File
Validation msgspec Struct validation
Security JWT, Basic, OAuth2, API Keys
Caching @cache decorator
Lifecycle Events Startup/Shutdown
Background Tasks Async task processing
WebSockets Real-time communication
Testing TachyonTestClient
CLI Tools Scaffolding and generation
Request Lifecycle How requests are processed
Migration from FastAPI Migration guide
Best Practices Recommended patterns
tachyon-engine Rust engine (experimental)

๐Ÿฆ Example: KYC Demo API

A complete example demonstrating all Tachyon features is available in example/:

cd example
pip install -r requirements.txt
uvicorn example.app:app --reload

The KYC Demo implements:

  • ๐Ÿ” JWT Authentication
  • ๐Ÿ‘ค Customer CRUD
  • ๐Ÿ“‹ KYC Verification with Background Tasks
  • ๐Ÿ“ Document Uploads
  • ๐ŸŒ WebSocket Notifications
  • ๐Ÿงช 12 Tests with Mocks

Demo credentials: demo@example.com / demo123

๐Ÿ‘‰ See example/README.md for full details.


๐Ÿ”Œ Core Dependencies

Package Purpose
starlette ASGI framework
msgspec Ultra-fast validation/serialization
orjson High-performance JSON
uvicorn ASGI server

๐Ÿ’‰ Dependency Injection

from tachyon_api import injectable, Depends

@injectable
class UserService:
    def get_user(self, id: str):
        return {"id": id}

@app.get("/users/{id}")
def get_user(id: str, service: UserService = Depends()):
    return service.get_user(id)

๐Ÿ‘‰ Full DI documentation


๐Ÿ” Security

from tachyon_api.security import HTTPBearer, OAuth2PasswordBearer

bearer = HTTPBearer()

@app.get("/protected")
async def protected(credentials = Depends(bearer)):
    return {"token": credentials.credentials}

๐Ÿ‘‰ Full Security documentation


โšก Background Tasks

from tachyon_api.background import BackgroundTasks

@app.post("/notify")
def notify(background_tasks: BackgroundTasks):
    background_tasks.add_task(send_email, "user@example.com")
    return {"status": "queued"}

๐Ÿ‘‰ Full Background Tasks documentation


๐ŸŒ WebSockets

@app.websocket("/ws")
async def websocket(ws):
    await ws.accept()
    data = await ws.receive_text()
    await ws.send_text(f"Echo: {data}")

๐Ÿ‘‰ Full WebSockets documentation


๐Ÿ”ง CLI Tools

# Create new project
tachyon new my-api

# Generate module
tachyon generate service users --crud

# Code quality
tachyon lint all

๐Ÿ‘‰ Full CLI documentation


๐Ÿงช Testing

from tachyon_api.testing import TachyonTestClient

def test_hello():
    client = TachyonTestClient(app)
    response = client.get("/")
    assert response.status_code == 200
pytest tests/ -v

๐Ÿ‘‰ Full Testing documentation


๐Ÿ“Š Why Tachyon?

Feature Tachyon FastAPI
Serialization msgspec + orjson pydantic
Performance โšกโšกโšก Ultra-fast โšก Fast
Bundle Size Minimal Larger
Learning Curve Easy (FastAPI-like) Easy
Type Safety Full Full

๐Ÿ“ 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. Run tests (pytest tests/ -v)
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

๐Ÿ“œ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.


๐Ÿ”ฎ What's Next

See CHANGELOG.md for version history.

Upcoming features:

  • Response streaming
  • GraphQL support
  • More deployment guides
  • Performance benchmarks

Built with ๐Ÿ’œ by developers, for developers

About

A lightweight, high-performance Python API framework with the elegance of FastAPI and minimal dependencies.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages