Skip to main content

Automatic RESTful API generator with redoc

Project description

flarchitect

Docs Tests Coverage PyPI version

flarchitect is a friendly Flask extension that turns your SQLAlchemy or Flask-SQLAlchemy models into a production-ready REST API with almost no boilerplate. It automatically builds CRUD endpoints, generates interactive Redoc documentation and keeps responses consistent so you can focus on your application logic.

Why flarchitect?

If you're new here, welcome! flarchitect gets you from data models to a fully fledged REST API in minutes, letting you focus on the features that matter rather than plumbing.

Features

  • Automatic CRUD endpoints – expose SQLAlchemy models as RESTful resources with a simple Meta class.
  • Interactive documentation – Redoc or Swagger UI generated at runtime and kept in sync with your models.
  • Built-in authentication – JWT, basic and API key strategies ship with a ready‑made /auth/login endpoint, or plug in your own.
  • Extensibility hooks – customise request and response flows.
  • Soft delete – hide and restore records without permanently removing them.

Optional extras

  • Rate limiting & structured responses – configurable throttling and consistent response schema.
  • Field validation – built-in validators for emails, URLs, IPs and more.
  • Nested writes – send related objects in POST/PUT payloads when API_ALLOW_NESTED_WRITES is True.
  • CORS support – enable cross-origin requests with API_ENABLE_CORS.

Installation

flarchitect supports Python 3.10 and newer. Set up a virtual environment, install the package and verify the install:

python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
pip install flarchitect
python -c "import flarchitect; print(flarchitect.__version__)"

The final command prints the version number to confirm everything installed correctly.

Quick Start

from flask import Flask
from flarchitect import Architect
from models import Author, BaseModel  # your SQLAlchemy models

app = Flask(__name__)
app.config["API_TITLE"] = "My API"
app.config["API_VERSION"] = "1.0"
app.config["API_BASE_MODEL"] = BaseModel
app.config["API_ALLOW_NESTED_WRITES"] = True

architect = Architect(app)

if __name__ == "__main__":
    app.run(debug=True)

With the application running, try your new API in another terminal window:

curl http://localhost:5000/api/authors

OpenAPI specification

An OpenAPI 3 schema is generated automatically and powers the Redoc UI. You can switch to Swagger‑UI by setting API_DOCS_STYLE = 'swagger' in your Flask config. Either way you can serve the raw specification to integrate with tooling such as Postman:

from flask import Flask
from flarchitect import Architect

app = Flask(__name__)
architect = Architect(app)  # OpenAPI served at /openapi.json

The specification endpoint can be customised with API_SPEC_ROUTE. See the OpenAPI docs for exporting or customising the document.

Read about hiding and restoring records in the soft delete section.

Running Tests

To run the test suite locally:

pytest

Documentation & help

Roadmap

Check out the project roadmap for upcoming features and enhancements.

Contributing

Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.

Before submitting a pull request, ensure that linters and tests pass locally:

ruff --fix .
pytest

Versioning & Releases

The package version is defined in pyproject.toml and exposed as flarchitect.__version__. A GitHub Actions workflow automatically publishes to PyPI when the version changes on master.

To publish a new release:

  1. Update the version field in pyproject.toml (for example with hatch version patch).
  2. Commit and push to master.

Ensure the repository has a PYPI_API_TOKEN secret with an API token from PyPI.

License

Distributed under the MIT License. See LICENCE for details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flarchitect-0.1.0.1.tar.gz (7.7 MB view details)

Uploaded Source

Built Distribution

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

flarchitect-0.1.0.1-py3-none-any.whl (91.3 kB view details)

Uploaded Python 3

File details

Details for the file flarchitect-0.1.0.1.tar.gz.

File metadata

  • Download URL: flarchitect-0.1.0.1.tar.gz
  • Upload date:
  • Size: 7.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for flarchitect-0.1.0.1.tar.gz
Algorithm Hash digest
SHA256 fa82b4fb97e1ee90c687bb21dccdd3dbf148ab7fedcb9cc0e9fe6682ee945853
MD5 43fad26cc9d9835607dc0e7b044ead1f
BLAKE2b-256 3f2846e203f9a3ef8fef8a3d39c812ef6569883144783dceb6870f3da7edf644

See more details on using hashes here.

File details

Details for the file flarchitect-0.1.0.1-py3-none-any.whl.

File metadata

  • Download URL: flarchitect-0.1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 91.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for flarchitect-0.1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9043c937e946baf4ff16eb54bf1b78da1679550ad521b99a55e2dbbd45e49a0e
MD5 94f6ba5213272c345e1396f3e342245f
BLAKE2b-256 c05ee26436740e655926d163b3183b5e5a91291d74a4398a1ff24733ab80be21

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