This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Inter, a custom Google Font.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
Create Project:
npx create-next-app@latest ai-character-creator --typescript --eslint --tailwindRun Shadcn CLI
npx shadcn-ui@latest initClerk Authentication
- create an account here
- Set Environment Keys in .env
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_aGXXXXXXXXXX
CLERK_SECRET_KEY=sk_test_WFgWXXXXXXXXXXXXXXXX- Install @clerk/nextjs
npm install @clerk/nextjs- Mount Updating app/layout.tsx with wrapper.
- Protect application
creating
middleware.tsfile at the root - build sign-up and sing-in pages.
- Add more environmental variables to .env
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/ NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
Adding button component from shadcn ui:
npx shadcn-ui@latest add buttonAdding Dark mode
- installing
next-themes
npm i next-themes@latest- creating a theme provider
components/theme-provider.tsx
"use client" import * as React from "react" import { ThemeProvider as NextThemesProvider } from "next-themes" import { type ThemeProviderProps } from "next-themes/dist/types" export function ThemeProvider({ children, ...props }: ThemeProviderProps) { return <NextThemesProvider {...props}>{children}</NextThemesProvider> }
- Adding the
ThemeProviderto root layout.<ThemeProvider attribute="class" defaultTheme="system" enableSystem> {children} </ThemeProvider>
- Adding theme toggle following this
npx shadcn-ui@latest add dropdown-menu
- Adding sheet component
npx shadcn-ui@latest add sheet
Display a form input field
npx shadcn-ui@latest add inputnpm install query-stringInitializing prisma
npm i -D prisma
npx prisma initCreating an account with 'planetscale' Creating DB with prisma and mysql provider Modifying 'prisma/schema.prisma' file:
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
generator client {
provider = "prisma-client-js"
}After schema.prisma file is being edited:
npx prisma generate
npx prisma db pushchecking db in localhost:
npx prisma studioSeeding category names
node scripts/seed.tsAdding character creation form
npx shadcn-ui@latest add formAdding Textarea
npx shadcn-ui@latest add formAdding separator
npx shadcn-ui@latest add separatorAdding Select component
npx shadcn-ui@latest add selectSetting up Cloudinary for image upload
In .env file
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME="CloudNameHere"Installing package:
npm i next-cloudinarynpm i axios
npx shadcn-ui@latest add toastnpm i ainpm i @pinecone-database/pinecone
npm i @upstash/redis
npm i @upstash/ratelimit
npm i langchainSetting up Pinecone: Name: character Dimentions: 1536
Adding environmental variables for Pinecone, Upstash and OpenAI
PINECONE_INDEX="character"
PINECONE_ENVIRONMENT="gcX-XXXXXX"
PINECONE_API_KEY="dccXXX-XXX-XXX-XXXX-XXXXX"
UPSTASH_REDIS_REST_URL="https://XXXXXXXXXXXXXXXXXXXXXXX"
UPSTASH_REDIS_REST_TOKEN="XXXXXXXXXXXXXXXXXxxx"
OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXXXXSetting up stripe:
stripe listen --forward-to localhost:3000/api/webhookStripe UI:
npm i zustand
npx shadcn-ui@latest add dialog