Skip to main content
The Metaweave pipeline is a Python package that ingests submissions into PostgreSQL. It runs as a single CLI on a schedule.

Prerequisites

  • Python 3.12+
  • A Google Cloud SQL Postgres instance (and a service account JSON with access)
  • An Azure AD app registration with Mail.Read and Mail.ReadWrite permissions on the shared Outlook mailbox
  • Network access to:
    • graph.microsoft.com
    • login.microsoftonline.com
    • sqladmin.googleapis.com (for Cloud SQL Connector)

Set up the venv

Editable install means changes to src/ are picked up without re-installing.

Dependencies

Pulled in from pyproject.toml:
PackageWhy
pycryptodomeAES-128-CBC decryption
sqlalchemy ≥2.0ORM + declarative models
cloud-sql-python-connector[pg8000]GCP Cloud SQL Connector
pg8000Pure-Python PostgreSQL dialect
psycopg2-binaryFallback PostgreSQL driver
alembicSchema migrations (included, not yet used)
msalMicrosoft identity library (OAuth2 client credentials)
requestsHTTP client for Microsoft Graph
python-dotenv.env loading
Dev deps: pytest, pytest-cov.

Configure environment variables

Create a .env in the pipeline/ directory (or set them in your shell). Required variables:
See Configuration for the full list of variables.

Create the database tables

First-time setup:
This calls Base.metadata.create_all(engine) and exits. It’s idempotent — re-running on an existing schema is a no-op. The 17 tables it creates:
See Data model for the relationships.

Verify the install

Run a single email through end-to-end without touching Outlook:
--file reads the body from disk, runs Parse → Map → Write, and exits. Useful for testing without consuming a real mailbox message.

Run the tests

Tests use SQLite in-memory with PRAGMA foreign_keys=ON — no PostgreSQL needed.

See also