Skip to main content

High-performance Python framework built directly on uvicorn with built-in database models, migrations, and background tasks. Django that was built async-first.

Project description

NeutronAPI

High-performance Python framework built directly on uvicorn with built-in database models, migrations, and background tasks. If you want Django that was built async-first, this is for you.

Batteries included async API framework with command-line management.

Installation

pip install neutronapi

Quick Start

# 1. Create project
neutronapi startproject blog
cd blog

# 2. Create an app
python manage.py startapp posts

# 3. Start server  
python manage.py start               # Dev mode (auto-reload)

# 4. Test
python manage.py test

Getting Started Tutorial

1. Create Project

neutronapi startproject blog
cd blog

2. Create App Module

python manage.py startapp posts

3. Configure in apps/settings.py

import os

# ASGI application entry point (required for server)
ENTRY = "apps.entry:app"  # module:variable format

# Database
DATABASES = {
    'default': {
        'ENGINE': 'aiosqlite',
        'NAME': 'db.sqlite3',
    }
}

4. Create API in apps/posts/api.py

from neutronapi.base import API

class PostAPI(API):
    name = "posts"
    
    @API.endpoint("/posts", methods=["GET"])
    async def list_posts(self, scope, receive, send, **kwargs):
        posts = [{"id": 1, "title": "Hello World"}]
        return await self.response(posts)
    
    @API.endpoint("/posts", methods=["POST"])
    async def create_post(self, scope, receive, send, **kwargs):
        # Get request data from scope["body"]
        return await self.response({"id": 2, "title": "New Post"})

5. Register API in apps/entry.py

from neutronapi.application import Application
from apps.posts.api import PostAPI

app = Application({
    "posts": PostAPI()
})

6. Start Server

python manage.py start
# Visit: http://127.0.0.1:8000/posts

Project Structure

myproject/
├── manage.py           # Management commands
├── apps/
│   ├── __init__.py
│   ├── settings.py     # Configuration 
│   └── entry.py        # ASGI application
└── db.sqlite3          # Database

Background Tasks

from neutronapi.background import Task, TaskFrequency

class CleanupTask(Task):
    name = "cleanup"
    frequency = TaskFrequency.MINUTELY
    
    async def run(self, **kwargs):
        print("Cleaning up logs...")

# Add to application
app = Application(
    apis={"ping": PingAPI()},
    tasks={"cleanup": CleanupTask()}
)

Database Models

from neutronapi.db.models import Model
from neutronapi.db.fields import CharField, IntegerField, DateTimeField

class User(Model):
    name = CharField(max_length=100)
    age = IntegerField()
    created_at = DateTimeField(auto_now_add=True)

Server Commands

# Development (auto-reload, localhost)
python manage.py start

# Production (multi-worker, optimized)  
python manage.py start --production

# Custom configuration
python manage.py start --host 0.0.0.0 --port 8080 --workers 4

Testing

# SQLite (default)
python manage.py test


# Specific tests
python manage.py test app.tests.test_models.TestUser.test_creation

Commands

python manage.py start              # Start server
python manage.py test               # Run tests  
python manage.py migrate            # Run migrations
python manage.py startapp posts     # Create new app

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neutronapi-0.1.1.tar.gz (76.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neutronapi-0.1.1-py3-none-any.whl (88.3 kB view details)

Uploaded Python 3

File details

Details for the file neutronapi-0.1.1.tar.gz.

File metadata

  • Download URL: neutronapi-0.1.1.tar.gz
  • Upload date:
  • Size: 76.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for neutronapi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ba67aac8f49888b16a97883c279edc264ee74c330b2c3dca06ce7184d770d9e2
MD5 82816d6ad9cf2f7fcd28f787d4e90a82
BLAKE2b-256 e9adf8e0d47e7953122941effee911347896ca5d11088b76158fe44f362008f5

See more details on using hashes here.

File details

Details for the file neutronapi-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: neutronapi-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 88.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for neutronapi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a728fe9face89dd8121bc73143d2ccdec1af6617cf39560c1932bfe20dfada5d
MD5 95973b40ad0c3f5f997ab9def9bb9f2a
BLAKE2b-256 fdddb9007265c168b8ab577fe994056220050a83aca4efa9388f920e626ca520

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page