Storm is a Python framework inspired by NestJS, designed to build efficient, scalable, and maintainable server-side applications. With a focus on modularity, dependency injection, and an intuitive development experience, Storm empowers developers to create robust backend systems with ease.
- Modular Architecture: Organize your application into self-contained, reusable modules.
- Dependency Injection: Powerful DI container for clean and maintainable code.
- Decorators: Use Python decorators to define controllers, routes, services, and more.
- Asynchronous Support: Built-in support for async operations, enabling high-performance, non-blocking I/O.
- Middleware and Guards: Handle cross-cutting concerns and request validation with ease.
- CLI Tool: Quickly scaffold projects, generate modules, controllers, and services with the Storm CLI.
- ORM Integration: Seamlessly connect to databases using popular ORMs like SQLAlchemy or Tortoise ORM.
- Comprehensive Testing: Built-in utilities for unit and integration testing.
To install Storm, you can use pip:
pip install storm-framework
Use the Storm CLI to create a new project:
storm-cli new my-storm-app
cd my-storm-app
This will generate a basic project structure with everything you need to get started.
Once your project is set up, you can run the application:
python src/main.py
Modules are the building blocks of a Storm application. Each module is a self-contained unit that encapsulates related components such as controllers, services, and models.
Example:
from storm import Module
@Module({
'controllers': [AppController],
'providers': [AppService],
})
class AppModule:
pass
Controllers are responsible for handling incoming requests and returning responses to the client. Use decorators to define routes within controllers.
Example:
from storm import Controller, Get
@Controller('/app')
class AppController:
@Get('/')
async def get_app(self):
return {'message': 'Hello from Storm!'}
Services contain your business logic and can be injected into controllers or other services.
Example:
from storm import Injectable
@Injectable()
class AppService:
def get_message(self):
return 'This is a message from the service.'
Storm's DI system allows you to easily manage dependencies within your application. Simply annotate classes with @Injectable
and inject them where needed.
Example:
from storm import Injectable, Inject
@Injectable()
class AppService:
def get_message(self):
return 'Hello from Service!'
@Controller('/app')
class AppController:
def __init__(self, service: AppService):
self.service = service
@Get('/')
async def get_app(self):
return {'message': self.service.get_message()}
Middleware functions are executed before reaching the controllers, allowing you to handle tasks like authentication, logging, etc.
Example:
from storm import Middleware, Request, Next
class LoggerMiddleware(Middleware):
async def handle(self, request: Request, next: Next):
print(f'Incoming request: {request.method} {request.path}')
return await next(request)
Storm comes with a powerful CLI to streamline your development workflow:
- Create a new project:
storm new my-storm-app
- Generate a module:
storm generate module my-module
- Generate a controller:
storm generate controller my-controller
- Generate a service:
storm generate service my-service
Check out the examples directory for sample projects demonstrating different features of Storm.
Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines.
Storm is MIT licensed.