Automatic RESTful API generator with redoc
Reason this release was yanked:
wrong version numbers
Project description
flarchitect
flarchitect is a friendly Flask extension that turns your SQLAlchemy or Flask-SQLAlchemy models into a production-ready REST API in minutes while keeping you in full control of your models and endpoints. 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, saving you time without sacrificing quality or customisation.
Features
- Automatic CRUD endpoints – expose SQLAlchemy models as RESTful resources with a simple
Metaclass. - 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/loginendpoint, or plug in your own. - Extensibility hooks – customise request and response flows.
- Soft delete – hide and restore records without permanently removing them.
- GraphQL integration – expose your models through a single
/graphqlendpoint when you need more flexible queries.
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_WRITESisTrue. - 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
Authentication
flarchitect ships with ready-to-use JWT, Basic and API key authentication. Choose strategies with
API_AUTHENTICATE_METHOD.
JWT
app.config["API_AUTHENTICATE_METHOD"] = ["jwt"]
app.config["ACCESS_SECRET_KEY"] = "access-secret"
app.config["REFRESH_SECRET_KEY"] = "refresh-secret"
app.config["API_USER_MODEL"] = User
app.config["API_USER_LOOKUP_FIELD"] = "username"
app.config["API_CREDENTIAL_CHECK_METHOD"] = "check_password"
Basic
app.config["API_AUTHENTICATE_METHOD"] = ["basic"]
app.config["API_USER_MODEL"] = User
app.config["API_USER_LOOKUP_FIELD"] = "username"
app.config["API_CREDENTIAL_CHECK_METHOD"] = "check_password"
API key
app.config["API_AUTHENTICATE_METHOD"] = ["api_key"]
app.config["API_KEY_AUTH_AND_RETURN_METHOD"] = lookup_user_by_token
# app.config["API_CREDENTIAL_HASH_FIELD"] = "api_key_hash" # optional
See the authentication docs for full configuration details and custom strategies.
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, docs served at /docs
The specification endpoint can be customised with API_SPEC_ROUTE. See the
OpenAPI docs for exporting or customising the
document.
GraphQL
Prefer working with a single endpoint? flarchitect can turn your SQLAlchemy models into a GraphQL schema with just a couple of lines. Generate the schema and register it with the architect:
from flarchitect.graphql import create_schema_from_models
schema = create_schema_from_models([Item], db.session)
architect.init_graphql(schema=schema)
With the server running you can open GraphiQL at http://localhost:5000/graphql and explore your data interactively. Use the all_items query to fetch existing records:
query {
all_items {
id
name
}
}
The GraphQL demo contains ready-made models and sample queries to help you get started.
Read about hiding and restoring records in the soft delete section.
Running Tests
To run the test suite locally:
pytest
Documentation & help
- Browse the full documentation for tutorials and API reference.
- Explore runnable examples in the demo directory, including a validators example showcasing email and URL validation.
- Authentication demos: JWT, Basic and API key snippets showcase the built-in strategies.
- Questions? Join the GitHub discussions or open an issue.
- See the changelog for release history.
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:
- Update the
versionfield inpyproject.toml(for example withhatch version patch). - 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 LICENSE 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flarchitect-1.1.2.tar.gz.
File metadata
- Download URL: flarchitect-1.1.2.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5039dd0137c88a5c82d15eee6d80dca2de3fe4c5e78316bab8820379f5a7e7f
|
|
| MD5 |
894886a599dbbbfa3bc566923c796e52
|
|
| BLAKE2b-256 |
be86cf63da7bce51231507afc90908f7b815e690a477fbfae49a863d9993bbf7
|
Provenance
The following attestation bundles were made for flarchitect-1.1.2.tar.gz:
Publisher:
release.yml on lewis-morris/flarchitect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flarchitect-1.1.2.tar.gz -
Subject digest:
f5039dd0137c88a5c82d15eee6d80dca2de3fe4c5e78316bab8820379f5a7e7f - Sigstore transparency entry: 395733362
- Sigstore integration time:
-
Permalink:
lewis-morris/flarchitect@2a1a25e67f79106446f853a9b75fffbd670d8e08 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/lewis-morris
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a1a25e67f79106446f853a9b75fffbd670d8e08 -
Trigger Event:
push
-
Statement type:
File details
Details for the file flarchitect-1.1.2-py3-none-any.whl.
File metadata
- Download URL: flarchitect-1.1.2-py3-none-any.whl
- Upload date:
- Size: 107.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
517a265201e211dc43ab5f0e7a4d38c219a7bd6b204ded038814d018f7886da9
|
|
| MD5 |
65081a5c3bac7dd51dd5761b75a5419e
|
|
| BLAKE2b-256 |
282b46c8c93670566603e5f80c434c96c879e2c98469227b4ce7cc2fb91b6577
|
Provenance
The following attestation bundles were made for flarchitect-1.1.2-py3-none-any.whl:
Publisher:
release.yml on lewis-morris/flarchitect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flarchitect-1.1.2-py3-none-any.whl -
Subject digest:
517a265201e211dc43ab5f0e7a4d38c219a7bd6b204ded038814d018f7886da9 - Sigstore transparency entry: 395733364
- Sigstore integration time:
-
Permalink:
lewis-morris/flarchitect@2a1a25e67f79106446f853a9b75fffbd670d8e08 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/lewis-morris
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a1a25e67f79106446f853a9b75fffbd670d8e08 -
Trigger Event:
push
-
Statement type: