FOCA¶
An archetype for OpenAPI-based web services in Python, brought to you by ELIXIR On-Cloud. FOCA (Flask-OpenAPI-Connexion-Archetype) builds a Connexion app on Flask from your OpenAPI specifications and a single configuration file, so that you only write the controllers and the logic of your app. It provides:
- OpenAPI 2.x/3.x specifications, validated and routed by Connexion and modified on the fly;
- a validated, typed configuration, with environment-specific overlays;
- errors as problem details;
- bearer token validation for the OpenID Connect providers that you trust;
- access control with Casbin: policies on all operations, roles of users and groups, resource ownership and a permissions API;
- MongoDB databases, collections and indexes;
- background tasks with Celery and RabbitMQ;
- CORS and a GA4GH service info endpoint;
- a plugin engine for gateway apps (e.g., proTES): installed, versioned plugins that check, change and route requests to backends, in pipelines set by operators;
- an HTTP client for untrusted URLs, guarded against server-side request forgery;
- Docker base images with SBOM and provenance attestations, and a Helm library chart for Kubernetes with a provenance attestation, all signed.
Why FOCA¶
FOCA's package has about 9,300 lines of code, tested by about 12,600 lines of tests, and its Helm library chart about 1,750 lines. Cloud Registry, for example, uses almost all of the package (all but the Celery factory and a database helper) and has about 2,200 lines of code of its own, plus about 9,000 lines of tests. Its own code is thus about a fifth of what it would be without FOCA, counting code only, and about a third, counting code and tests. Even if an app needed only half of FOCA's code, FOCA would still save it about 4,500 lines, plus their tests and the chart. (Lines of Python without blank lines and comments, docstrings included; FOCA and Cloud Registry in October 2026.)
The savings add up with every app: if you maintain several OpenAPI-based apps, they all share the same authentication, access control, configuration, errors, images and Helm chart, and security fixes and upgrades are made once, in FOCA, instead of in every app.
Apps built with FOCA¶
| App | Description |
|---|---|
| Cloud Registry | A registry of web services, implementing the GA4GH Service Registry API |
| proTES | A gateway for the GA4GH Task Execution Service (TES) API that federates TES instances |
See also the dependents of FOCA on
GitHub. Built an
app with FOCA? Open a pull request that adds it to the table in
README.md.
Contents¶
- Getting started: install FOCA, write a minimal app, the example apps and the Docker image.
- Configuration: the configuration file, overlays and each of its sections.
- Authentication: bearer token validation for trusted OpenID Connect providers.
- Access control: policies, roles, resource ownership and the permissions API.
- Deployment: running in production, Kubernetes and Helm, Docker Compose and verifying images and charts.
- Helm library chart: the
foca-commonchart for the Helm charts of apps. - Utilities: helpers for common tasks.
- Migrating to 0.22.0, 0.21.0, 0.20.0, 0.18.0, 0.17.0, 0.16.0, 0.15.0 and 0.14.0: breaking changes and how to upgrade apps.
- Preparing for the ASGI release: what the ASGI release removes, with Flask, and what to use instead from FOCA 0.22 on.
- Contributing: how to contribute, the development setup, versioning and releases, and the Python guidelines.
- API reference: the code, generated from its docstrings.
- Changelog: release notes.
The project adopts semantic versioning; while the major version is 0, minor releases may contain breaking changes, which are listed in the changelog and the migration notes.
Citation¶
If you use FOCA, please cite it with its DOI
10.5281/zenodo.23603534, which
always resolves to the latest version on Zenodo; the
Zenodo record lists the DOI of each version, too. The citation metadata is in
CITATION.cff:
on GitHub, "Cite this repository" in the sidebar of the repository formats it
as APA or BibTeX.
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 project for any inquiry, proposal, question etc.
