Migrate backend to Encore and local desktop auth

✅ merged · #1 · KB01111/mike ← KB01111/mike · opened 14d ago by KB01111 · merged 14d ago by KB01111 · self · +4,494-407 across 41 files · ↗ on GitHub

From the PR description

User description

Summary by Sourcery

Migrate authentication and backend infrastructure from Supabase to an Encore-managed Postgres and local JWT-based auth system, and add an optional Tauri-based desktop shell alongside build and tooling updates.

New Features:

  • Introduce a local JWT-based authentication API with signup, login, session, refresh, and logout endpoints backed by a users table.
  • Add a Supabase-to-Encore migration script and initial Encore SQL migration defining core application tables and legacy user mapping.
  • Add a Tauri v2 desktop shell that runs a packaged Next.js standalone server via a sidecar binary for desktop builds.

Bug Fixes:

  • Ensure account deletion also removes or unlinks associated application data and legacy user claims before deleting the user record.
  • Normalize and prefix R2 storage keys to avoid collisions and support configurable key prefixes across uploads, downloads, deletes, and signed URLs.

Enhancements:

  • Replace Supabase client usage in the frontend with a lightweight local auth client that talks to the new backend auth endpoints and stores sessions in localStorage.
  • Replace the server-side Supabase client with a Postgres-backed compatibility layer and Encore SQLDatabase, keeping existing route shapes while migrating off Supabase.
  • Refactor auth middleware and user extraction to validate Mike bearer tokens instead of calling Supabase.
  • Adapt the Express app to run under Encore via a raw API shim while preserving standalone server startup for local development.
  • Add Postgres client abstractions and tests to emulate the Supabase query builder API against raw SQL.
  • Improve safe local testing docs and README to describe the Encore setup, new env vars, migration flow, and desktop build commands.

Build:

  • Add Encore, pg, and related typings to the backend, introduce a test script and a Supabase-to-Encore migration script entrypoint.
  • Add Tauri CLI and pkg-based sidecar build tooling to the frontend, plus a desktop build flag that produces a Next.js standalone output and wiring for sidecar preparation scripts.

Documentation:

  • Update README and safe-local-testing docs to reflect Encore-based backend, local auth, database migration steps, desktop shell usage, and revised environment variables.

Tests:

  • Add unit tests for the Postgres Supabase-compat client and its SQL generation behavior.

CodeAnt-AI Description

Move Mike to local auth, Encore PostgreSQL, and desktop support

What Changed

  • Sign-up, login, session refresh, and logout now use Mike's own auth flow instead of Supabase, with sessions stored locally in the app.
  • The app now loads user data from Encore PostgreSQL and keeps the same main API routes while running through an Encore-backed backend.
  • Deleting an account now clears associated project, document, workflow, chat, and profile data before removing the user.
  • Storage keys can now be kept under a configurable R2 prefix, and migrated files avoid double-prefixing.
  • A desktop version is now available through Tauri, with build and launch support for packaged Windows, macOS, and Linux apps.
  • The migration tool can copy legacy Supabase data and R2 objects into the new Encore setup and write a report of what was moved or skipped.

Impact

✅ Sign in without Supabase ✅ Safer account deletion ✅ Cleaner data migration ✅ Desktop app builds

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Our analysis

Migrate off Supabase to Encore Postgres with local JWT auth and a Tauri desktop shell — read the full analysis →

Think the analysis missed something the PR description covers?

Commits in this PR (6)

SHA Subject Author Date
e53d5b1d Migrate backend to Encore and local desktop auth KB01111 2026-05-26 ↗ GitHub
011de869 Update backend/migrations/001_initial.sql KB01111 2026-05-26 ↗ GitHub
Co-authored-by: entelligence-ai-pr-reviews[bot] <174136889+entelligence-ai-pr-reviews[bot]@users.noreply.github.com>
7cc73c22 Update backend/src/lib/localAuth.ts KB01111 2026-05-26 ↗ GitHub
Co-authored-by: entelligence-ai-pr-reviews[bot] <174136889+entelligence-ai-pr-reviews[bot]@users.noreply.github.com>
2244cb48 fix: apply CodeRabbit auto-fixes coderabbitai[bot] 2026-05-26 ↗ GitHub
Fixed 11 file(s) based on 14 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
d35344d9 Update backend/src/encore.ts KB01111 2026-05-26 ↗ GitHub
Co-authored-by: entelligence-ai-pr-reviews[bot] <174136889+entelligence-ai-pr-reviews[bot]@users.noreply.github.com>
2ef59269 fix: apply CodeRabbit auto-fixes coderabbitai[bot] 2026-05-26 ↗ GitHub
Fixed 5 file(s) based on 3 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

Capture this PR into my fork

Download a Markdown prompt that tells Claude how to port every commit in this PR into your working tree. Run it via claude -p < capture-pull-1.md from inside the repo you want the changes in.

⬇ Download capture-pull-1.md