Spec-driven backend platform for FastAPI
Generate REST APIs, GraphQL, search, version history, and an admin UI from a single Python model.
Renamed from
autocrudtospecstar(v0.10.0). The old name still installs as a deprecation shim that redirects everyautocrud[.X]import tospecstar[.X]. New projects shouldpip install specstar. See the migration guide.
v0.11 adds spec-driven authoring (additive, zero breaking changes). Edit a single
spec.mdin prose; a Claude Code skill or thespecstar genCLI translates it into the declarative Python the engine consumes. See the Spec-Driven Authoring guide and the v0.11 upgrade notes.
Focus on business logic, not infrastructure.
⭐ If you find this project useful, consider giving it a star.
Why SpecStar
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.
SpecStar eliminates this repetition by using a spec-driven architecture.
Define your model once, and the framework generates the rest.
What sets SpecStar apart
Most "model → API" generators stop at routes. SpecStar treats every resource as a versioned timeline by default: updates create revisions, history stays queryable, and rollback is built in. Don't need history? Ignore it — the same routes work as plain CRUD.
Example
Define a resource model:
from msgspec import Struct
class User(Struct):
name: str
email: str
Register the model:
from fastapi import FastAPI
from specstar import spec
app = FastAPI()
spec.add_model(User)
spec.apply(app)
spec.add_model(User)is shorthand forspec.add_model(Schema(User))— the canonical form once you start tracking schema versions or migrations isspec.add_model(Schema(User, "v1")), which the quickstart docs use. Both run; pick whichever fits your stage.
Start the server:
uvicorn main:app
Optional startup tuning:
export SPECSTAR_DEFAULT_QUERY_LIMIT=1000
This controls the default page size for list endpoints (GET /{model} and
search routes). The built-in fallback is 2**32 - 1 (effectively unlimited)
— pick a sane value for production. Per-request limit and offset query
params still override it.
You now automatically get:
POST /user
GET /user
GET /user/{resource_id}
PUT /user/{resource_id}
PATCH /user/{resource_id}
DELETE /user/{resource_id}
The path segment follows model_naming (default: kebab-case of the model name,
e.g. User -> /user). PUT replaces the whole resource; PATCH expects a
JSON Patch (RFC 6902) array of operations rather than a partial object.
OpenAPI documentation is generated automatically.
Architecture
graph TD
FastAPI --> SpecStar
SpecStar --> ResourceManager
ResourceManager --> Storage
Storage --> MetaStore
Storage --> RevisionStore
Storage --> BlobStore
SpecStar --> REST_API
SpecStar --> GraphQL_API
SpecStar --> UI_Generator
Core Features
Spec-driven APIs
SpecStar generates APIs directly from Python models.
Model
↓
REST API
GraphQL API (opt-in: pip install specstar[graphql] + add_route_template(GraphQLRouteTemplate()))
OpenAPI
REST and OpenAPI are wired up automatically when you call
spec.apply(app). GraphQL is opt-in: install the extra (pip install specstar[graphql]) and register the template explicitly:from specstar import spec from specstar.crud.route_templates.graphql import GraphQLRouteTemplate spec.add_route_template(GraphQLRouteTemplate())
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
SpecStar supports multiple storage backends.
| Backend | Meta | Revision | Blob |
|---|---|---|---|
| Memory | memory | memory | memory |
| Disk | SQLite | files | filesystem |
| S3 | SQLite | S3 | S3 |
| Postgres | PostgreSQL | S3 | S3 |
The rows above are typical profiles, not the only valid combinations. The
three storage layers (IMetaStore / IResourceStore / IBlobStore) are
independent — for example, a Postgres resource_store exists
(resource_data table with data BYTEA), so you can keep revision payloads
in Postgres instead of S3 if that fits your deployment. You can also implement
custom storage systems.
UI generation
SpecStar can generate a web interface directly from the API.
API
↓
UI generator
↓
admin dashboard
This allows rapid creation of internal tools.
Comparison
| Feature | SpecStar | 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 specstar
Spec-driven (v0.11+) — bootstrap a starter project, then describe resources in prose:
specstar init my_app
# edit spec.md, then in Claude Code:
/specstar regen
# CI-friendly drift check (no LLM):
specstar verify
See the Spec-Driven Authoring guide for the full workflow.
Classic Python — register models directly:
Run your app:
uvicorn main:app
Open:
http://localhost:8000/docs
Documentation
Full documentation:
https://hychou0515.github.io/specstar/
Example use cases
SpecStar works well for:
- internal tools
- content systems
- configuration management
- job processing systems
- administrative APIs
- workflow management systems
License
MIT
Metadata
Release files for specstar 0.12.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| specstar-0.12.3.tar.gz | 4.7 MB | Without provenance | Details for specstar-0.12.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| specstar-0.12.3-py3-none-any.whl | Python 3 | none | any | Details for specstar-0.12.3-py3-none-any.whl |
Total release size: 5.2 MB
Release files / specstar-0.12.3.tar.gz
| Download URL | specstar-0.12.3.tar.gz |
|---|---|
| Size | 4.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ccf8288c10cd1daff3730a521dd44e5e7c2eb54ebffc9e4ce654697d765d2f70
|
|
BLAKE2b-256 checksum How to use checksums |
6e0d56feca074d0e948f5d9226f893172dbee1ad91f0eef800fae8659adbef00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / specstar-0.12.3-py3-none-any.whl
| Download URL | specstar-0.12.3-py3-none-any.whl |
|---|---|
| Size | 501.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
518b2456c290dc54b25f5e33ac61633655fcd822ad7dac8aee153c854a2bc336
|
|
BLAKE2b-256 checksum How to use checksums |
13c5f627283302335d00b3e6c5c8cbaccbf6b0061a38ea595c1c5fe72dd31943
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for specstar 0.12.3
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.