Skip to main content

App Boot

English | 中文翻译

AppBoot is a FastAPI project template designed to provide a Django-like structure and development experience.

Technology Stack

  • Python 3.9+
  • FastAPI
  • SQLAlchemy 2.0+
  • Pydantic
  • Uvicorn

Quick Start

Start a New Project

# Create the project directory
mkdir mysite
cd mysite
# Create a virtual environment to isolate our package dependencies locally
python3 -m venv env
source env/bin/activate  # On Windows use `env\\Scripts\\activate`
# Install appboot and aiosqlite into the virtual environment
pip install appboot aiosqlite
# Set up a new project with a single application
appboot startproject mysite .  # Note the trailing '.' character
# Start the server, application running on http://127.0.0.1:8000
python manage.py runserver

Start a New App 'polls'

python manage.py startapp polls

Create a Model

Define a Question model in polls/models.py.

from datetime import datetime
from sqlalchemy.orm import Mapped
from appboot import models

class Question(models.Model):
    question_text: Mapped[str]
    pub_date: Mapped[datetime]

Create a Schema

Define a QuestionSchema schema in polls/schema.py.

from appboot.schema import ModelSchema
from polls.models import Question

class QuestionSchema(ModelSchema):
    class Meta:
        model = Question

Write CRUD API

Write the CRUD API in polls/views.py.

from fastapi import APIRouter, Depends
from appboot.db import create_tables
from appboot.params import QuerySchema, QueryDepends, PaginationResult
from polls.models import Question
from polls.schema import QuestionSchema

router = APIRouter(dependencies=[Depends(create_tables)])

@router.post('/questions/', response_model=QuestionSchema)
async def create_question(question: QuestionSchema):
    return await question.create()

@router.get('/questions/', response_model=PaginationResult[QuestionSchema])
async def query_questions(query: QuerySchema = QueryDepends()):
    return await query.query_result(Question.objects.clone())

@router.get('/questions/{question_id}', response_model=QuestionSchema)
async def get_question(question_id: int):
    return await Question.objects.get(question_id)

@router.put('/questions/{question_id}', response_model=QuestionSchema)
async def update_question(question_id: int, question: QuestionSchema):
    instance = await Question.objects.get(question_id)
    return await question.update(instance)

@router.delete('/questions/{question_id}', response_model=QuestionSchema)
async def delete_question(question_id: int):
    instance = await Question.objects.get(question_id)
    return await instance.delete()

Configure API Routes

Wire up the API URLs in mysite/urls.py.

from fastapi import APIRouter
from polls.views import router

root_router = APIRouter()
root_router.include_router(router, prefix='/polls', tags=['polls'])

Testing Our API

python manage.py runserver

We can now access our API directly through the browser at http://127.0.0.1:8000/docs/. API Documentation

Create Complex Query Schema

Create a QuestionQuerySchema for complex queries in polls/schema.py.

from typing import Optional
from appboot.params import QuerySchema
from appboot.filters import EqField, ContainsField

class QuestionQuerySchema(QuerySchema):
    ids: Optional[list[int]] = EqField(None, alias='pk', columns='id')  # Query questions by ID list
    question_text: Optional[str] = ContainsField(None)  # Fuzzy query question_text

Replace QuerySchema with QuestionQuerySchema in polls/views.py, refresh the docs in the browser, and you will see two new query parameters in the query questions API. Complex Query Parameters

Try Out Examples

Go to Examples for more examples.

Metadata

Release files for appboot 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for appboot 0.3.5
File Size Uploaded Provenance Actions
appboot-0.3.5.tar.gz 24.5 kB Without provenance Details for appboot-0.3.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for appboot 0.3.5
File Interpreter ABI Platform Actions
appboot-0.3.5-py3-none-any.whl Python 3 none any Details for appboot-0.3.5-py3-none-any.whl

Total release size: 55.4 kB

Release files / appboot-0.3.5.tar.gz

Download URL appboot-0.3.5.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c994869e67943d5a72e297063a6c0b5c13634e4db2d56c8e150b6adbf8ab291f
BLAKE2b-256 checksum
How to use checksums
031892be81caebcc6926920982da91279b39874a7367679cab3b4ba08dc5853c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/24.5.0

Release files / appboot-0.3.5-py3-none-any.whl

Download URL appboot-0.3.5-py3-none-any.whl
Size 30.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
080906dd99234fa0e7314aab36452f90901221dc3e936dcfecd497eb35204eaa
BLAKE2b-256 checksum
How to use checksums
07d700afbef465d09d43dbe13cb8c443a954ebcc3a6d14d5b621584e022ee401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.6 Darwin/24.5.0

Security for appboot 0.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page