Raystack is a modern, high-performance Python web framework that merges the asynchronous power of FastAPI with the battle-tested structure and development convenience inspired by Django. Forget the compromises between speed and ease of development β with Raystack, you get the best of both worlds!
Do you love FastAPI's speed but miss Django's organized project structure? Do you want a powerful ORM with built-in async support and a familiar admin panel? Raystack is built for you! It's ideal for:
- High-Performance APIs and Microservices: Leverage FastAPI's capabilities for blazing-fast and concurrent request handling.
- Rapid Development of Full-Featured Web Applications: Benefit from a ready-to-use project structure, templating, admin panel, and CLI tools.
- Developers Transitioning from Django: Get up to speed instantly with familiar "app" concepts, ORM, and management commands.
- Projects Requiring a Flexible and Robust ORM: SQLAlchemy under the hood gives you full control over your database.
- FastAPI at its Core: Experience incredible speed and asynchronous performance for your web applications.
- Django-Inspired Project Structure: Organize your project with "apps" for clean, modular, and maintainable code.
- Universal SQLAlchemy ORM: A powerful and flexible ORM with a unified API for both synchronous and asynchronous operations.
- Smart Database Management (Alembic): Seamless database migrations for effortless schema evolution.
- Jinja2 Templating: A robust and flexible templating engine for dynamic HTML rendering.
- Built-in Admin Panel: A ready-to-use, customizable administrative interface for easy data management.
- Convenient CLI Commands: Create projects and apps, run the server, manage migrations, and moreβall from your command line.
- Async-First Design: Full support for asynchronous views and database operations with minimal effort.
- Multi-Database Support: Connect to SQLite, PostgreSQL, MySQL, and other databases with easy switching between sync and async drivers.
- Extensible Architecture: Easily integrate your own apps, middleware, and commands to tailor the framework to your needs.
Get your project up and running in minutes!
pip install raystack
raystack startproject myproject
cd myproject
raystack runserver
Open your browser and navigate to: http://127.0.0.1:8000
Raystack offers a clear and modular project structure, inspired by Django:
graph TD
A[Raystack Project] --> B[myproject/];
B --> C[apps/];
C --> D[home/];
D --> D1[models.py];
D --> D2[views.py];
D --> D3[urls.py];
D --> D4[admin.py];
B --> E[config/];
E --> E1[settings.py];
E --> E2[urls.py];
B --> F[core/];
F --> F1[__init__.py];
B --> G[templates/];
G --> G1[base.html];
G --> G2[home/];
B --> H[requirements.txt];
B --> I[README.md];
Raystack introduces a unique approach to database interaction, allowing you to explicitly control whether to use synchronous or asynchronous operations by simply specifying the appropriate driver in your database URL.
The mode is determined by the presence of async drivers in your database URL within your config/settings.py
file.
# Synchronous mode (default)
DATABASES = {
'default': {
'ENGINE': 'raystack.core.database.sqlalchemy',
'URL': 'sqlite:///db.sqlite3', # Sync mode
}
}
# Asynchronous mode
DATABASES = {
'default': {
'ENGINE': 'raystack.core.database.sqlalchemy',
'URL': 'sqlite+aiosqlite:///' + str(BASE_DIR / 'db.sqlite3'), # Async mode
}
}
Synchronous:
- SQLite:
sqlite:///db.sqlite3
- PostgreSQL:
postgresql://user:pass@localhost/dbname
- MySQL:
mysql://user:pass@localhost/dbname
Asynchronous:
- SQLite:
sqlite+aiosqlite:///db.sqlite3
(requiresaiosqlite
) - PostgreSQL:
postgresql+asyncpg://user:pass@localhost/dbname
(requiresasyncpg
) - MySQL:
mysql+aiomysql://user:pass@localhost/dbname
(requiresaiomysql
)
- β Explicit Control: You explicitly choose the mode in settings, not based on execution context.
- β Predictable Behavior: Database operations are always clear and predictable.
- β Framework Agnostic: Works consistently with FastAPI, Django, Flask, or any other framework.
- β Easy Switching: Simply change the URL to switch between sync and async modes.
- β Clear Intent: The URL clearly indicates whether you're using sync or async database drivers.
Raystack's ORM automatically detects the mode based on your database configuration and adapts accordingly. No need for separate sync/async methods!
# Create
article = await Article.objects.create(title="Hello", content="World", author_id=1)
# Get a single object
user = await UserModel.objects.get(id=1)
# Filter
users = await UserModel.objects.filter(age__gte=25).execute()
# Update
user.name = "Jane Doe"
await user.save()
# Delete
await user.delete()
# Count
count = await UserModel.objects.count()
# Check existence
exists = await UserModel.objects.filter(email="[email protected]").exists()
- Technical Documentation
- ORM Reference
- Template Reference
- Command Reference
- Middleware Reference
- Extending Raystack
- FAQ
Pull requests and issues are welcome! See GitHub.
MIT License. See LICENSE for details.