DocumentationAuth Starter v1.0.0 · CLI v0.2.6
ArkRealm Auth Starter — Quickstart & Reference
How auth-api (Express 5 + PostgreSQL 18 + Redis 8 on port 3000) and auth-ui (Next.js 16 on port 3001) run locally and in production.
1. Decoupled Service Architecture
Authentication lives in a standalone Express 5 service rather than inside Next.js route handlers, with PostgreSQL 18 storing users, OAuth links, and encrypted TOTP secrets, and Redis 8 handling session state and rate limits.
2. Quickstart (Up in 3 Minutes)
Try the free --lite demo locally, or spin up the licensed starter from the release ZIP or arkrealm CLI.
3. Key Environment Variables
Core settings from .env.example. Full variable details and security rules are also included inside the repo's docs/ folder.
| Key(s) | Repo | Example / Default | Role |
|---|---|---|---|
| PORT / APP_URL / CORS_ORIGIN | auth-api | 3000 / http://localhost:3001 / http://localhost:3001 | API port, frontend base URL for links/OAuth redirects, and allowed CORS origins. |
| DATABASE_URL / REDIS_URL | auth-api | postgresql://postgres:postgres@localhost:5432/auth_db · redis://localhost:6379 | PostgreSQL 18 (Prisma 7) and Redis 8 (sessions & rate limiters). SESSION_TTL defaults to 604800s (7d). |
| TOTP_ENCRYPTION_KEY | auth-api | 64-char hex (openssl rand -hex 32) | Encrypts TOTP 2FA secrets at rest with AES-256-GCM; required when NODE_ENV=production. |
| GOOGLE_CLIENT_ID / SECRET / REDIRECT_URI | auth-api | http://localhost:3000/auth/google/callback | Optional Google OAuth 2.0 credentials; set all three together or leave blank. |
| SMTP_HOST / PORT / USER / PASS / EMAIL_FROM | auth-api | smtp.example.com / 587 | Leave SMTP_HOST empty in development to log links to stdout; required in production. |
| TRUST_PROXY | auth-api | 0 (or 1 behind reverse proxy) | Sets reverse proxy hop count for accurate client IPs behind Nginx, Cloudflare, or cloud hosts. |
| NEXT_PUBLIC_API_URL | auth-ui | http://localhost:3000 | Points the Next.js 16 frontend to your running auth-api server. |
4. Core REST & Health Endpoints
Authentication, email verification/recovery, Google OAuth, TOTP 2FA, session management, and health probes—also exported in openapi.json.
| Method | Route | Guard | Summary |
|---|---|---|---|
| POST | /auth/register | registerRateLimiter | Register user and send email verification token. |
| POST | /auth/login | loginRateLimiter | Authenticate credentials and issue session or 2FA challenge. |
| POST | /auth/verify-email | emailActionRateLimiter | Verify email token; /auth/verify-email/resend re-sends verification. |
| POST | /auth/forgot-password | emailActionRateLimiter | Send password reset token; /auth/reset-password updates password. |
| GET | /auth/google | loginRateLimiter | Start Google OAuth flow (/auth/google/callback & POST /auth/google/token). |
| POST | /auth/2fa/setup | requireAuth | Initialize TOTP 2FA (/auth/2fa/enable, /auth/2fa/verify, /auth/2fa/disable). |
| GET | /auth/me | requireAuth | Fetch authenticated user profile; POST /auth/change-password updates password. |
| GET | /auth/sessions | requireAuth | List active sessions; DELETE /auth/sessions/:sessionId or DELETE /auth/sessions revokes. |
| POST | /auth/logout | Idempotent | Terminate current session and clear cookie. |
| GET | /health & /ready | Probes | Liveness (/health) and PostgreSQL + Redis readiness (/ready) endpoints. |