Metadata-Version: 2.4
Name: specstar
Version: 0.11.8
Summary: Spec-driven backend platform for FastAPI: REST + GraphQL + search + version history + admin UI from a single msgspec.Struct
Project-URL: Homepage, https://github.com/HYChou0515/specstar
Project-URL: Documentation, https://HYChou0515.github.io/specstar/
Project-URL: Repository, https://github.com/HYChou0515/specstar.git
Project-URL: Issues, https://github.com/HYChou0515/specstar/issues
Author-email: HYChou0515 <hychou.svm@example.com>
License: MIT License
        
        Copyright (c) 2025 HYChou0515
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: api,crud,fastapi,graphql,rest,spec-driven,versioning
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: fastapi<1,>=0.115
Requires-Dist: jsonpatch>=1.33
Requires-Dist: jsonpointer>=3.0.0
Requires-Dist: more-itertools>=10.7.0
Requires-Dist: msgpack>=1.1.1
Requires-Dist: msgspec>=0.19.0
Requires-Dist: pydantic<3,>=1.10.26
Requires-Dist: python-multipart>=0.0.22
Requires-Dist: qqabc>=0.2.1
Requires-Dist: xxhash>=3.5.0
Provides-Extra: all
Requires-Dist: boto3>=1.40.21; extra == 'all'
Requires-Dist: celery>=5.6.2; extra == 'all'
Requires-Dist: datamodel-code-generator[http]>=0.35.0; extra == 'all'
Requires-Dist: httpx>=0.28.1; extra == 'all'
Requires-Dist: oracledb>=3.4.2; extra == 'all'
Requires-Dist: pika>=1.3.2; extra == 'all'
Requires-Dist: psycopg2-binary>=2.9.10; extra == 'all'
Requires-Dist: pymysql>=1.1.2; extra == 'all'
Requires-Dist: python-magic>=0.4.27; extra == 'all'
Requires-Dist: redis>=6.4.0; extra == 'all'
Requires-Dist: sqlalchemy>=2.0.46; extra == 'all'
Requires-Dist: strawberry-graphql>=0.288.1; extra == 'all'
Requires-Dist: tenacity>=9.1.2; extra == 'all'
Requires-Dist: textual>=6.3.0; extra == 'all'
Requires-Dist: typer>=0.20.0; extra == 'all'
Provides-Extra: benchmark
Requires-Dist: matplotlib>=3.8; extra == 'benchmark'
Requires-Dist: pyyaml>=6.0; extra == 'benchmark'
Requires-Dist: rich>=13.0; extra == 'benchmark'
Provides-Extra: celery
Requires-Dist: celery>=5.6.2; extra == 'celery'
Provides-Extra: cli
Requires-Dist: datamodel-code-generator[http]>=0.35.0; extra == 'cli'
Requires-Dist: httpx>=0.28.1; extra == 'cli'
Requires-Dist: tenacity>=9.1.2; extra == 'cli'
Requires-Dist: textual>=6.3.0; extra == 'cli'
Requires-Dist: typer>=0.20.0; extra == 'cli'
Provides-Extra: dev
Requires-Dist: boto3>=1.40.21; extra == 'dev'
Requires-Dist: celery>=5.6.2; extra == 'dev'
Requires-Dist: coverage>=7.9.2; extra == 'dev'
Requires-Dist: datamodel-code-generator[http]>=0.35.0; extra == 'dev'
Requires-Dist: git-cliff>=2.0.0; extra == 'dev'
Requires-Dist: httpx>=0.28.1; extra == 'dev'
Requires-Dist: matplotlib>=3.8; extra == 'dev'
Requires-Dist: mkdocs-gen-files>=0.5.0; extra == 'dev'
Requires-Dist: mkdocs-literate-nav>=0.6.0; extra == 'dev'
Requires-Dist: mkdocs-material-extensions>=1.3.0; extra == 'dev'
Requires-Dist: mkdocs-material>=9.5.0; extra == 'dev'
Requires-Dist: mkdocs-section-index>=0.3.0; extra == 'dev'
Requires-Dist: mkdocs-static-i18n>=1.2.0; extra == 'dev'
Requires-Dist: mkdocs>=1.6.0; extra == 'dev'
Requires-Dist: mkdocstrings[python]>=0.26.0; extra == 'dev'
Requires-Dist: oracledb>=3.4.2; extra == 'dev'
Requires-Dist: pika>=1.3.2; extra == 'dev'
Requires-Dist: psycopg2-binary>=2.9.10; extra == 'dev'
Requires-Dist: pymdown-extensions>=10.0.0; extra == 'dev'
Requires-Dist: pymysql>=1.1.2; extra == 'dev'
Requires-Dist: pytest-asyncio>=1.1.0; extra == 'dev'
Requires-Dist: pytest-markdown-docs>=0.9.1; extra == 'dev'
Requires-Dist: pytest-rerunfailures>=15.0; extra == 'dev'
Requires-Dist: pytest>=8.4.1; extra == 'dev'
Requires-Dist: python-magic>=0.4.27; extra == 'dev'
Requires-Dist: pyyaml>=6.0; extra == 'dev'
Requires-Dist: redis>=6.4.0; extra == 'dev'
Requires-Dist: rich>=13.0; extra == 'dev'
Requires-Dist: ruff>=0.12.4; extra == 'dev'
Requires-Dist: sqlalchemy>=2.0.46; extra == 'dev'
Requires-Dist: strawberry-graphql>=0.288.1; extra == 'dev'
Requires-Dist: tenacity>=9.1.2; extra == 'dev'
Requires-Dist: textual>=6.3.0; extra == 'dev'
Requires-Dist: ty>=0.0.33; extra == 'dev'
Requires-Dist: typer>=0.20.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: boto3>=1.40.21; extra == 'docs'
Requires-Dist: mkdocs-gen-files>=0.5.0; extra == 'docs'
Requires-Dist: mkdocs-literate-nav>=0.6.0; extra == 'docs'
Requires-Dist: mkdocs-material-extensions>=1.3.0; extra == 'docs'
Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
Requires-Dist: mkdocs-section-index>=0.3.0; extra == 'docs'
Requires-Dist: mkdocs-static-i18n>=1.2.0; extra == 'docs'
Requires-Dist: mkdocs>=1.6.0; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.26.0; extra == 'docs'
Requires-Dist: pymdown-extensions>=10.0.0; extra == 'docs'
Provides-Extra: gen
Requires-Dist: litellm>=1.50; extra == 'gen'
Provides-Extra: graphql
Requires-Dist: strawberry-graphql>=0.288.1; extra == 'graphql'
Provides-Extra: magic
Requires-Dist: python-magic>=0.4.27; extra == 'magic'
Provides-Extra: mq
Requires-Dist: pika>=1.3.2; extra == 'mq'
Provides-Extra: mysql
Requires-Dist: pymysql>=1.1.2; extra == 'mysql'
Provides-Extra: oracle
Requires-Dist: oracledb>=3.4.2; extra == 'oracle'
Provides-Extra: postgresql
Requires-Dist: psycopg2-binary>=2.9.10; extra == 'postgresql'
Provides-Extra: redis
Requires-Dist: redis>=6.4.0; extra == 'redis'
Provides-Extra: s3
Requires-Dist: boto3>=1.40.21; extra == 's3'
Provides-Extra: sqlalchemy
Requires-Dist: sqlalchemy>=2.0.46; extra == 'sqlalchemy'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://github.com/HYChou0515/specstar/raw/master/docs/assets/logo-text.svg" alt="SpecStar" height="120">
</p>

<p align="center">
  <strong>Spec-driven backend platform for FastAPI</strong><br>
  Generate REST APIs, GraphQL, search, version history, and an admin UI from a single Python model.
</p>

<p align="center">
  <a href="https://pypi.org/project/specstar/"><img alt="PyPI" src="https://img.shields.io/pypi/v/specstar"></a>
  <a href="https://github.com/HYChou0515/specstar/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/specstar"></a>
  <a href="https://hychou0515.github.io/specstar/"><img alt="Docs" src="https://img.shields.io/badge/docs-mkdocs-blue"></a>
  <a href="https://codecov.io/gh/HYChou0515/specstar"><img alt="Coverage" src="https://codecov.io/gh/HYChou0515/specstar/branch/master/graph/badge.svg"></a>
</p>

> **Renamed from `autocrud` to `specstar` (v0.10.0).** The old name still installs as a deprecation shim that redirects every `autocrud[.X]` import to `specstar[.X]`. New projects should `pip install specstar`. See the [migration guide](MIGRATION.md).

> **v0.11 adds spec-driven authoring** (additive, zero breaking changes). Edit a single `spec.md` in prose; a Claude Code skill or the `specstar gen` CLI translates it into the declarative Python the engine consumes. See the [Spec-Driven Authoring guide](docs/en/guides/spec-driven.md) and the [v0.11 upgrade notes](docs/en/guides/upgrade-0.11.md).

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:

```python
from msgspec import Struct

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

Register the model:

```python continuation
from fastapi import FastAPI
from specstar import spec

app = FastAPI()

spec.add_model(User)
spec.apply(app)
```

> `spec.add_model(User)` is shorthand for `spec.add_model(Schema(User))` — the
> canonical form once you start tracking schema versions or migrations is
> `spec.add_model(Schema(User, "v1"))`, which the quickstart docs use.
> Both run; pick whichever fits your stage.

Start the server:

```bash
uvicorn main:app
```

Optional startup tuning:

```bash
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

```mermaid
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:
>
> ```python
> 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:

```bash
pip install specstar
```

**Spec-driven (v0.11+)** — bootstrap a starter project, then describe resources in prose:

```bash
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](docs/en/guides/spec-driven.md) for the full workflow.

**Classic Python** — register models directly:

Run your app:

```bash
uvicorn main:app
```

Open:

```
http://localhost:8000/docs
```

---

# Documentation

Full documentation:

[https://hychou0515.github.io/specstar/](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
