An open API service indexing awesome lists of open source software.

https://github.com/amarmuric04/auth_template

๐Ÿ” A secure, production-ready auth starter with passwordless login (OTP) using custom JWT, plus OAuth via NextAuth (Google & GitHub). Built on Next.js with Prisma ORM and Supabase as the backend. Includes a modern UI, full responsiveness, and a built-in AI chatbot integration โ€” ready to drop into any SaaS or app project.
https://github.com/amarmuric04/auth_template

ai-chatbot auth fullstack jwt nextauth nextjs oauth otp passwordless postgresql prisma secure-login supabase

Last synced: 3 months ago
JSON representation

๐Ÿ” A secure, production-ready auth starter with passwordless login (OTP) using custom JWT, plus OAuth via NextAuth (Google & GitHub). Built on Next.js with Prisma ORM and Supabase as the backend. Includes a modern UI, full responsiveness, and a built-in AI chatbot integration โ€” ready to drop into any SaaS or app project.

Awesome Lists containing this project

README

          

# ๐Ÿ” Full Auth Template โ€“ Custom JWT + OTP + OAuth (Next.js + Prisma + Supabase)

A modern and secure **authentication template** built with **Next.js**, featuring:

- ๐Ÿ”‘ **Custom credentials auth** using **passwordless OTP** (no passwords stored!)
- ๐Ÿ” **OAuth support** with **GitHub** and **Google** (via NextAuth)
- โš™๏ธ **Custom JWT-based system** for credentials auth
- ๐Ÿง  A custom-built **AI chatbot** integrated and ready to go
- ๐ŸŽจ Fully responsive, modern UI
- ๐Ÿงฉ **Supabase** PostgreSQL database with **Prisma ORM**

Designed for scalability and security, this starter gives you everything you need to bootstrap a real-world auth system.

---

## ๐Ÿš€ Features

- โœ… Passwordless authentication via OTP codes (email-based)
- ๐Ÿ” OAuth support with GitHub and Google via NextAuth
- ๐Ÿ”‘ Custom credentials login with stateless JWT handling
- ๐Ÿง  Integrated AI chatbot (drop-in use or extendable)
- ๐Ÿ“ฑ Fully responsive and mobile-friendly
- ๐Ÿ’ฝ PostgreSQL + Supabase backend with Prisma ORM
- ๐Ÿงฐ Built with **Next.js App Router** and modular component design

---

## ๐Ÿงฑ Tech Stack

| Layer | Tech |
|--------------|-----------------|
| Frontend | Next.js |
| Backend | Next.js (API) |
| Auth (OAuth) | NextAuth |
| Auth (OTP) | Custom JWT + OTP |
| DB | PostgreSQL via Supabase |
| ORM | Prisma |
| AI Chatbot | Custom-built (plug-and-play) |

---

## ๐Ÿ”ง Getting Started

### 1. Clone the Repository

```bash
git clone https://github.com/amarmuric04/auth-template.git
cd auth-template
```

### 2. Install Dependencies

```bash
npm install
# or
yarn
```

### 3. Configure Environment Variables

Copy `.env.example` to `.env.local`:

```env
DATABASE_URL=postgresql://user:password@host:port/dbname

# JWT Secrets
JWT_SECRET=your_jwt_secret

# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your_service_role

# NextAuth (for OAuth)
NEXTAUTH_SECRET=nextauth_secret_here
NEXTAUTH_URL=http://localhost:3000
GITHUB_ID=your_github_id
GITHUB_SECRET=your_github_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
```

### 4. Set Up the Database

```bash
npx prisma generate
npx prisma db push
```

> โœ… Schema already included for user, OTP verification, sessions, and chatbot data.

### 5. Seed the Database (Optional)

Use mock data or your own:

```bash
npm run seed
```

### 6. Start the App

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000)

---

## ๐Ÿงฌ How Authentication Works

### ๐Ÿ”‘ OTP-based Credentials (Passwordless)

- Users login with email
- An OTP code is emailed (or mocked in dev)
- OTP is verified and a **JWT** is issued
- Stateless auth: sessions are stored client-side via JWT

### ๐Ÿงท OAuth Login

- Handles GitHub and Google using **NextAuth**
- Session strategy can be configured (JWT or DB-based)

---

## ๐Ÿค– AI Chatbot

A smart, extendable chatbot built directly into the UI.

- Custom hook/API integration
- Chat log stored in Supabase
- UI is mobile-ready and responsive
- Great for onboarding or user help center

---

## ๐Ÿ“ Project Structure

``
/app โ†’ Next.js App Router pages
/components โ†’ UI and shared components
/lib โ†’ Utilities (auth, jwt, helpers)
/prisma โ†’ Prisma schema and client
/pages/api/auth โ†’ Custom API for OTP + NextAuth
/styles โ†’ Global CSS / Tailwind
/chatbot โ†’ AI bot logic and UI
``

---

## ๐Ÿ” Security Notes

- Passwordless auth = more secure and lower friction
- OTP expires after X minutes (configurable)
- JWT is signed with server-only secret
- OAuth tokens never touch your DB directly
- Fully stateless login path with fallback to OAuth

---

## ๐Ÿงช Testing

Coming soon:
- Jest for unit tests
- Playwright for E2E
- Auth flow test harness

---

## ๐Ÿ“ฆ Deployment

- One-click deploy to **Vercel**
- Add env variables in Vercel dashboard
- Works with Docker (optional)

---

## ๐Ÿ“œ License

MIT

---

Built for modern apps that need secure, scalable, and flexible authentication + AI support.