Skip to content

Move backend off Railway: Neon Postgres + Render, uploads stored in Postgres - #2

Merged
Derdiry merged 3 commits into
mainfrom
neon-setup
Nov 1, 2026
Merged

Derdiry merged 3 commits into
mainfrom
neon-setup

Conversation

@Derdiry

@Derdiry Derdiry commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Database → Neon. The backend reads Neon's .env.local. It prefers DATABASE_URL_UNPOOLED (the direct endpoint) because it is one long-running process with its own pool and runs DDL at startup. libpq sslmode/channel_binding are converted for asyncpg.
  • Uploads → Postgres. The profile photo, resume and screenshots are now stored in a new uploaded_files table (bytea + content type + filename + created time). Render's free disk is ephemeral, so files saved there would be lost. API paths and the /uploads/{filename} URLs are unchanged, so the frontend is untouched. Replacing the profile photo deletes the old one.
  • Seed hardening. The admin user is created only when ADMIN_PASSWORD is set. Previously an empty users table plus a missing env var produced admin/admin.
  • Render. render.yaml defines a free Python web service:
    • Root directory backend, Python 3.10.12, Frankfurt region (closest to Neon aws-eu-west-2).
    • Start command uvicorn main:app --host 0.0.0.0 --port $PORT, health check /health.
    • Secrets use sync: false.
  • Hygiene. Added backend/.dockerignore (env files, venvs, caches, uploads) and venv entries in .gitignore.
  • Docs. DEPLOY.md is rewritten for Vercel + Render + Neon. Both railway.toml files are marked unused.

Not changed: vercel.json and VITE_API_URL. They will point at the Render URL once the service exists.

Testing

  • npm run build passes.
  • Simulated the Render deploy from a clean copy of backend/. I ran Render's build and start commands on Python 3.10.12 with only the Render env vars set. Results:
    • /health 200
    • Verified content served
    • Wrong login 401
    • Admin without token 403
    • CORS allows both moderdiry.com origins and rejects others
  • Upload durability, tested on a temporary Neon branch (since deleted):
    • Uploaded photo, screenshot and resume, restarted the backend, and all three were served byte-identical.
    • After deletion they return 404.
    • Replacing the photo removes the old one.
    • Nothing was written to local disk.
  • Docker build context check: no .env, .venv or __pycache__ in the image.

Known limitations (Render free tier)

  • Outbound SMTP is blocked. Contact messages are still saved in contact_messages, but no email is sent.
  • The service sleeps after 15 minutes idle, with a cold start of about 1 minute.

🤖 Generated with Claude Code

Derdiry and others added 3 commits November 1, 2026 12:20
- neon init: link project (neon.ts, .neon ignored), add @neon/config and @neon/env
- Read repo-root .env.local; prefer DATABASE_URL_UNPOOLED (direct endpoint)
- Convert libpq sslmode/channel_binding params for asyncpg
- Seed creates the admin user only when ADMIN_PASSWORD is set (no admin/admin default)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Profile photo, resume and screenshots go to a new uploaded_files table
(bytea, content type, filename, created time) so they survive restarts
on hosts with ephemeral disks. API paths and /uploads/{filename} URLs are
unchanged; replacing the profile photo deletes the previous one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- render.yaml: free Python web service, rootDir backend, Python 3.10.12,
  health check /health, secrets as sync: false
- backend/.dockerignore and .gitignore: keep env files, venvs and caches out
- DEPLOY.md rewritten for Vercel + Render + Neon; railway.toml marked unused

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
my_website Ready Ready Preview Nov 1, 2026 9:21am UTC

@Derdiry
Derdiry merged commit a16074c into main Nov 1, 2026
3 checks passed
@Derdiry
Derdiry deleted the neon-setup branch November 1, 2026 09:24

This branch was successfully deployed

1 active deployment
Preview — 7a4ee287 Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant