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
| Component | Where | In OSS? |
|---|---|---|
| Editor + Stlite preview | frontend/ | ✓ |
| Django backend (auth, projects, resources) | backend/ | ✓ |
| Plan + Subscription models | backend/billing/ | ✓ |
HasTierPermission (tier gating) | backend/billing/permissions.py | ✓ |
/api/v1/billing/capabilities/ endpoint | backend/billing/views.py | ✓ |
| Mollie checkout / cancel / webhook | backend/hosted/billing_mollie/ | ✗ |
| Tunnel WebSocket server | backend/dataproxy/ | ✓ |
| Standalone tunnel agent | agent/ | ✓ |
| Hugo landing + docs site | landing/ | ✓ |
| nginx + supervisord config | conf/ | ✓ |
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:
INSTALLED_APPSgetshosted.billing_mollieappended.pycorner/urls.pymountshosted.billing_mollie.urlsat/api/v1/billing/.- The frontend sees
{"checkout": true, "cancel": true}from/api/v1/billing/capabilities/and renders the Upgrade / Cancel subscription buttons.
When 0 (default):
- Mollie code never imports; no
mollie-api-pythondep needed. - Billing endpoints for checkout/cancel/webhook don’t exist.
- Frontend shows a “Self-hosted deployment — ask your admin to upgrade your subscription through Django admin” hint where the Upgrade button would be.
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:
- Exposes payment-provider URLs (checkout / cancel / webhook).
- Mutates
Subscriptionrows on payment events — throughbilling.plans.set_plan, which is the only writer that keepsProfile.tierin step withSubscription.plan. - Reports its presence via the
apps.is_installed(...)check inbackend/billing/views.py:CapabilitiesView.
To add Paddle or LemonSqueezy or something self-hosted:
- Create
backend/hosted/billing_<name>/withapps.py,services.py,views.py,urls.py. - Add it to the
if PYCORNER_HOSTED:branch insettings.pyand the matching branch inpycorner/urls.py. - Extend
CapabilitiesViewto recognize your app’s label. - 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:
- Require a key. Set
AI_API_KEYin.env— PyCorner sends it asAuthorization: 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>" ... - 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; } - PyCorner warns you if you forget: with
AI_ENABLED=True, anhttps://AI_BASE_URL, and an emptyAI_API_KEY,manage.py checkreportsdataproxy.W001and 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
| Var | Default | Purpose |
|---|---|---|
SECRET_KEY | change-me-in-production | Django secret. Set this. |
DEBUG | False | Standard Django flag. |
ALLOWED_HOSTS | pycorner.dev,app.pycorner.dev,localhost,127.0.0.1 | Comma-separated. |
FRONTEND_URL | https://app.pycorner.dev | The editor’s origin. Used to derive TUNNEL_WS_URL. |
TUNNEL_WS_URL | derived | Override if your agents dial a different URL. |
PYCORNER_HOSTED | False | Activate backend/hosted/ apps. |
MOLLIE_API_KEY | empty | Only used when PYCORNER_HOSTED=1. |
MOLLIE_WEBHOOK_BASE_URL | derived from FRONTEND_URL | Override when webhooks arrive on a different host. Must be public https. |
AI_ENABLED | False | Turn on the optional AI features. See “AI endpoint”. |
AI_BASE_URL | https://ai.fineupp.com/pycorner/v1 | OpenAI-compatible upstream (only used when AI enabled). |
AI_API_KEY | empty | Bearer for the upstream. Set it — see “Secure it”. |
FIELD_ENCRYPTION_KEY | derived from SECRET_KEY | Encrypts 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.