Skip to main content

FOCA_logo  Develop Flask microservices quickly!

License Build_status Docs Coverage GitHub_tag PyPI_release

FOCA (Flask-OpenAPI-Connexion-Archetype) is an opinionated archetype that enables fast development of OpenAPI-based HTTP API microservices in Flask, leveraging the excellent Connexion framework.

FOCA reduces the required boilerplate code to fire up your app to a bare minimum and allows you to focus on your application logic. It also avoids unnecessary code repetition and introduces cross-service consistency when developing multiple applications. Simply write a configuration file, pass it to FOCA and you're good to go!

Features:

  • Validated, typed app configuration, with environment-specific overlays
  • OpenAPI 2.x/3.x specifications, merged and modified on the fly
  • Errors as problem details, with configurable media type
  • Bearer token (JWT) validation for trusted OpenID Connect issuers
  • Policy-based access control with Casbin, including a permissions API
  • MongoDB databases, collections and indexes
  • Background tasks with RabbitMQ & Celery
  • Configurable CORS
  • GA4GH service info served from the configuration

Read the documentation for details. Upgrading from an earlier version? See Migrating to 0.16.0 (from 0.14 or earlier, first Migrating to 0.15.0 and Migrating to 0.14.0).

Usage

(1) Install the FOCA package with pip:

pip install foca

(2) Create a configuration file, e.g.:

api:
  specs:
    - path: api/openapi.yaml
      add_operation_fields:
        x-openapi-router-controller: my_app.controllers

(3) Create and run your app:

from foca import Foca

app = Foca(config_file="config.yaml").create_app()  # Connexion app

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

Hint Check out the Petstore example application shipped with this repository to see FOCA in action! See Getting started for a step-by-step guide.

Docker image

FOCA images with all dependencies installed are published as elixircloud/foca (built from docker/Dockerfile), for use as base images of apps:

FROM elixircloud/foca:latest
COPY ./ /app
CMD ["python", "app.py"]

python app.py starts Flask's development server, which is meant for local development only. In production, run the app with a WSGI server such as Gunicorn (see running in production).

Images of releases are tagged with the FOCA and Python versions (e.g., 0.14.0-py3.12); the FOCA version alone (e.g., 0.14.0) tags the Python 3.13 image, and latest that of the highest stable release (not an alpha, beta or release candidate). Images built from the dev branch are tagged with their date and the Python version (e.g., 20261019-py3.13).

The image contains no build tools and runs as non-root user foca (UID 1000, group 0); /app and the home directory are writable by group 0, so that the image also runs under arbitrary user IDs (e.g., on OpenShift). To install system or Python packages in derived images, switch to root and back:

USER root
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
USER 1000

Contributing

This project is a community effort and lives off your contributions, be it in the form of bug reports, feature requests, discussions, or fixes and other code changes. Please refer to our organization's contributing guidelines if you are interested to contribute. Please mind the code of conduct for all interactions with the community.

Test coverage of foca is kept at 100%, which is enforced: coverage report (and CI) fails below 100% (fail_under in pyproject.toml), and so do Codecov's checks of the whole code and of the changes of a pull request (codecov.yml). The tests marked mongodb need a MongoDB server on localhost:12345:

pip install -e .[dev]
coverage run -m pytest
coverage report -m

To build the documentation locally, install the docs extra and run MkDocs:

pip install -e .[docs]
mkdocs serve

Versioning

The project adopts semantic versioning. Currently the service is in beta stage, so the API may change without further notice.

The version is derived from git tags (via setuptools-scm) and available as foca.__version__; builds between releases get development versions (e.g., 0.14.1.dev3+g1a2b3c4).

Releasing

Features and fixes are merged into dev. Branch main only ever moves forward to commits on dev that are released. To release version X.Y.Z from commit <sha> on dev, after CI passed for it:

git push origin <sha>:main  # fails unless it is a fast-forward
git tag -s vX.Y.Z <sha> -m "vX.Y.Z"
git push origin vX.Y.Z

Pushing the tag triggers the release workflow, which checks that the tagged commit is on main, publishes the distributions to PyPI (after approval in the pypi environment), pushes Docker images tagged X.Y.Z and latest, and creates a GitHub release with generated notes. Tags of alpha, beta and release candidate versions (e.g., vX.Y.Zrc1) do not update latest. These and, until 1.0.0, all other releases are GitHub pre-releases (never marked as the latest release).

The Helm library chart foca-common (charts/foca-common) is versioned and released separately, from signed tags chart-vX.Y.Z; see releases of the library chart.

License

This project is covered by the Apache License 2.0 also shipped with this repository.

Contact

The project is a collaborative effort under the umbrella of ELIXIR On-Cloud. Follow the link to get in touch with us via chat or email. Please mention the name of this service for any inquiry, proposal, question etc.

Logo_banner

Metadata

Release files for foca 0.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foca 0.16.0
File Size Uploaded Provenance
foca-0.16.0.tar.gz 213.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for foca 0.16.0
File Interpreter ABI Platform
foca-0.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 331.0 kB

Release files / foca-0.16.0.tar.gz

Download URL foca-0.16.0.tar.gz
Size 213.6 kB
Tags Source
SHA-256 checksum
How to use checksums
126c599e11948715eaa2d780de07cabb24636862f6fbd91be2581327157ecbae
BLAKE2b-256 checksum
How to use checksums
4114f42f3ef2175e89c2972a7e893c667e15d3cd933339901c3093870100de83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / foca-0.16.0-py3-none-any.whl

Download URL foca-0.16.0-py3-none-any.whl
Size 117.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a06579664846bdb3c8380605e48b2411076d05c5fe76da80f3453c91952962f1
BLAKE2b-256 checksum
How to use checksums
4f14ea1b95343adf3ab684858845828a50c4bd5817847365054a7555ceb39859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for foca 0.16.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for foca-0.16.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page