β‘ Navigator Framework

A batteries-included async web framework built on aiohttp π
Navigator is a next-generation Python framework designed for building high-performance asynchronous APIs and web applications. Built on top of aiohttp and asyncio, it provides enterprise-grade features out of the box with a focus on developer productivity and application scalability.
β¨ Key Features
- β‘ Lightning Fast: Built on aiohttp + uvloop for maximum performance
- π Batteries Included: Authentication, WebSockets, templates, database connections, and more
- ποΈ Django-style Apps: Organize code with modular, reusable application components
- π Multi-tenant Ready: Built-in sub-domain support for SaaS applications
- π§ Centralized Config: Unified configuration management with NavConfig
- π Auto-Connections: Automatic database connection handling with AsyncDB
- π Class-based Views: Powerful CRUD operations with ModelViews
- π― Extensible: Plugin architecture for adding custom features
π Quick Start
Installation
uv add navigator-api[uvloop,locale]
pip install navigator-api[uvloop,locale]
Create Your First App
nav init
nav app create myapp
nav run --debug --reload
Hello Navigator
import asyncio
import uvloop
from navigator import Application
from aiohttp import web
async def hello(request):
return web.Response(text="Hello Navigator! π")
async def main():
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
app = Application(enable_jinja2=True)
app.router.add_get('/', hello)
app.add_websockets()
return app.setup()
if __name__ == '__main__':
asyncio.run(main())
ποΈ Architecture
Class-based Views
Navigator provides powerful class-based views for building APIs:
from navigator.views import BaseView, ModelView
from aiohttp import web
from datamodel import BaseModel
class UserView(BaseView):
async def get(self):
return web.json_response({"users": []})
async def post(self):
data = await self.request.json()
return web.json_response({"status": "created"})
class User(BaseModel):
name: str
email: str
age: int
class UserModelView(ModelView):
model = User
path = '/api/users'
Centralized Configuration
Navigator uses NavConfig for unified configuration management:
from navconfig import config
DATABASE_URL = config.get('DATABASE_URL', 'postgresql://user:pass@localhost/db')
REDIS_URL = config.get('REDIS_URL', 'redis://localhost:6379')
DEBUG = config.getboolean('DEBUG', False)
SECRET_KEY = config.get('SECRET_KEY', required=True)
ENV = config.get('ENV', 'development')
Django-style Applications
Organize your code with modular applications:
myproject/
βββ apps/
β βββ users/
β β βββ __init__.py
β β βββ views.py
β β βββ models.py
β β βββ urls.py
β β βββ templates/
β βββ products/
β βββ __init__.py
β βββ views.py
β βββ models.py
βββ settings/
β βββ settings.py
βββ main.py
from navigator.applications import AppConfig
class UsersConfig(AppConfig):
name = 'users'
path = '/api/users'
def ready(self):
pass
Database Integration
Navigator integrates seamlessly with AsyncDB for database operations:
from navigator.views import ModelView
from asyncdb.models import Model
class User(Model):
name: str
email: str
created_at: datetime
class Meta:
name = 'users'
schema = 'public'
class UserAPI(ModelView):
model = User
path = '/api/users'
async def validate_payload(self, data):
if 'email' not in data:
raise ValueError("Email is required")
return data
async def _post_callback(self, response, model):
pass
WebSocket Support
Real-time features with built-in WebSocket support:
from navigator import Application
from navigator.services.ws import WebSocketHandler
class ChatHandler(WebSocketHandler):
async def on_message(self, message):
await self.broadcast(message)
app = Application()
app.add_websockets()
app.router.add_websocket('/ws/chat', ChatHandler)
π Extensions
Navigator's extension system allows you to add powerful features:
Authentication Extension
from navigator_auth import AuthConfig
class MyApp(Application):
def configure(self):
self.add_extension(AuthConfig, {
'secret_key': 'your-secret-key',
'algorithm': 'HS256',
'token_expiration': 3600
})
Admin Interface
from navigator.admin import admin_site
from .models import User, Product
admin_site.register(User)
admin_site.register(Product)
app.include_router(admin_site.router, prefix='/admin')
π οΈ CLI Tools
Navigator includes powerful CLI tools for development:
nav init
nav app create myapp
nav run
nav shell
π¦ Available Extensions
Navigator supports various optional dependencies:
navigator-api[uvloop]
navigator-api[locale]
navigator-api[memcache]
navigator-api[gunicorn]
navigator-api[all]
π Deployment
AWS App Runner
Navigator includes built-in support for AWS App Runner deployment:
version: 1.0
runtime: python3
build:
commands:
build:
- pip install -r requirements.txt
- python setup.py build_ext --inplace
run:
runtime-version: '3.11'
command: 'nav run --port 8080'
network:
port: 8080
env: PORT
Docker
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
RUN python setup.py build_ext --inplace
EXPOSE 8000
CMD ["nav", "run", "--port", "8000"]
π Requirements
- Python: 3.9+ (3.11+ recommended)
- Dependencies:
- aiohttp >= 3.10.0
- asyncio (built-in)
- uvloop >= 0.21.0 (optional, recommended)
π§ͺ Testing
uv add --dev pytest pytest-asyncio coverage
pytest
pytest --cov=navigator tests/
π Documentation
π€ Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
git clone https://github.com/phenobarbital/navigator.git
cd navigator
uv venv --python 3.11 .venv
source .venv/bin/activate
uv sync --dev
pre-commit install
pytest
π License
Navigator is licensed under the BSD 3-Clause License. See LICENSE for details.
π Credits
Navigator is built on top of these amazing projects:
π Links
Made with β€οΈ by the Navigator team. Built for the async future of web development.