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.8.3.tar.gz (987.9 kB view details)

Uploaded Source

Built Distribution

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

autocrud-0.8.3-py3-none-any.whl (295.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for autocrud-0.8.3.tar.gz
Algorithm Hash digest
SHA256 73393ee5e9527680478320cc30ef7be3457c2cebfb992aadc3460ea121703a38
MD5 f50c60f93e14978206d63f2ae46a6a18
BLAKE2b-256 b5bbc03c5d22f4a260805b429f8c57bf0fb91a357311a245f5d2a251a4711f2b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: autocrud-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 295.4 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.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a7631139ec5263dfbf3ab6ed75e82906c8bc58a5aecb43588c98e35692e0eaad
MD5 a459868e3c44ad6500ce5c1d52d486cd
BLAKE2b-256 96b1d156f0bbab12b904aa2b89776a855a929207f7ecd138647b6ea86df9d585

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