Skip to content
myfy logo

myfy

Build Python applications that feel like they wrote themselves.


Why Another Framework?

You've built enough Python apps to know: FastAPI is brilliant for APIs but barebones for real apps. Django's too heavy and too coupled. Flask feels like duct tape.

What if you could have: - FastAPI's ergonomics (decorators, type hints, async-first) - Enterprise-grade architecture (DI container, module system, lifecycle) - Sensible defaults (no config files until you need them)

myfy is that framework. Opinionated where it matters, flexible everywhere else.


60-Second Example

Full-Stack App with Frontend

Build a complete web app with DaisyUI components:

# Initialize frontend (one-time setup)
uv run myfy frontend init

This creates app.py and frontend/ with Tailwind 4 + DaisyUI 5:

from myfy.core import Application
from myfy.web import WebModule, route
from myfy.frontend import FrontendModule, render_template
from starlette.requests import Request
from starlette.templating import Jinja2Templates

@route.get("/")
async def home(request: Request, templates: Jinja2Templates):
    return render_template(
        "home.html",
        request=request,
        templates=templates,
        title="Welcome to myfy"
    )

app = Application(auto_discover=False)
app.add_module(WebModule())
app.add_module(FrontendModule())

Run it:

uv run myfy run

Visit http://127.0.0.1:8000 - styled UI with DaisyUI, instant HMR, ready to ship.

myfy Frontend Light myfy Frontend Dark


API-Only Example

Build a REST API with DI and validation:

from myfy.core import Application, provider, SINGLETON, BaseSettings
from myfy.web import route, WebModule
from pydantic import Field

# 1. Settings (auto-loads from .env)
class Settings(BaseSettings):
    app_name: str = Field(default="My App")
    api_key: str

# 2. Services (constructor-injected)
class UserService:
    def __init__(self, settings: Settings):
        self.settings = settings

    def greet(self, name: str) -> str:
        return f"Hello {name} from {self.settings.app_name}!"

@provider(scope=SINGLETON)
def user_service(settings: Settings) -> UserService:
    return UserService(settings)

# 3. Routes (DI + path params + type conversion)
@route.get("/greet/{name}")
async def greet_user(name: str, service: UserService) -> dict:
    return {"message": service.greet(name)}

# 4. Run
app = Application(settings_class=Settings, auto_discover=False)
app.add_module(WebModule())

Run it:

echo "API_KEY=secret123" > .env
uv run myfy run

Visit http://127.0.0.1:8000/greet/World


What Makes myfy Different

Modules That Actually Work

Real, composable modules with their own lifecycle - not "blueprints":

class DataModule(BaseModule):
    async def start(self):
        await self.db.connect()

    async def stop(self):
        await self.db.disconnect()

app.add_module(DataModule())
app.add_module(WebModule())

Dependency Injection Without Magic

Type-based DI that's fast (zero reflection on hot path) and safe (compile-time validation):

@provider(scope=SINGLETON)
def database(settings: Settings) -> Database:
    return Database(settings.db_url)

@route.post("/users")
async def create_user(body: CreateUserDTO, db: Database):
    return await db.create_user(body)

Defaults That Make Sense

One file. No config. Just run.


Getting Started

  • Installation


    Install myfy and create your first app in 5 minutes

    Get Started

  • Tutorial


    Build a complete application step-by-step

    Full Tutorial

  • Quick Reference


    Common patterns and code snippets

    Cheat Sheet

  • Core Concepts


    Deep dive into DI, modules, configuration, and lifecycle

    Learn More


Key Features

Feature Description
Type-Safe DI Constructor injection with SINGLETON, REQUEST, and TASK scopes
Module System First-class modules with lifecycle hooks (start/stop)
FastAPI-Style Routes Decorators, path params, automatic body parsing
Configuration Profiles Environment-based config (dev/test/prod) with Pydantic validation
CLI Tools Built-in commands: run, routes, modules, doctor
Zero Reflection All DI resolution at compile-time, not request-time
Async-Native ASGI + AnyIO throughout

Next Steps

New to myfy? Start with the Installation Guide and Tutorial

Want to understand the architecture? Read about Dependency Injection, Modules, and Configuration

Need API details? Check the API Reference

Want to contribute? See our Contributing Guide


Philosophy

Built on core principles: - Opinionated, not rigid - Strong defaults but fully customizable - Defaults by default - Zero config to start, infinite config to scale - Pythonic over ceremonial - Type hints, decorators, async/await - Modular by design - Tiny kernel, add what you need - Zero reflection on hot path - All analysis at startup

Read the full philosophy: PRINCIPLES.md


Community & Support

License

MIT