Skip to main content

A python/fastAPI implementation of the ActivityPub protocol.

Requirements

  • Linux environment (tested on Mint/Ubuntu)

  • Python (3.12+)

Installation

  1. As a pip package:

If you want to build ActivityPub clients, you can use the software as a library.

pip install phederation
  1. For development of the library, clone the repository from codeberg:

git clone https://codeberg.org/feldie/phederation.git phederation
  1. Navigate to the root folder of the “phederation” repository, then set up a python environment with uv, e.g.:

cd phederation
uv sync
  1. You can start a debug/development version using:

source .venv/bin/activate
gunicorn -c=settings/gunicorn.conf.dev.py

This will start a local server (localhost), you can try to access the fastapi doc at “<localhost:port>/docs”.

Testing and profiling

There are unit tests in the tests/ folder. They can be run using pytest:

pytest tests/unit_tests/

For coverage:

coverage run -m pytest tests/
coverage html

Profiling can be done with the pytest plugin pytest-profiling. For pretty svg plots of the runtimes, we use the additional graphviz tool.

pip install pytest-profiling
sudo apt install graphviz
pytest tests/unit_tests/ --profile-svg

Production environment

For a production environment, you should set up proper web hosting. Minimal safeguards should be in place, at least proxy+load balancing+ddos safe; nginx+fail2ban are a good combination:

You should also use a proper WSGI webserver (e.g. gunicorn), see below. Phederation is set up to accommodate all of this, and is tested to work in a production environment. Example settings files for production can be found in the “settings” folder. After setting up fail2ban and nginx, you can start a production mode version like this:

source .venv/bin/activate
gunicorn -c=settings/gunicorn.conf.prod.py

The command above starts gunicorn workers and serves content on “127.0.0.1:8082” (localhost, then use proxy to serve on the web). It uses the settings file “settings/instance_config-prod.yaml” for production mode.

Of course, it is useful to convert this into a proper service that runs continuously. This can be done by containerization of the phederation server itself, building a docker image and then hosting it. It is important to first set the proper variables in the file settings/.env (an example file with dummy values is located in settings/.env.noignore), then build the docker image, and then start all docker images. Note that the docker compose file settings/compose.yaml will start a keycloak server, its postgres database, a mongo database for the phederation image, and the phederation image itself. If you have another keycloak server running already, you should disable the former in the settings/compose.yaml file and instead link to yours in the settings/.env file.

docker build -t phederation-0.5 .
docker compose up -d

Metadata

Release files for phederation 0.8.2

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

Source distribution (sdist)

Source distribution for phederation 0.8.2
File Size Uploaded
phederation-0.8.2.tar.gz 111.5 kB Details

Built distribution (wheel)

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

Total release size: 256.9 kB

Release files / phederation-0.8.2.tar.gz

Download URL phederation-0.8.2.tar.gz
Size 111.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a7ca8db2970492781aecbaab6bf07e4662fec067e5551792eb49550be6545561
BLAKE2b-256 checksum
How to use checksums
026fb6717598a3bdcaa6e18a4acdd86670f590e3ef8658440639c92571981748
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release files / phederation-0.8.2-py3-none-any.whl

Download URL phederation-0.8.2-py3-none-any.whl
Size 145.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ae9f07f05154e99d235b1633f1cab7d91251eead5971dac764de47662fed0e9
BLAKE2b-256 checksum
How to use checksums
b98737187e23e8d2319342d2f57bf9c1db7faa6b298eb8dec2b8e15e52cd2bd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.8.2 This release

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.8

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

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