Версия: 2.0.0
Дата: 2025-11-10
# Init project
cifra init <project-name> --template crm
# Generate code
cifra generate <config.cifra>
# Run application
cifra run <config.cifra> --port 8000 --reload
# Migrations
cifra migrate up
cifra migrate down
cifra migrate create "add user table"
# Database
cifra db create
cifra db seed
cifra db backup
# Export/Import
cifra export Contact --format csv
cifra import contacts.csv --entity Contact
# Hub
cifra hub search payment
cifra hub install stripe-integration
# Deploy
cifra deploy production --provider aws
# Test
cifra test --coverage
project/
├── backend/
│ ├── models.py # SQLAlchemy models
│ ├── schemas.py # Pydantic schemas
│ ├── api.py # FastAPI routes
│ └── crud.py # CRUD operations
│
├── frontend/
│ ├── components/ # React/Vue components
│ ├── pages/ # Pages
│ └── api/ # API client
│
└── migrations/ # Alembic migrations
# Generated API
@app.get("/api/contacts")
async def list_contacts(
skip: int = 0,
limit: int = 100,
db: Session = Depends(get_db)
):
contacts = await Contact.list(db, skip=skip, limit=limit)
return contacts
from cifra.fields import BaseField
class IPAddressField(BaseField):
def validate(self, value):
# Validate IP address format
...
def to_db_type(self):
return String(15)
from cifra.validators import Validator
class CustomValidator(Validator):
def validate(self, value, entity):
if not self.is_valid(value):
raise ValueError("Invalid value")
Преимущества:
- ✅ Async support
- ✅ Auto-documentation (OpenAPI)
- ✅ Type hints (Pydantic)
- ✅ High performance
- ✅ Modern Python (3.11+)
vs Django:
- FastAPI: 20,000 req/s
- Django: 2,000 req/s
- 10x faster!
import pytest
from cifra.testing import TestClient
@pytest.fixture
def client():
return TestClient(app)
def test_create_contact(client):
response = client.post("/api/contacts", json={
"name": "John Doe",
"email": "john@example.com"
})
assert response.status_code == 201
Следующий документ: DEPLOYMENT.md →