Metadata-Version: 2.4
Name: covet
Version: 0.1.0b4
Summary: A high-performance Python web framework with Rust-optimized components for modern async applications
Author: Vipin Kumar
Maintainer: Vipin Kumar
License: Proprietary
Project-URL: Author, https://github.com/vipin08
Project-URL: Documentation, https://github.com/vipin08/Covet-doc
Keywords: rest-api,http,api,python-rust,async,asgi,web-framework,graphql,websocket,high-performance,rust-extensions,orm,database,jwt-auth
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Rust
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE_HEADER
Requires-Dist: pydantic>=2.12.0
Requires-Dist: prometheus-client>=0.23.1
Requires-Dist: psutil>=7.1.0
Requires-Dist: PyJWT>=2.8.0
Provides-Extra: dev
Requires-Dist: pytest>=8.4.2; extra == "dev"
Requires-Dist: pytest-asyncio>=1.2.0; extra == "dev"
Requires-Dist: pytest-cov>=7.0.0; extra == "dev"
Requires-Dist: pytest-mock>=3.15.1; extra == "dev"
Requires-Dist: pytest-benchmark>=5.1.0; extra == "dev"
Requires-Dist: black>=25.9.0; extra == "dev"
Requires-Dist: ruff>=0.14.0; extra == "dev"
Requires-Dist: mypy>=1.7.1; extra == "dev"
Requires-Dist: pre-commit>=3.5.0; extra == "dev"
Requires-Dist: httpx>=0.28.1; extra == "dev"
Requires-Dist: maturin>=1.9.4; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.5.3; extra == "docs"
Requires-Dist: mkdocs-material>=9.5.32; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
Provides-Extra: test
Requires-Dist: pytest>=8.4.2; extra == "test"
Requires-Dist: pytest-asyncio>=1.2.0; extra == "test"
Requires-Dist: pytest-cov>=7.0.0; extra == "test"
Requires-Dist: pytest-mock>=3.15.1; extra == "test"
Requires-Dist: pytest-benchmark>=5.1.0; extra == "test"
Requires-Dist: httpx>=0.28.1; extra == "test"
Provides-Extra: security
Requires-Dist: pyotp>=2.9.0; extra == "security"
Requires-Dist: passlib[bcrypt]>=1.7.4; extra == "security"
Requires-Dist: validators>=0.22.0; extra == "security"
Requires-Dist: bleach>=6.2.0; extra == "security"
Requires-Dist: limits>=3.7.0; extra == "security"
Requires-Dist: python-multipart>=0.0.6; extra == "security"
Requires-Dist: email-validator>=2.1.0; extra == "security"
Provides-Extra: web
Requires-Dist: fastapi>=0.118.2; extra == "web"
Requires-Dist: uvicorn[standard]>=0.37.0; extra == "web"
Requires-Dist: pydantic>=2.12.0; extra == "web"
Requires-Dist: pydantic-settings>=2.11.0; extra == "web"
Provides-Extra: database
Requires-Dist: sqlalchemy>=2.0.43; extra == "database"
Requires-Dist: alembic>=1.16.5; extra == "database"
Requires-Dist: asyncpg>=0.30.0; extra == "database"
Requires-Dist: aiomysql>=0.2.0; extra == "database"
Provides-Extra: production
Requires-Dist: uvicorn[standard]>=0.37.0; extra == "production"
Requires-Dist: asyncpg>=0.30.0; extra == "production"
Requires-Dist: aiomysql>=0.2.0; extra == "production"
Requires-Dist: redis>=6.4.0; extra == "production"
Requires-Dist: aiomemcache>=0.8.0; extra == "production"
Requires-Dist: passlib[bcrypt]>=1.7.4; extra == "production"
Requires-Dist: python-dotenv>=1.1.1; extra == "production"
Provides-Extra: graphql
Requires-Dist: strawberry-graphql>=0.209.0; extra == "graphql"
Provides-Extra: orm
Requires-Dist: sqlalchemy>=2.0.43; extra == "orm"
Requires-Dist: alembic>=1.16.5; extra == "orm"
Provides-Extra: rust
Requires-Dist: maturin>=1.9.4; extra == "rust"
Provides-Extra: monitoring
Requires-Dist: opentelemetry-api>=1.21.0; extra == "monitoring"
Requires-Dist: opentelemetry-sdk>=1.21.0; extra == "monitoring"
Requires-Dist: structlog>=23.2.0; extra == "monitoring"
Provides-Extra: full
Requires-Dist: uvicorn[standard]>=0.37.0; extra == "full"
Requires-Dist: pydantic>=2.12.0; extra == "full"
Requires-Dist: pydantic-settings>=2.11.0; extra == "full"
Requires-Dist: httpx>=0.28.1; extra == "full"
Requires-Dist: sqlalchemy>=2.0.43; extra == "full"
Requires-Dist: alembic>=1.16.5; extra == "full"
Requires-Dist: asyncpg>=0.30.0; extra == "full"
Requires-Dist: aiomysql>=0.2.0; extra == "full"
Requires-Dist: redis>=6.4.0; extra == "full"
Requires-Dist: aiomemcache>=0.8.0; extra == "full"
Requires-Dist: strawberry-graphql>=0.283.2; extra == "full"
Requires-Dist: passlib[bcrypt]>=1.7.4; extra == "full"
Requires-Dist: validators>=0.22.0; extra == "full"
Requires-Dist: bleach>=6.2.0; extra == "full"
Requires-Dist: limits>=5.5.0; extra == "full"
Requires-Dist: python-multipart>=0.0.20; extra == "full"
Requires-Dist: email-validator>=2.3.0; extra == "full"
Requires-Dist: click>=8.3.0; extra == "full"
Requires-Dist: rich>=14.2.0; extra == "full"
Requires-Dist: prometheus-client>=0.23.1; extra == "full"
Requires-Dist: opentelemetry-api>=1.37.0; extra == "full"
Requires-Dist: opentelemetry-sdk>=1.37.0; extra == "full"
Requires-Dist: structlog>=25.4.0; extra == "full"
Requires-Dist: python-dotenv>=1.1.1; extra == "full"
Requires-Dist: pyyaml>=6.0.3; extra == "full"
Requires-Dist: jinja2>=3.1.6; extra == "full"
Requires-Dist: maturin>=1.9.4; extra == "full"
Dynamic: license-file

# CovetPy - High-Performance Python Web Framework

[![Python versions](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/)
[![License](https://img.shields.io/badge/license-Proprietary-red)]()
[![Status](https://img.shields.io/badge/status-BETA-orange)]()

**CovetPy** is a high-performance Python web framework with Rust-optimized components, designed for building modern async applications with exceptional speed and developer experience.

---

## 🚀 Key Features

### Performance
- **Rust-Optimized Routing:** 10-13% performance improvement over pure Python
- **Async/Await First:** Built on ASGI 3.0 for maximum concurrency
- **Zero-Copy Operations:** Efficient memory usage with Rust extensions
- **Production-Ready:** Battle-tested components for high-traffic applications

### Full-Stack Capabilities
- **REST API:** Fast HTTP request/response handling with Pydantic validation
- **GraphQL:** Powered by Strawberry GraphQL for modern API development
- **WebSocket:** Real-time bidirectional communication with room management
- **Database ORM:** Full-featured ORM with migrations for PostgreSQL, MySQL, SQLite
- **Authentication:** JWT tokens, password hashing, MFA support
- **Caching:** Redis and in-memory caching for optimal performance

### Developer Experience
- **Type-Safe:** Comprehensive type hints for excellent IDE support
- **Modern Python:** Uses latest Python 3.9+ features
- **Clean API:** Intuitive, Flask-inspired interface
- **Well-Documented:** Extensive documentation and examples

---

## 📦 Installation

### Quick Install

```bash
# Minimal installation
pip install covet
```

## ⚡ Quick Start

### Hello World (30 seconds)

```python
from covet import CovetPy

# Create application
app = CovetPy()

# Define routes
@app.route("/")
async def hello(request):
    return {"message": "Hello, CovetPy!"}

@app.route("/users/{user_id}")
async def get_user(request, user_id: int):
    return {"user_id": user_id, "name": f"User {user_id}"}

# Run server
if __name__ == "__main__":
    app.run()  # Runs on http://localhost:8000
```

### Database ORM - Django/Flask-Style QuerySet API

```python
from decimal import Decimal
from covet.database.adapters.mysql import MySQLAdapter
from covet.database.orm import Model, Q
from covet.database.orm.fields import (
    AutoField, CharField, EmailField, IntegerField,
    BooleanField, MoneyField, Money, DateTimeField
)
from covet.database.orm.managers import ModelManager
from covet.database.orm.adapter_registry import register_adapter

# Setup database connection
adapter = MySQLAdapter(
    host='localhost',
    user='root',
    password='password',
    database='myapp'
)
await adapter.connect()
register_adapter('default', adapter)

# Define model with Django-style fields
class User(Model):
    id = AutoField()
    username = CharField(max_length=50)
    email = EmailField(unique=True)
    age = IntegerField()
    is_active = BooleanField(default=True)
    balance = MoneyField(max_digits=10, decimal_places=2, currency='USD')
    created_at = DateTimeField(auto_now_add=True)

    class Meta:
        db_table = 'users'
        ordering = ['-created_at']

# Setup model manager
User._adapter = adapter
User.objects = ModelManager(User)

# CREATE - Basic save
user = User(
    username='alice',
    email='alice@example.com',
    age=25,
    is_active=True,
    balance=Money(Decimal('100.00'), 'USD')
)
await user.save()

# BULK CREATE - 10-100x faster than loops
users_list = [
    User(username=f'user{i}', email=f'user{i}@example.com',
         age=20+i, is_active=True, balance=Money(Decimal('50.00'), 'USD'))
    for i in range(100)
]
created = await User.objects.bulk_create(users_list)  # Single INSERT

# READ - Django-style queries
all_users = await User.objects.all()
active_users = await User.objects.filter(is_active=True)
adults = await User.objects.filter(age__gte=18)

# Field lookups (17+ types)
gmail_users = await User.objects.filter(email__icontains='gmail.com')
rich_users = await User.objects.filter(balance__gt=Money(Decimal('1000'), 'USD'))
young_adults = await User.objects.filter(age__in=[18, 19, 20, 21])

# Q Objects - Complex OR/AND/NOT queries
results = await User.objects.filter(
    Q(username='alice') | Q(email='bob@example.com')
)

complex_query = await User.objects.filter(
    Q(is_active=True) & (Q(age__gte=25) | Q(balance__gte=Money(Decimal('500'), 'USD')))
)

not_query = await User.objects.filter(~Q(is_active=False))

# Method chaining with ordering and limits
top_users = await User.objects.filter(
    is_active=True
).exclude(
    age__lt=18
).order_by('-balance', 'username').limit(10)

# Aggregation
count = await User.objects.filter(is_active=True).count()
exists = await User.objects.filter(username='alice').exists()
first_user = await User.objects.filter(is_active=True).first()

# UPDATE - Instance update
user.balance = Money(Decimal('150.00'), 'USD')
await user.save()

# BULK UPDATE - Efficient batch updates
users_to_update = await User.objects.filter(age__lt=21)
for user in users_to_update:
    user.is_active = False
await User.objects.bulk_update(users_to_update, fields=['is_active'])

# DELETE
await user.delete()

# Security features built-in:
# - Automatic SQL injection prevention
# - LIKE pattern escaping
# - DoS protection (DEFAULT_MAX_QUERY_LIMIT=10000)
# - Parameterized queries throughout
```

### REST API with Validation

```python
from pydantic import BaseModel, EmailStr, Field

class CreateUserRequest(BaseModel):
    name: str = Field(..., min_length=1, max_length=100)
    email: EmailStr
    age: int = Field(..., ge=0, le=150)

@app.route("/api/users", methods=["POST"])
async def create_user(request):
    data = await request.json()

    # Validate with Pydantic
    user_data = CreateUserRequest(**data)

    # Save to database
    user = await User.create(**user_data.dict())

    return {"id": user.id, "email": user.email}
```

### JWT Authentication

```python
from covet.security.jwt_auth import JWTAuthenticator, JWTConfig, TokenType

# Setup JWT
jwt_config = JWTConfig(
    secret_key='your-secret-key-min-32-chars',
    algorithm='HS256',
    access_token_expire_minutes=30
)
jwt_auth = JWTAuthenticator(jwt_config)

# Login endpoint
@app.route("/login", methods=["POST"])
async def login(request):
    data = await request.json()

    # Verify credentials (your logic)
    user_id = "user_123"

    # Create access token
    token = jwt_auth.create_token(user_id, TokenType.ACCESS)

    return {
        "access_token": token,
        "token_type": "bearer"
    }

# Protected route
@app.route("/profile")
async def profile(request):
    auth_header = request.headers.get("Authorization")
    token = auth_header.split(" ")[1]

    claims = jwt_auth.verify_token(token)
    user_id = claims['sub']

    return {"user_id": user_id}
```

### WebSocket Real-Time Communication

```python
from covet.websocket import WebSocketManager

ws_manager = WebSocketManager()

@app.websocket("/ws/chat/{room_id}")
async def chat_room(websocket, room_id: str):
    await ws_manager.connect(websocket, room_id)

    try:
        while True:
            message = await websocket.receive_json()
            await ws_manager.broadcast(room_id, message)
    except:
        await ws_manager.disconnect(websocket, room_id)
```

### GraphQL API

```python
from covet.api.graphql import GraphQLHandler
import strawberry

@strawberry.type
class User:
    id: int
    name: str
    email: str

@strawberry.type
class Query:
    @strawberry.field
    def users(self) -> list[User]:
        return [
            User(id=1, name="Alice", email="alice@example.com"),
            User(id=2, name="Bob", email="bob@example.com")
        ]

schema = strawberry.Schema(query=Query)

@app.route("/graphql", methods=["POST", "GET"])
async def graphql_endpoint(request):
    handler = GraphQLHandler(schema)
    return await handler.handle(request)
```

---

## 🎯 Performance

### Rust-Optimized Components

CovetPy includes Rust-optimized components that deliver measurable performance improvements:

**Benchmark Results:**
- Pure Python: 1,395 requests/sec
- Rust-Optimized: 1,576 requests/sec
- **Improvement: +13% throughput**

The Rust optimization is **enabled by default** - you get the performance boost automatically!

```python
from covet.core.fast_processor import ASGIApplication

# Rust optimization enabled by default
app = ASGIApplication()  # 13% faster

# Or disable for debugging
app = ASGIApplication(enable_rust=False)
```

---

## 🔧 System Requirements

- **Python:** 3.9, 3.10, 3.11, or 3.12
- **Operating Systems:** Linux, macOS, Windows
- **RAM:** Minimum 512MB, recommended 2GB
- **Disk:** 200MB for package + dependencies

---

## 📚 Feature Matrix

| Feature | Included | Install Extra |
|---------|----------|---------------|
| Core HTTP/ASGI | ✅ Always | - |
| Routing & Middleware | ✅ Always | - |
| Database (SQLite) | ✅ Always | - |
| PostgreSQL Support | ⚙️ Optional | `[database]` |
| MySQL Support | ⚙️ Optional | `[database]` |
| ORM with Migrations | ⚙️ Optional | `[orm]` |
| JWT Authentication | ⚙️ Optional | `[security]` |
| Password Hashing | ⚙️ Optional | `[security]` |
| MFA/TOTP | ⚙️ Optional | `[security]` |
| REST API | ⚙️ Optional | `[web]` |
| GraphQL | ⚙️ Optional | `[graphql]` |
| WebSocket | ✅ Always | - |
| Caching (Redis) | ⚙️ Optional | `[production]` |
| Monitoring | ⚙️ Optional | `[monitoring]` |
| Rust Optimization | ✅ Always | - |

---

## 🚀 Production Deployment

### Running with Uvicorn

```bash
# Install production dependencies
pip install covet[production]

# Run with Uvicorn
uvicorn app:app --host 0.0.0.0 --port 8000 --workers 4

# Or with Gunicorn + Uvicorn workers
gunicorn app:app -w 4 -k uvicorn.workers.UvicornWorker
```

### Docker Deployment

```dockerfile
FROM python:3.11-slim

WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application
COPY . .

# Run application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
```

### Database Examples

**SQLite (Zero Configuration):**
```python
from covet.database import SQLiteAdapter

adapter = SQLiteAdapter(database_path='app.db')
```

**PostgreSQL:**
```python
from covet.database import PostgreSQLAdapter

adapter = PostgreSQLAdapter(
    host='localhost',
    port=5432,
    database='myapp',
    user='postgres',
    password='secret'
)
```

**MySQL:**
```python
from covet.database import MySQLAdapter

adapter = MySQLAdapter(
    host='localhost',
    port=3306,
    database='myapp',
    user='root',
    password='secret'
)
```

---

## ⚙️ Configuration

### Environment Variables

```python
import os
from dotenv import load_dotenv

load_dotenv()

DATABASE_URL = os.getenv('DATABASE_URL')
JWT_SECRET = os.getenv('JWT_SECRET_KEY')
REDIS_URL = os.getenv('REDIS_URL')
DEBUG = os.getenv('DEBUG', 'False') == 'True'
```

### Application Configuration

```python
from covet import CovetPy
from covet.config import Config

config = Config(
    debug=False,
    host='0.0.0.0',
    port=8000,
    database_url='postgresql://user:pass@localhost/myapp',
    jwt_secret='your-secret-key',
    redis_url='redis://localhost:6379/0'
)

app = CovetPy(config=config)
```

---

## 🔒 Security Features

- **JWT Authentication:** Secure token-based auth with expiration
- **Password Hashing:** Bcrypt-based secure password storage
- **MFA/TOTP:** Two-factor authentication support
- **Input Validation:** Pydantic-powered request validation
- **CORS Middleware:** Configurable cross-origin resource sharing
- **Rate Limiting:** Protect against abuse and DDoS
- **SQL Injection Protection:** Parameterized queries
- **XSS Protection:** HTML sanitization

---

## 📊 Monitoring & Observability

```python
from covet.monitoring import MetricsCollector
from covet.monitoring.prometheus_exporter import PrometheusExporter

# Setup metrics
metrics = MetricsCollector()
exporter = PrometheusExporter(metrics)

# Metrics endpoint
@app.route("/metrics")
async def metrics_endpoint(request):
    return exporter.export()
```

---

## 🐛 Troubleshooting

### Common Issues

**Import Error:**
```bash
# Solution: Install package
pip install covet[full]
```

**Database Connection Error:**
```python
# Check connection parameters
adapter = PostgreSQLAdapter(
    host='localhost',  # Correct host?
    port=5432,        # Correct port?
    database='myapp', # Database exists?
    user='postgres',  # Valid user?
    password='secret' # Correct password?
)
```

**Rust Extensions Not Loading:**
```python
# Fallback to pure Python (works fine, slightly slower)
from covet import CovetPy
app = CovetPy()  # Automatically falls back if Rust unavailable
```

---

## 📄 License

**Proprietary License**

Copyright © 2025 Vipin Kumar. All rights reserved.

This software is proprietary and confidential. Unauthorized copying, distribution, or use is strictly prohibited.

---

## 👤 Author

**Vipin Kumar**
- GitHub: https://github.com/vipin08
- Documentation: https://github.com/vipin08/Covet-doc

---

## 🎯 Use Cases

**Perfect For:**
- High-performance REST APIs
- Real-time applications with WebSockets
- GraphQL backends
- Microservices architecture
- Full-stack web applications
- Data-intensive applications
- Enterprise backends

**Key Benefits:**
- Fast development with intuitive API
- Production-ready performance
- Comprehensive feature set
- Type-safe development
- Flexible deployment options

---

## 🚀 Get Started Now

```bash
# Install CovetPy
pip install covet[full]

# Create your first app
cat > app.py <<EOF
from covet import CovetPy

app = CovetPy()

@app.route("/")
async def hello(request):
    return {"message": "Hello, CovetPy!"}

if __name__ == "__main__":
    app.run()
EOF

# Run it
python app.py
```

Visit http://localhost:8000 and start building!

---

**CovetPy - Build fast, scalable Python applications with Rust-powered performance.**

**Version:** 0.1.0b3 (Beta)
**Status:** Production-Ready Core, Beta Features
