Self-hosting

Run your own PyCorner instance. The core platform is AGPLv3 and ships with everything except payment provider integration.

PyCorner is AGPLv3+ and designed to run on a single Linux host with no Docker. The hosted SaaS at pycorner.dev runs the same code as you’d get from cloning the public repo, plus a small backend/hosted/ layer that wires up Mollie-specific URLs. Everything outside backend/hosted/ is the OSS distribution.

What AGPLv3 means for you in practice: self-hosting for your team, internal use, or any non-distributed setting is unrestricted. If you modify PyCorner and run it as a network service for others, AGPLv3 obligates you to publish your source changes under the same license. Use the unmodified code, or modify it for internal use, and there’s nothing further to do.

What’s in / what’s not

ComponentWhereIn OSS?
Editor + Stlite previewfrontend/✓
Django backend (auth, projects, resources)backend/✓
Plan + Subscription modelsbackend/billing/✓
HasTierPermission (tier gating)backend/billing/permissions.py✓
/api/v1/billing/capabilities/ endpointbackend/billing/views.py✓
Mollie checkout / cancel / webhookbackend/hosted/billing_mollie/✗
Tunnel WebSocket serverbackend/dataproxy/✓
Standalone tunnel agentagent/✓
Hugo landing + docs sitelanding/✓
nginx + supervisord configconf/✓

OSS clones run fully — you just don’t have automated checkout. Plan changes happen via Django admin (or by writing your own billing provider as a parallel hosted app).

Activation flag

backend/pycorner/settings.py reads a single env var:

PYCORNER_HOSTED = env.bool("PYCORNER_HOSTED", default=False)

When 1:

When 0 (default):

Setting plans manually (OSS path)

Open a Django shell and assign a plan directly:

pixi run -e backend python backend/manage.py shell -c "
from accounts.models import User
from billing.models import Plan
u = User.objects.get(email='customer@example.com')
u.subscription.plan = Plan.objects.get(slug='pro')
u.subscription.save()
"

Or use the Django admin at /admin/billing/subscription/.

Wiring your own billing provider

PyCorner’s “hosted” pattern isn’t Mollie-specific — it’s just a Django app that:

  1. Exposes payment-provider URLs (checkout / cancel / webhook).
  2. Mutates Subscription rows on payment events — through billing.plans.set_plan, which is the only writer that keeps Profile.tier in step with Subscription.plan.
  3. Reports its presence via the apps.is_installed(...) check in backend/billing/views.py:CapabilitiesView.

To add Paddle or LemonSqueezy or something self-hosted:

  1. Create backend/hosted/billing_<name>/ with apps.py, services.py, views.py, urls.py.
  2. Add it to the if PYCORNER_HOSTED: branch in settings.py and the matching branch in pycorner/urls.py.
  3. Extend CapabilitiesView to recognize your app’s label.
  4. Optionally add a pixi feature for your provider’s SDK so the OSS env doesn’t pull it in:
    [feature.hosted.pypi-dependencies]
    mollie-api-python = ">=3.7"  # existing
    paddle-sdk = ">=2.0"         # your add
    

The frontend doesn’t need provider-specific changes — useCheckout() already posts to /api/v1/billing/checkout/, and whichever provider’s app mounted that URL handles it.

AI endpoint (optional)

PyCorner ships optional AI features (an ai resource for pycorner.ai().chat()/embed(), plus in-editor “Explain error” and “Describe your app”). They are off by default — PyCorner runs identically without them — and turn on with one flag:

AI_ENABLED=True
AI_BASE_URL=https://your-llm-host/v1   # any OpenAI-compatible endpoint
AI_CHAT_MODEL=...
AI_EMBED_MODEL=...
AI_API_KEY=...                          # see "Secure it" below

Secure it (important)

PyCorner’s per-account token quota is an app-layer cap only: it stops your users from over-spending through the gateway, but it can’t stop anyone who reaches your model server directly. Treat the upstream like any other unauthenticated internal service and lock it down:

  1. Require a key. Set AI_API_KEY in .env — PyCorner sends it as Authorization: Bearer <key> on every hosted call. Launch your model server with the same key so it rejects everything else, e.g.:
    llama-server --host 127.0.0.1 --port 8092 --api-key "<same-as-AI_API_KEY>" ...
    
  2. Restrict ingress to the PyCorner backend’s egress IP — a host firewall rule, a private network, or an nginx allow/deny on the model’s vhost:
    # On the box that fronts the model (e.g. ai.example.com):
    location /v1/ {
        allow 10.0.0.4;          # PyCorner backend egress IP
        deny  all;
        proxy_pass http://127.0.0.1:8092;
    }
    
  3. PyCorner warns you if you forget: with AI_ENABLED=True, an https:// AI_BASE_URL, and an empty AI_API_KEY, manage.py check reports dataproxy.W001 and the server logs a startup warning.

Bring-your-own-key AI resources (a user pointing at their own OpenAI/Anthropic account) store their key encrypted at rest via FIELD_ENCRYPTION_KEY (see the env table) — set an explicit key in production so secrets survive a SECRET_KEY rotation.

Production deployment

Single-host recipe (Ubuntu / Debian):

# 1. Pixi
curl -fsSL https://pixi.sh/install.sh | sh

# 2. Clone + install
git clone https://github.com/KellerKev/pycorner.dev.git
cd pycorner.dev
pixi install -e backend          # or `-e hosted` for the SaaS layer
pixi install -e frontend
pixi install -e web
pixi install -e supervisor
pixi install -e db

# 3. PostgreSQL
pixi run db-init && pixi run db-start && pixi run db-create

# 4. Forgejo (Git backend)
pixi run -e forgejo forgejo-download
pixi run -e forgejo forgejo-init
# follow the on-screen setup, then put the admin token in your .env

# 5. Migrations + collectstatic
pixi run -e backend python backend/manage.py migrate
pixi run -e backend python backend/manage.py collectstatic --noinput

# 6. TLS certs
# Drop your fullchain + privkey into conf/nginx/ssl-fullchain.cer + ssl-key.key,
# or wire up acme.sh / certbot.

# 7. Supervisord
pixi run sv-start    # starts everything: postgres, forgejo, gunicorn,
                     # daphne, nginx

See conf/supervisord.conf for the process list, and conf/nginx/nginx.conf for the routing. The default supervisord config uses the hosted pixi env (which is a superset of backend + the Mollie dep); change it to backend if you’re running OSS-only and don’t want the extra dep in .pixi/envs/.

Environment variables

VarDefaultPurpose
SECRET_KEYchange-me-in-productionDjango secret. Set this.
DEBUGFalseStandard Django flag.
ALLOWED_HOSTSpycorner.dev,app.pycorner.dev,localhost,127.0.0.1Comma-separated.
FRONTEND_URLhttps://app.pycorner.devThe editor’s origin. Used to derive TUNNEL_WS_URL.
TUNNEL_WS_URLderivedOverride if your agents dial a different URL.
PYCORNER_HOSTEDFalseActivate backend/hosted/ apps.
MOLLIE_API_KEYemptyOnly used when PYCORNER_HOSTED=1.
MOLLIE_WEBHOOK_BASE_URLderived from FRONTEND_URLOverride when webhooks arrive on a different host. Must be public https.
AI_ENABLEDFalseTurn on the optional AI features. See “AI endpoint”.
AI_BASE_URLhttps://ai.fineupp.com/pycorner/v1OpenAI-compatible upstream (only used when AI enabled).
AI_API_KEYemptyBearer for the upstream. Set it — see “Secure it”.
FIELD_ENCRYPTION_KEYderived from SECRET_KEYEncrypts BYO secrets at rest. manage.py generate_field_key.

For an OSS deployment, you can ignore everything Mollie-related entirely.

“Will my deployment break when you push hosted changes?”

No. The OSS public repo only contains the core (everything outside backend/hosted/). Hosted changes happen on the SaaS deployment and aren’t part of the upstream tree. If you git pull, you only get core changes; your installation stays “OSS mode” unless you opt in.