Skip to main content

自動產生 CRUD API 的 Python 函式庫

Project description

AutoCRUD

Model-driven backend platform for FastAPI

AutoCRUD automatically generates REST APIs, GraphQL APIs, search, version history, and admin UI from Python models.

Focus on business logic, not infrastructure.

⭐ If you find this project useful, consider giving it a star.


Why AutoCRUD

Modern backend development repeatedly rebuilds the same infrastructure:

  • CRUD APIs
  • validation
  • search and filtering
  • version history
  • permissions
  • background jobs
  • admin tools

Most of this code is not business logic.

AutoCRUD eliminates this repetition by using a model-driven architecture.

Define your model once, and the framework generates the rest.


Example

Define a resource model:

from msgspec import Struct

class User(Struct):
    name: str
    email: str

Register the model:

from fastapi import FastAPI
from autocrud import crud

app = FastAPI()

crud.add_model(User)
crud.apply(app)

Start the server:

uvicorn main:app

Optional startup tuning:

export AUTOCRUD_DEFAULT_QUERY_LIMIT=1000

This controls the default page size for list endpoints. Per-request limit still overrides it.

You now automatically get:

POST   /users
GET    /users
GET    /users/{id}
PUT    /users/{id}
PATCH  /users/{id}
DELETE /users/{id}

OpenAPI documentation is generated automatically.


Architecture

graph TD

FastAPI --> AutoCRUD
AutoCRUD --> ResourceManager
ResourceManager --> Storage

Storage --> MetaStore
Storage --> RevisionStore
Storage --> BlobStore

AutoCRUD --> REST_API
AutoCRUD --> GraphQL_API
AutoCRUD --> UI_Generator

Core Features

Model-driven APIs

AutoCRUD generates APIs directly from Python models.

Model
  ↓
REST API
GraphQL API
OpenAPI

Versioned resources

Every resource maintains immutable revision history.

Resource
 ├── r1
 ├── r2
 └── r3

Advantages:

  • audit history
  • rollback
  • draft workflows
  • debugging

Built-in search

Search operates on indexed metadata instead of scanning full resource payloads.

QueryBuilder
   ↓
ResourceManager.search()
   ↓
MetaStore.search()

Background jobs

Jobs are modeled as resources.

create()
  ↓
message_queue.put(resource_id)

Workers process jobs through:

ResourceManager.start_consume()

Storage abstraction

AutoCRUD supports multiple storage backends.

Backend Meta Revision Blob
Memory memory memory memory
Disk SQLite files filesystem
S3 SQLite S3 S3
Postgres PostgreSQL S3 S3

You can also implement custom storage systems.


UI generation

AutoCRUD can generate a web interface directly from the API.

API
 ↓
UI generator
 ↓
admin dashboard

This allows rapid creation of internal tools.


Comparison

Feature AutoCRUD Hasura Django
REST API
GraphQL ⚠️
Version history
Search engine SQL ORM
Storage pluggable PostgreSQL relational
Background jobs built-in external external
UI generation console admin

Quickstart

Install:

pip install autocrud

Run your app:

uvicorn main:app

Open:

http://localhost:8000/docs

Documentation

Full documentation:

https://hychou0515.github.io/autocrud/


Example use cases

AutoCRUD works well for:

  • internal tools
  • content systems
  • configuration management
  • job processing systems
  • administrative APIs
  • workflow management systems

License

MIT

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

autocrud-0.9.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

autocrud-0.9.0-py3-none-any.whl (314.9 kB view details)

Uploaded Python 3

File details

Details for the file autocrud-0.9.0.tar.gz.

File metadata

  • Download URL: autocrud-0.9.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for autocrud-0.9.0.tar.gz
Algorithm Hash digest
SHA256 82a5a02e19c82983b705996257693f8e245ea4f0d7dbe2dfd41530f8b7ee25c7
MD5 dd6fa8454e6538225a5132b6138a114d
BLAKE2b-256 b10e8c2d31d3b0619e82715fe1e276bb573a6893b30da0ebf71d02e5f63d2283

See more details on using hashes here.

File details

Details for the file autocrud-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: autocrud-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 314.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for autocrud-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d372992f73b441b19effdff9e07bdc944dc38e4119e2e630cf71bb64d803bfba
MD5 da69e8d9cd3b75209543b089ec74ed72
BLAKE2b-256 2889762065cbb73680789e9542c8cb6da22488568929c594dc3d5abf227e796b

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