feat: GitHub auth + Turso persistence (saved graphs & testimonials)#111
Conversation
…imonials - Auth.js v5 with GitHub provider and Drizzle adapter (database sessions) - Turso/libSQL via Drizzle: users, accounts, sessions, graphs, testimonials - Save graphs per user (private) with history pages under /[lang]/graphs - Public testimonial wall on the landing page - Zod-validated server actions for graphs, testimonials and auth - Header sign in/out + avatar; save button in the workspace - i18n keys (auth.*) across all six locales - CSP: allow GitHub avatars in img-src - Fix pnpm-workspace.yaml to standard onlyBuiltDependencies format
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (34)
📝 WalkthroughWalkthroughThis PR integrates GitHub OAuth authentication via NextAuth backed by a Drizzle/LibSQL (Turso) database. It adds a full database schema, migration, and CRUD data-access modules for user-owned graphs and public testimonials. New pages let authenticated users list, view, and delete saved graphs, while the editor workspace gains a save button. A testimonials section is added to the home page. Six locale dictionaries receive new ChangesAuth, Database, Graph Saving, and Testimonials
Sequence Diagram(s)sequenceDiagram
participant Browser
participant RootLayout
participant NextAuth as NextAuth /api/auth
participant GitHubOAuth as GitHub OAuth
participant db as LibSQL (Turso)
participant CodeWorkspace
participant saveGraph as saveGraph()
participant GraphsPage as /[lang]/graphs
Browser->>RootLayout: page request
RootLayout->>NextAuth: auth()
NextAuth->>db: SELECT session WHERE sessionToken
db-->>RootLayout: session | null
RootLayout-->>Browser: Header with user/sign-in
Browser->>NextAuth: POST /api/auth/signin/github
NextAuth->>GitHubOAuth: OAuth redirect
GitHubOAuth-->>NextAuth: callback with code
NextAuth->>db: UPSERT user, account, session
NextAuth-->>Browser: session cookie
Browser->>CodeWorkspace: click Save
CodeWorkspace->>saveGraph: saveGraph(title, language, graph, source)
saveGraph->>db: INSERT INTO graphs
db-->>CodeWorkspace: { id }
Browser->>GraphsPage: GET /[lang]/graphs
GraphsPage->>db: SELECT graphs WHERE userId ORDER BY createdAt DESC
db-->>GraphsPage: graph rows
GraphsPage-->>Browser: rendered graph list
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
PR #111 added drizzle-kit (which pulls esbuild). esbuild's build script was left undecided as a placeholder in pnpm-workspace.yaml, and the prior change to onlyBuiltDependencies isn't the format this pnpm honors, so the Vercel install failed with ERR_PNPM_IGNORED_BUILDS. Set esbuild: true and keep the other builds disabled.
Resumen
Añade autenticación con GitHub y persistencia con Turso (libSQL) para guardar grafos por usuario y un muro de testimonios.
Qué incluye
user,account,session,verificationToken,graph,testimonial./[lang]/graphsy vista en/[lang]/graphs/[id](reusa<Diagram>).src/lib/validation.ts) para grafos, testimonios y auth.auth.*) en los 6 idiomas.img-src.drizzle/(el SQL a aplicar en producción).pnpm-workspace.yamlal formato estándaronlyBuiltDependencies(estaba con un placeholder roto que bloqueaba instalar/scripts).Sin middleware de auth
Next.js solo admite un middleware y
src/proxy.tsya hace locale-routing + CSP nonce. La protección se hace server-side (auth()en Server Components/Actions).Configuración requerida (no en el repo)
Variables de entorno:
AUTH_SECRET,AUTH_GITHUB_ID,AUTH_GITHUB_SECRET,TURSO_DATABASE_URL,TURSO_AUTH_TOKEN.…/api/auth/callback/github(una para local, otra para prod).drizzle/0000_*.sql).Verificación
pnpm typecheck✓pnpm lint✓pnpm test✓ (55 tests, incluye validación de schemas)pnpm build✓ (todas las rutas, incl./api/auth/[...nextauth]y/[lang]/graphs)Fuera de alcance (YAGNI)
Compartir grafos por link, comentarios por grafo, otros providers (Google/email).
Summary by CodeRabbit
Release Notes
New Features
Chores
Tests