A full-stack book catalog application built with Next.js, TypeScript, PostgreSQL, Prisma ORM, and NextAuth.js for user authentication.
- User Authentication: Sign up/Sign in with email/password or Google OAuth
- Book Management: Add, view, and delete books
- Responsive Design: Mobile-friendly interface using Tailwind CSS
- Type Safety: Full TypeScript implementation
- Database Integration: PostgreSQL with Prisma ORM
- Session Management: Secure authentication with NextAuth.js
- Frontend: Next.js 15 (App Router) + TypeScript
- Backend: Next.js API Routes
- Authentication: NextAuth.js (Email/Password, Google)
- Database: PostgreSQL (hosted via Neon/Supabase/ElephantSQL)
- ORM: Prisma
- Styling: Tailwind CSS
- Deployment: Vercel
| Method | Route | Description |
|---|---|---|
| GET | /api/books |
Fetch all books |
| POST | /api/books |
Add a new book |
| DELETE | /api/books/:id |
Delete a book |
- Home Page (
/): Display all books with delete functionality - Add Book Page (
/add): Form to add new books - Authentication Pages (
/auth/signin): Login/signup with email/password or Google
- Node.js 18+
- PostgreSQL database (local or hosted)
- Google OAuth credentials (optional)
git clone <your-repo-url>
cd book-catalog
npm installCreate a .env.local file in the root directory:
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/book_catalog"
# NextAuth.js
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here"
# Google OAuth (optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma migrate dev
# (Optional) Seed the database
npx prisma db seednpm run devVisit http://localhost:3000 to see the application.
git add .
git commit -m "Initial commit"
git push origin main-
Connect your GitHub repository to Vercel
-
Set the following environment variables in Vercel:
DATABASE_URL: Your PostgreSQL connection stringNEXTAUTH_URL: Your Vercel app URLNEXTAUTH_SECRET: A random secret stringGOOGLE_CLIENT_ID: Your Google OAuth client ID (optional)GOOGLE_CLIENT_SECRET: Your Google OAuth client secret (optional)
-
Deploy the application
After deployment, run the database migration:
npx prisma migrate deploy- Users can register with name, email, and password
- Passwords are hashed using bcryptjs
- Users can sign in with their credentials
- Users can sign in with their Google account
- Requires Google OAuth credentials setup
- Automatically creates user account on first sign-in
id: Unique identifiername: User's full nameemail: User's email (unique)password: Hashed password (for email/password auth)image: Profile image URLcreatedAt: Account creation timestampupdatedAt: Last update timestamp
id: Unique identifiertitle: Book titleauthor: Book authorgenre: Book genreuserId: Reference to the user who added the bookcreatedAt: Book creation timestampupdatedAt: Last update timestamp
book-catalog/
├── src/
│ ├── app/
│ │ ├── api/
│ │ │ ├── auth/
│ │ │ │ ├── [...nextauth]/route.ts
│ │ │ │ └── register/route.ts
│ │ │ └── books/
│ │ │ ├── route.ts
│ │ │ └── [id]/route.ts
│ │ ├── auth/
│ │ │ └── signin/page.tsx
│ │ ├── add/page.tsx
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ └── providers.tsx
│ ├── lib/
│ │ ├── auth.ts
│ │ └── prisma.ts
│ └── types/
│ └── book.ts
├── prisma/
│ └── schema.prisma
├── .env.example
└── README.md
✅ Backend API (Next.js + Prisma): Complete CRUD operations for books ✅ Authentication (NextAuth.js): Email/password and Google OAuth ✅ TypeScript Usage: Full type safety throughout the application ✅ Code Structure & Organization: Clean, modular architecture ✅ UI Design & UX: Responsive design with Tailwind CSS ✅ Deployment: Ready for Vercel deployment
- GitHub Repository: [Your GitHub Repo Link]
- Live Application: [Your Vercel Deployment Link]
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License.