LAUNCH PROMOSave 20% on ArkRealm Auth Starter (first 15 licenses) — code LAUNCH auto-applied at checkout.
ArkRealm logoArkRealm
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.

[ Next.js 16 · auth-ui (:3001) ] ── Credentialed CORS ──▶ [ Express 5 · auth-api (:3000) ]
                                                              ├── Redis 8       (Sessions & rate limiters)
                                                              └── PostgreSQL 18 (Users, OAuth & encrypted TOTP)

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.

Free Demo (--lite)
No Token
sh
npx arkrealm init auth-demo --lite
cd auth-demo && docker compose up --build -d

# UI:  http://localhost:3001
# API: http://localhost:3000/docs
Instant Release ZIP
v1.0.0
sh
unzip arkrealm-auth-starter-v1.0.0.zip
cd arkrealm-auth-starter
cp auth-api/.env.example auth-api/.env
cp auth-ui/.env.example auth-ui/.env.local
docker compose up --build -d
Via CLI (GitHub PAT)
Paid Repo
sh
npx arkrealm@latest init my-app --token <YOUR_GITHUB_PAT>
cd my-app
docker compose up --build -d

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)RepoExample / DefaultRole
PORT / APP_URL / CORS_ORIGINauth-api3000 / http://localhost:3001 / http://localhost:3001API port, frontend base URL for links/OAuth redirects, and allowed CORS origins.
DATABASE_URL / REDIS_URLauth-apipostgresql://postgres:postgres@localhost:5432/auth_db · redis://localhost:6379PostgreSQL 18 (Prisma 7) and Redis 8 (sessions & rate limiters). SESSION_TTL defaults to 604800s (7d).
TOTP_ENCRYPTION_KEYauth-api64-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_URIauth-apihttp://localhost:3000/auth/google/callbackOptional Google OAuth 2.0 credentials; set all three together or leave blank.
SMTP_HOST / PORT / USER / PASS / EMAIL_FROMauth-apismtp.example.com / 587Leave SMTP_HOST empty in development to log links to stdout; required in production.
TRUST_PROXYauth-api0 (or 1 behind reverse proxy)Sets reverse proxy hop count for accurate client IPs behind Nginx, Cloudflare, or cloud hosts.
NEXT_PUBLIC_API_URLauth-uihttp://localhost:3000Points 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.

MethodRouteGuardSummary
POST/auth/registerregisterRateLimiterRegister user and send email verification token.
POST/auth/loginloginRateLimiterAuthenticate credentials and issue session or 2FA challenge.
POST/auth/verify-emailemailActionRateLimiterVerify email token; /auth/verify-email/resend re-sends verification.
POST/auth/forgot-passwordemailActionRateLimiterSend password reset token; /auth/reset-password updates password.
GET/auth/googleloginRateLimiterStart Google OAuth flow (/auth/google/callback & POST /auth/google/token).
POST/auth/2fa/setuprequireAuthInitialize TOTP 2FA (/auth/2fa/enable, /auth/2fa/verify, /auth/2fa/disable).
GET/auth/merequireAuthFetch authenticated user profile; POST /auth/change-password updates password.
GET/auth/sessionsrequireAuthList active sessions; DELETE /auth/sessions/:sessionId or DELETE /auth/sessions revokes.
POST/auth/logoutIdempotentTerminate current session and clear cookie.
GET/health & /readyProbesLiveness (/health) and PostgreSQL + Redis readiness (/ready) endpoints.

5. Production Notes

TOTP 2FA & Session Control

TOTP secrets are encrypted at rest with AES-256-GCM, and active sessions live in Redis 8 so users can inspect devices or revoke individual or other sessions.

Repository Docs & AI Context

Every starter repo includes docs/ guides, openapi.json, Vitest tests, AGENTS.md, and llms.txt.

  • Generate a 32-byte hex TOTP_ENCRYPTION_KEY (openssl rand -hex 32) and configure SMTP_* before setting NODE_ENV=production.
  • Set APP_URL, CORS_ORIGIN, and GOOGLE_REDIRECT_URI (if using Google OAuth) to your exact production origins.
  • Set TRUST_PROXY=1 when running behind a reverse proxy or platform ingress so rate limiters see real client IPs.
  • Run pnpm prisma migrate deploy before starting the API server, and wire /health and /ready to your health checks.
  • Full environment details, security notes, and deployment walkthroughs are included inside the repository under docs/.

Ready to inspect it live or get the source?

Try the running demo or grab a one-time license with CLI and private repository access.