Skip to content

Commit 513fbff

Browse files
Initial commit
0 parents  commit 513fbff

29 files changed

Lines changed: 11582 additions & 0 deletions

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DATABASE_URL=file:./dev.db
2+
BETTER_AUTH_SECRET=
3+
BETTER_AUTH_URL=http://localhost:3000
4+
EMAIL_USER=
5+
EMAIL_PASS=""

.gemini/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"mcpServers": {
3+
"nuxt-remote": {
4+
"httpUrl": "https://nuxt.com/mcp"
5+
},
6+
"nuxt-ui-remote": {
7+
"httpUrl": "https://ui.nuxt.com/mcp"
8+
},
9+
"better-auth": {
10+
"httpUrl": "https://mcp.chonkie.ai/better-auth/better-auth-builder/mcp"
11+
}
12+
}
13+
}

.github/workflows/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
permissions:
11+
id-token: write # This is required for requesting the JWT
12+
runs-on: ubuntu-24.04-arm
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
# - name: Set up Docker Buildx
19+
# uses: docker/setup-buildx-action@v1
20+
21+
- name: configure aws credentials
22+
uses: aws-actions/configure-aws-credentials@v4
23+
with:
24+
role-to-assume: arn:aws:iam::654654236858:role/GithubActions
25+
role-session-name: GitHub_to_AWS_via_FederatedOIDC
26+
aws-region: us-east-2
27+
28+
- name: Login to Amazon ECR
29+
id: login-ecr
30+
uses: aws-actions/amazon-ecr-login@v2
31+
32+
- name: Build and Push Docker image
33+
env:
34+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry}}
35+
REPOSITORY: nuxt-template
36+
IMAGE_TAG: ${{ github.sha}}
37+
DATABASE_URL: "file:./dev.db"
38+
run: |
39+
docker build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG .
40+
docker build --output type=image,push=true --platform linux/arm64 -t $ECR_REGISTRY/$REPOSITORY:prod .

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example
25+
26+
/prisma/generated
27+
/prisma/migrations
28+
/dev.db

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

.prettierignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Package managers and build outputs
2+
node_modules
3+
.nuxt
4+
.output
5+
dist
6+
7+
# Prisma and Database
8+
prisma/migrations
9+
*.db
10+
*.db-journal
11+
12+
# Version control
13+
.git
14+
15+
# Public assets (often minified or binary)
16+
public/
17+
18+
# Environment files
19+
.env
20+
.env.*

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "es5",
6+
"printWidth": 100,
7+
"bracketSpacing": true,
8+
"arrowParens": "always",
9+
"endOfLine": "lf",
10+
"vueIndentScriptAndStyle": true,
11+
"plugins": ["prettier-plugin-tailwindcss"]
12+
}

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Nuxt Template (Better Auth + Prisma + SQLite)
2+
3+
A modern, production-ready Nuxt 4 template featuring a robust authentication system, ORM integration, and a clean UI foundation.
4+
5+
## Features
6+
7+
- **Nuxt 4**: The latest and greatest from the Nuxt team.
8+
- **Better Auth**: Comprehensive authentication with **Email OTP** support.
9+
- **Prisma**: Type-safe ORM for interacting with the database.
10+
- **SQLite**: Lightweight, zero-configuration database, ideal for development and small-to-medium projects.
11+
- **Nuxt UI v3**: Beautiful, accessible, and customizable UI components built with Tailwind CSS.
12+
- **Nodemailer**: Pre-configured for sending verification emails via Gmail.
13+
14+
## Stack
15+
16+
- **Framework**: [Nuxt](https://nuxt.com/)
17+
- **Auth**: [Better Auth](https://www.better-auth.com/)
18+
- **ORM**: [Prisma](https://www.prisma.io/)
19+
- **Database**: [SQLite](https://sqlite.org/)
20+
- **UI Framework**: [Nuxt UI](https://ui3.nuxt.com/)
21+
- **Email**: [Nodemailer](https://nodemailer.com/)
22+
23+
## Getting Started
24+
25+
### 1. Clone the repository
26+
27+
```bash
28+
git clone <your-repo-url>
29+
cd nuxt-template
30+
```
31+
32+
### 2. Install dependencies
33+
34+
This project uses `pnpm`, but you can use `npm` as well.
35+
36+
```bash
37+
pnpm install
38+
```
39+
40+
### 3. Setup Environment Variables
41+
42+
Copy the example environment file and fill in your details.
43+
44+
```bash
45+
cp .env.example .env
46+
```
47+
48+
Open `.env` and configure the following:
49+
50+
- `DATABASE_URL`: The SQLite connection string (default: `file:./dev.db`).
51+
- `BETTER_AUTH_SECRET`: A secure random string for encryption. You can generate one using `openssl rand -hex 32`.
52+
- `BETTER_AUTH_URL`: The base URL of your application (default: `http://localhost:3000`).
53+
- `EMAIL_USER`: Your Gmail address (for OTP delivery).
54+
- `EMAIL_PASS`: Your Gmail App Password. [How to generate an App Password](https://support.google.com/accounts/answer/185833).
55+
56+
### 4. Database Setup
57+
58+
Initialize your SQLite database and run migrations.
59+
60+
```bash
61+
pnpm dlx prisma migrate dev --name init
62+
```
63+
64+
Generate the Prisma client
65+
66+
```bash
67+
pnpm dlx prisma generate
68+
```
69+
70+
To reset the database and run the seed script:
71+
72+
```bash
73+
pnpm prisma:reset
74+
```
75+
76+
### 5. Start the development server
77+
78+
```bash
79+
pnpm dev
80+
```
81+
82+
Your application will be available at `http://localhost:3000`. This command also starts **Prisma Studio** automatically.
83+
84+
### 6. How to Login
85+
86+
Login requires an email address that already exists in the database.
87+
88+
- **Option A: Use the seeded user**
89+
Go to `/auth` and log in with `alice@a.com`.
90+
- **Option B: Use your own email**
91+
Update `prisma/seed.ts` with your email, then run `pnpm prisma:reset` to re-seed.
92+
93+
**To get your OTP:**
94+
95+
- Check your configured email inbox.
96+
- **Or**, check the **Prisma Studio** tab in your browser and look in the `Verification` table.
97+
98+
## Project Structure
99+
100+
- `app/`: Frontend code (pages, components, assets, composables).
101+
- `server/`: Backend code (API routes, authentication logic, database utilities).
102+
- `prisma/`: Database schema, migrations, and seed scripts.
103+
- `public/`: Static assets.
104+
105+
## License
106+
107+
MIT

app/app.vue

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script setup lang="ts">
2+
const colorMode = useColorMode()
3+
4+
const isDark = computed({
5+
get () {
6+
return colorMode.value === 'dark'
7+
},
8+
set () {
9+
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
10+
}
11+
})
12+
</script>
13+
14+
<template>
15+
<UApp>
16+
<div class="min-h-screen flex flex-col bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 transition-colors duration-300">
17+
<header class="border-b border-gray-200 dark:border-gray-800 bg-white/75 dark:bg-gray-900/75 backdrop-blur-md sticky top-0 z-50">
18+
<UContainer class="flex items-center justify-between h-16">
19+
<NuxtLink to="/" class="text-xl font-bold flex items-center gap-2">
20+
<UIcon name="i-heroicons-cube-transparent" class="w-8 h-8 text-primary-500" />
21+
<span>Nuxt Template</span>
22+
</NuxtLink>
23+
24+
<div class="flex items-center gap-2">
25+
<UButton
26+
:icon="isDark ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'"
27+
color="neutral"
28+
variant="ghost"
29+
@click="isDark = !isDark"
30+
aria-label="Toggle Theme"
31+
/>
32+
</div>
33+
</UContainer>
34+
</header>
35+
36+
<main class="flex-1">
37+
<NuxtPage />
38+
</main>
39+
</div>
40+
</UApp>
41+
</template>

app/assets/css/main.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import "tailwindcss";
2+
@import "@nuxt/ui";
3+

0 commit comments

Comments
 (0)