Skip to main content

A lightweight, modern Python web framework with ORM and auto-generated API docs

Project description

Maweng Framework

A lightweight, modern Python web framework designed for building scalable backend systems with ease. Maweng combines the simplicity of Flask with the power of FastAPI, featuring an intuitive ORM, auto-generated API documentation, and developer-friendly tooling.

🚀 Features

  • Lightning Fast: Built on top of FastAPI and Uvicorn for exceptional performance
  • Intuitive ORM: SQLAlchemy-based ORM with automatic migrations
  • Auto-Generated API Docs: OpenAPI/Swagger documentation out of the box
  • Type Safety: Full type hints and Pydantic integration
  • Dependency Injection: Clean architecture with built-in DI container
  • CLI Tools: Project scaffolding and management utilities
  • Testing Framework: Built-in testing utilities and fixtures
  • Modern Python: Python 3.8+ with async/await support

📦 Installation

# Install from PyPI (when available)
pip install maweng

# Or install from source
git clone https://github.com/maweng/framework.git
cd framework
pip install -e .

🎯 Quick Start

1. Create a New Project

maweng new myapp
cd myapp

2. Define Your Models

# models.py
from maweng.orm import Model, Field
from datetime import datetime

class User(Model):
    __tablename__ = "users"
    
    id = Field.Integer(primary_key=True)
    email = Field.String(unique=True, max_length=255)
    name = Field.String(max_length=100)
    created_at = Field.DateTime(default=datetime.utcnow)
    is_active = Field.Boolean(default=True)

3. Create Your Views

# views.py
from maweng import View, Response
from maweng.orm import query
from .models import User

class UserView(View):
    @query.get("/users")
    async def list_users(self):
        users = await User.all()
        return Response.json(users)
    
    @query.post("/users")
    async def create_user(self, user_data: dict):
        user = await User.create(**user_data)
        return Response.json(user, status=201)
    
    @query.get("/users/{user_id}")
    async def get_user(self, user_id: int):
        user = await User.get(user_id)
        if not user:
            return Response.json({"error": "User not found"}, status=404)
        return Response.json(user)

4. Run Your Application

maweng run

Visit http://localhost:8000/docs to see your auto-generated API documentation!

🏗️ Project Structure

myapp/
├── app/
│   ├── __init__.py
│   ├── models.py          # Database models
│   ├── views.py           # API endpoints
│   ├── services.py        # Business logic
│   └── middleware.py      # Custom middleware
├── migrations/            # Database migrations
├── tests/                 # Test files
├── static/               # Static files
├── templates/            # HTML templates
├── config.py             # Configuration
└── main.py              # Application entry point

🔧 Configuration

# config.py
from maweng.config import Config

class DevelopmentConfig(Config):
    DEBUG = True
    DATABASE_URL = "sqlite:///./dev.db"
    SECRET_KEY = "your-secret-key"
    
class ProductionConfig(Config):
    DEBUG = False
    DATABASE_URL = "postgresql://user:pass@localhost/db"
    SECRET_KEY = "your-production-secret"

🗄️ ORM Usage

Basic CRUD Operations

# Create
user = await User.create(name="John Doe", email="john@example.com")

# Read
user = await User.get(1)
users = await User.filter(is_active=True)
all_users = await User.all()

# Update
await user.update(name="Jane Doe")
# or
await User.filter(id=1).update(name="Jane Doe")

# Delete
await user.delete()
# or
await User.filter(id=1).delete()

Relationships

class Post(Model):
    __tablename__ = "posts"
    
    id = Field.Integer(primary_key=True)
    title = Field.String(max_length=200)
    content = Field.Text()
    author_id = Field.Integer(foreign_key="users.id")
    
    # Define relationship
    author = Relationship("User", back_populates="posts")

class User(Model):
    # ... existing fields ...
    posts = Relationship("Post", back_populates="author")

🧪 Testing

# tests/test_users.py
import pytest
from maweng.testing import TestClient
from app.models import User

@pytest.mark.asyncio
async def test_create_user():
    client = TestClient()
    
    response = await client.post("/users", json={
        "name": "Test User",
        "email": "test@example.com"
    })
    
    assert response.status_code == 201
    assert response.json()["name"] == "Test User"

📚 Documentation

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆚 Comparison with Other Frameworks

Feature Maweng FastAPI Django Flask
Performance ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐
Ease of Use ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐⭐
ORM ⭐⭐⭐⭐⭐ ⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐
Auto Docs ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐
Type Safety ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐ ⭐⭐⭐ ⭐⭐
Learning Curve ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐ ⭐⭐ ⭐⭐⭐⭐

🚀 Roadmap

  • GraphQL support
  • WebSocket support
  • Background task queue
  • Admin interface
  • Plugin system
  • Microservices support
  • Kubernetes deployment tools

Built with ❤️ by the Maweng Framework Team

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

maweng-0.1.0.tar.gz (40.7 kB view details)

Uploaded Source

Built Distribution

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

maweng-0.1.0-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file maweng-0.1.0.tar.gz.

File metadata

  • Download URL: maweng-0.1.0.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for maweng-0.1.0.tar.gz
Algorithm Hash digest
SHA256 32d9650594769e15597f332272442ab7bf821ff70c01d5123c817933242eb998
MD5 f9e31643e0f1479acfaf8e95d0dc9ac3
BLAKE2b-256 a0552fe41025ee5246c925afc1249f43438fedf764de4d2c526493b5cb3211cc

See more details on using hashes here.

File details

Details for the file maweng-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: maweng-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for maweng-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 506743dc5be9d6ad4d807d7fa48aaa635c5e328b3ffe15c81af6d983c46fec60
MD5 1b4929c57331fce5222f9c89f25d0b49
BLAKE2b-256 00376b154a83c5dcddc8f9bcc9fd071a9eb94b97c76d23e6046b10f7c0fc06ca

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