Lila Framework
A Python web framework built on Starlette and Pydantic, designed for simplicity, flexibility, and high performance.
Lila is a lightweight yet powerful Python web framework that combines the async capabilities of Starlette with the data validation power of Pydantic. It provides everything you need to build modern web applications and REST APIs with minimal boilerplate.
🚀 Getting Started
Install Lila via pip
and initialize your project with the CLI:
pip install lila-framework
lila-init
python main.py
📁 Project Structure
The lila-init
command scaffolds your entire project structure:
- 📂 app/routes/ — Route definitions for your application and API endpoints
- 📂 app/models/ — SQLAlchemy models for database tables
- 📂 core/middleware.py — Core middleware functions for authentication, logging, and security
- 📂 core/ — Framework core logic (routing, templates, session, auth, files, security, etc.)
- 📂 app/locales/ — Translation files for internationalization (i18n)
- 📄 app/connections.py — Database connection configuration (SQLite, MySQL, PostgreSQL)
- 📄 app/config.py — Application settings and environment configuration
- 📂 templates/ — Jinja2 templates for server-side rendering
- 📂 public/ — Static files (CSS, JS, images)
- 🐍 main.py — Application entry point
- 🔒 .env — Environment variables (HOST, PORT, DEBUG, SECRET_KEY)
✨ Core Features
- 🛤️ Routing — Define routes with HTTP method support, path parameters, and Pydantic validation
- 🎨 Templates — Server-side rendering with Jinja2, including Markdown support
- 🔐 Sessions — Secure signed sessions using
itsdangerous - 🛡️ Middlewares — Built-in authentication (
login_required,session_active,validate_token) and a security middleware that blocks malicious IPs, URLs, and sensitive paths - 🗄️ Models & ORM — SQLAlchemy integration with automatic model generation via CLI
- 📦 Migrations — One-command database migrations with
lila-migrations - ⚡ REST API CRUD — Auto-generate fully documented REST APIs with Swagger/OpenAPI, including Pydantic validation and customizable middlewares
- 📤 File Uploads — Built-in helper with validation, size limits, and secure filenames
- 🌍 Internationalization — JSON-based translations with per-route language forcing
- ⚛️ React Islands — Embed interactive React components in Jinja2 templates with Vite HMR support
- 👤 Admin Panel — Auto-generated admin dashboard with model management, system metrics, and log viewer
- 🔧 CLI Tools — Scaffold models, auth systems, CRUD pages, admin panels, and minify assets
- 🏗️ Production Ready — Systemd service deployment, asset minification, and environment configuration
🖥️ CLI Commands
All CLI commands follow the pattern lila-{command}:
- 🚀
lila-init— Initialize a new Lila project - 📦
lila-model— Generate SQLAlchemy models with CRUD methods - 🗄️
lila-migrations— Run database migrations - 🔐
lila-auth— Scaffold authentication (login, register, password reset) - 🏗️
lila-scaffold-crud— Generate complete CRUD from a model - 👤
lila-create-panel-admin— Create admin panel with dashboard - 🔑
lila-create-admin— Create an admin user - ⚛️
lila-react— Setup React Islands integration - ⚡
lila-minify— Minify CSS and JS files for production
📚 Documentation
Explore each section in the sidebar to learn about every feature in detail. Start with Installation to set up your first project.