Skip to content

broodwork/raystack

Repository files navigation

πŸš€ Raystack: Where FastAPI Speed Meets Django Elegance

PyPI Version Python Versions Python 3.6+ License Downloads

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!

✨ Why Choose Raystack?

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.

🌟 Key Features

  • 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.

⚑ Quick Start

Get your project up and running in minutes!

1. Install Raystack

pip install raystack

2. Create a New Project

raystack startproject myproject
cd myproject

3. Run the Development Server

raystack runserver

Open your browser and navigate to: http://127.0.0.1:8000

πŸ—οΈ Project Structure

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];
Loading

🌐 URL-Based Async/Sync Mode Detection

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.

How It Works:

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
    }
}

Supported Drivers:

Synchronous:

  • SQLite: sqlite:///db.sqlite3
  • PostgreSQL: postgresql://user:pass@localhost/dbname
  • MySQL: mysql://user:pass@localhost/dbname

Asynchronous:

  • SQLite: sqlite+aiosqlite:///db.sqlite3 (requires aiosqlite)
  • PostgreSQL: postgresql+asyncpg://user:pass@localhost/dbname (requires asyncpg)
  • MySQL: mysql+aiomysql://user:pass@localhost/dbname (requires aiomysql)

Benefits:

  • βœ… 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.

πŸ› οΈ ORM Usage Examples

Raystack's ORM automatically detects the mode based on your database configuration and adapts accordingly. No need for separate sync/async methods!

Basic CRUD Operations

# 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()

πŸ–ΌοΈ Screenshots

Home Page: Home Page

Login Page: Login Page

Admin Panel: Admin Page

πŸ“š Documentation

🀝 Contributing

Pull requests and issues are welcome! See GitHub.

πŸ“œ License

MIT License. See LICENSE for details.

About

πŸš€ Raystack: Where FastAPI Speed Meets Django Elegance

Resources

License

Stars

Watchers

Forks

Packages

No packages published